Still able to access raw tensor data after close() is called
未关闭
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 928
- 派生
- 227
- PR 合并指标
- 30 天内没有已合并 PR
描述
System information
- Have I written custom code: see simple test case below to reproduce
- OS Platform and Distribution: Windows 10, 64-bit operating system, x64-based processor
- TensorFlow installed from (source or binary): binary via Maven
- TensorFlow version: v0.4.1
- Java version (i.e., the output of
java -version): AdoptOpenJDK-11.0.11+9 - Java command line flags (e.g., GC parameters): N/A
- CUDA/cuDNN version: N/A - using pure CPU version
- GPU model and memory: N/A - using pure CPU version
Describe the current behavior
After closing a tensor output from a concrete function (and the concrete function itself), am still able to access the tensor's raw data.
Describe the expected behavior
Expect an IllegalStateException when accessing the raw tensor data because close() was already called on the tensor.
Code to reproduce the issue
// Create simple (a + b) function
ConcreteFunction addTwoInts = ConcreteFunction.create((tf) -> {
Placeholder<TInt32> inputA = tf.placeholder(TInt32.class);
Placeholder<TInt32> inputB = tf.placeholder(TInt32.class);
Add<TInt32> output = tf.math.add(inputA, inputB);
return Signature.builder().key("add")
.input("a", inputA)
.input("b", inputB)
.output("out", output)
.build();
});
// Apply to input
Map<String, Tensor> input = Map.of(
"a", TInt32.scalarOf(1),
"b", TInt32.scalarOf(2));
Tensor output = addTwoInts.call(input).get("out");
// Close everything
addTwoInts.close();
output.close();
// Expect java.lang.IllegalStateException: close() was called on the Tensor
output.asRawTensor().data(); // However, no exception is thrown here
Have recently upgraded from v0.2.0, where the same test case setup would throw the excepted exception.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先追踪所提供复现中涉及的入口点 Tensor.close() 和 Tensor.asRawTensor().data(),包括 ConcreteFunction.close() 的生命周期。确认在 output.close() 后访问原始数据会产生预期的 IllegalStateException;如果找到相关测试,则为此行为添加或更新覆盖率。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- machine-learning
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100