Skip to content

Commit f516966

Browse files
committed
1 parent 1b7003b commit f516966

4 files changed

Lines changed: 12 additions & 14 deletions

File tree

‎src/TensorFlowNET.Core/Sessions/Session.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public void close()
4747
public void Dispose()
4848
{
4949
Options.Dispose();
50-
Status.Dispose();
5150
c_api.TF_DeleteSession(_handle, Status);
51+
Status.Dispose();
5252
}
5353

5454
public void __enter__()

‎test/TensorFlowNET.UnitTest/CApiGradientsTest.cs‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ private void TestGradientsSuccess(bool grad_inputs_provided)
3131
BuildSuccessGraph(inputs, outputs);
3232
BuildExpectedGraph(grad_inputs_provided, expected_grad_outputs);
3333

34-
AddGradients(grad_inputs_provided, string.Empty, inputs, 2, outputs, 1,
34+
AddGradients(grad_inputs_provided, "test", inputs, 2, outputs, 1,
3535
grad_outputs);
36-
// EXPECT_EQ(TF_OK, TF_GetCode(s_));
36+
EXPECT_EQ(TF_OK, TF_GetCode(s_));
3737

3838
// Compare that the graphs match.
3939
GraphDef expected_gdef;
4040
GraphDef gdef;
4141
EXPECT_TRUE(GetGraphDef(expected_graph_, out expected_gdef));
4242
EXPECT_TRUE(GetGraphDef(graph_, out gdef));
43-
//TF_EXPECT_GRAPH_EQ(expected_gdef, gdef);
43+
// Assert.IsTrue(expected_gdef.ToString().Equals(gdef.ToString()));
4444

4545
// Compare that the output of the gradients of both graphs match.
4646
RunGraphsAndCompareOutputs(grad_outputs, expected_grad_outputs);
@@ -65,16 +65,14 @@ private void RunGraphsAndCompareOutputs(TF_Output[] grad_outputs, TF_Output[] ex
6565
var csession = new CSession(graph_, s_);
6666
var expected_csession = new CSession(expected_graph_, s_);
6767

68-
var grad_outputs_vec = new List<IntPtr>();
69-
grad_outputs_vec.AddRange(grad_outputs.Select(x => x.oper));
68+
var grad_outputs_vec = grad_outputs;
7069
csession.SetOutputs(grad_outputs_vec);
7170
csession.Run(s_);
7271
ASSERT_EQ(TF_OK, TF_GetCode(s_));
7372
var out0 = csession.output_tensor(0);
7473
var out1 = csession.output_tensor(1);
7574

76-
var expected_grad_outputs_vec = new List<IntPtr>();
77-
expected_grad_outputs_vec.AddRange(expected_grad_outputs.Select(x => x.oper));
75+
var expected_grad_outputs_vec = expected_grad_outputs;
7876
expected_csession.SetOutputs(expected_grad_outputs_vec);
7977
expected_csession.Run(s_);
8078
ASSERT_EQ(TF_OK, TF_GetCode(s_));
@@ -197,7 +195,7 @@ private void BuildExpectedGraph(bool grad_inputs_provided, TF_Output[] expected_
197195
var matmul2 = MatMul(expected_graph_, s_, const0, const3,
198196
"gradients/MatMul_1", true, false);
199197
expected_grad_outputs[0] = new TF_Output(matmul1, 0);
200-
expected_grad_outputs[1] = new TF_Output( matmul2, 0);
198+
expected_grad_outputs[1] = new TF_Output(matmul2, 0);
201199
}
202200

203201
private Operation OnesLike(Graph graph, Status s, Operation input, string name)

‎test/TensorFlowNET.UnitTest/CSession.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ private void DeleteInputValues()
4949
input_values_.Clear();
5050
}
5151

52-
public void SetOutputs(List<IntPtr> outputs)
52+
public void SetOutputs(TF_Output[] outputs)
5353
{
5454
ResetOutputValues();
5555
outputs_.Clear();
5656
foreach (var output in outputs)
5757
{
58-
outputs_.Add(new TF_Output(output, 0));
58+
outputs_.Add(output);
5959
output_values_.Add(IntPtr.Zero);
6060
}
6161
}
@@ -75,7 +75,7 @@ public unsafe void Run(Status s)
7575
var inputs_ptr = inputs_.ToArray();
7676
var input_values_ptr = input_values_.Select(x => (IntPtr)x).ToArray();
7777
var outputs_ptr = outputs_.ToArray();
78-
var output_values_ptr = output_values_.Select(x => (IntPtr)x).ToArray();
78+
var output_values_ptr = output_values_.Select(x => IntPtr.Zero).ToArray();
7979
IntPtr[] targets_ptr = new IntPtr[0];
8080

8181
c_api.TF_SessionRun(session_, null, inputs_ptr, input_values_ptr, inputs_ptr.Length,

‎test/TensorFlowNET.UnitTest/SessionTest.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void Session()
3737
inputs.Add(feed, new Tensor(3));
3838
csession.SetInputs(inputs);
3939

40-
var outputs = new List<IntPtr> { add };
40+
var outputs = new TF_Output[] { new TF_Output(add, 0) };
4141
csession.SetOutputs(outputs);
4242

4343
csession.Run(s);
@@ -56,7 +56,7 @@ public void Session()
5656
inputs = new Dictionary<Operation, Tensor>();
5757
inputs.Add(feed, new Tensor(7));
5858
csession.SetInputs(inputs);
59-
outputs = new List<IntPtr> { neg };
59+
outputs = new TF_Output[] { new TF_Output(neg, 0) };
6060
csession.SetOutputs(outputs);
6161
csession.Run(s);
6262
ASSERT_EQ(TF_Code.TF_OK, s.Code);

0 commit comments

Comments
 (0)