Skip to content

Commit 9dba680

Browse files
committed
minor changes
1 parent 33c4a9a commit 9dba680

3 files changed

Lines changed: 8 additions & 24 deletions

File tree

src/TensorFlowNET.Core/Operations/control_flow_ops.py.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -290,33 +290,11 @@ public static Tensor cond(Tensor pred,
290290
{
291291
// TODO: here a chunk of original code is missing
292292
/*
293-
if fn1 is not None:
294-
if true_fn is not None:
295-
raise TypeError("cond(): true_fn and fn1 may not be set simultaneously.")
296-
true_fn = fn1
297-
elif true_fn is None:
298-
raise TypeError("cond(): true_fn argument required")
299-
if fn2 is not None:
300-
if false_fn is not None:
301-
raise TypeError("cond(): false_fn and fn2 may not be set simultaneously.")
302-
false_fn = fn2
303-
elif false_fn is None:
304-
raise TypeError("cond(): false_fn argument required")
305-
306-
if not callable(true_fn):
307-
raise TypeError("true_fn must be callable.")
308-
if not callable(false_fn):
309-
raise TypeError("false_fn must be callable.")
310-
311293
with ops.name_scope(name, "cond", [pred]):
312294
if context.executing_eagerly():
313295
if pred:
314296
return _UnpackIfSingleton(true_fn())
315297
return _UnpackIfSingleton(false_fn())
316-
317-
# Add the Switch to the graph.
318-
if isinstance(pred, bool):
319-
raise TypeError("pred must not be a Python bool")
320298
*/
321299

322300
// Add the Switch to the graph.

test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void testCondTrue()
1919
var y = tf.constant(5);
2020
var z = control_flow_ops.cond(tf.less(x, y), () => tf.multiply(x, tf.constant(17)),
2121
() => tf.add(y, tf.constant(23)));
22-
tf.train.export_meta_graph(@"D:\dev\tensorboard\logdir\sharp.meta", as_text: false);
22+
//tf.train.export_meta_graph(@"D:\dev\tensorboard\logdir\sharp.meta", as_text: false);
2323
self.assertEquals(eval_scalar(z), 34);
2424
});
2525
}

test/TensorFlowNET.UnitTest/ops_test/ControlDependenciesTest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void TestNested()
139139
var a_2 = constant_op.constant(3.0);
140140
var a_3 = constant_op.constant(4.0);
141141
var a_4 = constant_op.constant(5.0);
142-
Operation b_1 = null, b_2 = null;
142+
Tensor b_1 = null, b_2 = null;
143143
with(g.control_dependencies(new[] { a_1, a_2, a_3, a_4 }), ctrl =>
144144
{
145145
b_1 = constant_op.constant(6.0);
@@ -157,6 +157,12 @@ public void TestNested()
157157
});
158158
});
159159
});
160+
var z=tf.add(a_1, tf.multiply(b_2, b_1));
161+
with(g.control_dependencies(new[] {z}), ctrl =>
162+
{
163+
var z1 = tf.add(a_3, tf.multiply(a_4, a_2));
164+
});
165+
tf.train.export_meta_graph(@"D:\dev\tensorboard\logdir\sharp.meta", as_text: false);
160166
assertItemsEqual(b_1.op.control_inputs, new[] { a_1.op, a_2.op, a_3.op, a_4.op });
161167
assertItemsEqual(b_2.op.control_inputs, b_1.op.control_inputs);
162168
}

0 commit comments

Comments
 (0)