-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Still able to access raw tensor data after close() is called #460
Comments
The semantic of void main() {
try (var g = new Graph(); var s = new Session(g)) {
var function = SessionFunction.create(myFunc(Ops.create(g)), session);
try (var result = function.call(...)) {
...
}
}
}
Signature myFunc(Ops 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();
} Normally But that being said, can you compare your actual observations with a newest version of the library (e.g. 0.4.1) and share your results? |
thanks for getting back so quickly @karllessard ! I can see that the API for With this in mind, I've set up some like-for-like tests between Concrete vs. Session function. When run locally with Test Case 1
@Test
public void testWithSessionFunctionThenCallCloseOnOutput() {
Map<String, Tensor> input = Map.of("a", TInt32.scalarOf(1), "b", TInt32.scalarOf(2));
Tensor result;
try (var graph = new Graph(); var session = new Session(graph)) {
var ops = Ops.create(graph);
var function = SessionFunction.create(addSig(ops), session);
result = function.call(input).get("out");
}
result.close();
// java.lang.IllegalStateException: close() was called on the Tensor
result.asRawTensor().data();
} Test Case 2
@Test
public void testWithConcreteFunctionThenCallCloseOnOutput() {
Map<String, Tensor> input = Map.of("a", TInt32.scalarOf(1), "b", TInt32.scalarOf(2));
Tensor result;
try (var graph = new Graph(); var session = new Session(graph)) {
var ops = Ops.create(graph);
try (var function = ConcreteFunction.create(addSig(ops), session)) {
result = function.call(input).get("out");
}
}
result.close();
// No exception is thrown
result.asRawTensor().data();
} Would we not expect the same behaviour here between the two function types? Thanks again for the help! |
System information
java -version
): AdoptOpenJDK-11.0.11+9Describe 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 becauseclose()
was already called on the tensor.Code to reproduce the issue
Have recently upgraded from v0.2.0, where the same test case setup would throw the excepted exception.
The text was updated successfully, but these errors were encountered: