From 49cbae055859e1af93fa770af1bea2d0a8615c7b Mon Sep 17 00:00:00 2001 From: Sebastian Hantsch Date: Wed, 10 Feb 2021 16:26:37 +0100 Subject: [PATCH] Fix sign function in eager mode --- src/TensorFlowNET.Core/Operations/gen_math_ops.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index 5d585e77..051f4f6b 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -374,6 +374,16 @@ namespace Tensorflow public static Tensor sign(T x, string name = "Sign") { + if (tf.executing_eagerly()) + { + var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, + "Sign", name, + null, + x); + + return results[0]; + } + var op = tf.OpDefLib._apply_op_helper("Sign", name: name, args: new { x }); return op.outputs[0];