From 67a661a1a3e5810ba79260af12f56a08c79500da Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Sat, 28 Nov 2020 00:10:54 -0600 Subject: [PATCH] add overload for math.logical_and. --- src/TensorFlowNET.Core/APIs/tf.math.cs | 3 +++ src/TensorFlowNET.Core/Operations/gen_math_ops.cs | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/TensorFlowNET.Core/APIs/tf.math.cs b/src/TensorFlowNET.Core/APIs/tf.math.cs index 9a405b49..2d91be12 100644 --- a/src/TensorFlowNET.Core/APIs/tf.math.cs +++ b/src/TensorFlowNET.Core/APIs/tf.math.cs @@ -211,6 +211,9 @@ namespace Tensorflow public Tensor logical_and(Tensor x, Tensor y, string name = null) => gen_math_ops.logical_and(x, y, name); + public Tensor logical_and(bool x, bool y, string name = null) + => gen_math_ops.logical_and(x, y, name); + public Tensor logical_not(Tensor x, string name = null) => gen_math_ops.logical_not(x, name); diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index bb9cc1c9..f059b9bd 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -578,10 +578,21 @@ namespace Tensorflow x); public static Tensor logical_and(Tensor x, Tensor y, string name = null) + => tf.OpDefLib._apply_op_helper("LogicalAnd", name, args: new { x, y }); + + public static Tensor logical_and(bool x, bool y, string name = null) { - var _op = tf.OpDefLib._apply_op_helper("LogicalAnd", name, args: new { x, y }); + if (tf.Context.executing_eagerly()) + { + var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, + "LogicalAnd", name, + null, + x, y); - return _op.outputs[0]; + return results[0]; + } + + return tf.OpDefLib._apply_op_helper("LogicalAnd", name, args: new { x, y }); } public static Tensor logical_not(Tensor x, string name = null)