From 653427144ab2aed6b5c557670a49e51931820906 Mon Sep 17 00:00:00 2001 From: Esther2013 Date: Tue, 10 Mar 2020 13:18:42 -0500 Subject: [PATCH] add gen_array_ops.pack eager --- src/TensorFlowNET.Core/Operations/array_ops.cs | 7 +++++++ src/TensorFlowNET.Core/Operations/gen_array_ops.cs | 6 ++++++ src/TensorFlowNET.Core/ops.cs | 3 --- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/TensorFlowNET.Core/Operations/array_ops.cs b/src/TensorFlowNET.Core/Operations/array_ops.cs index 5374d72b..662bdc77 100644 --- a/src/TensorFlowNET.Core/Operations/array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/array_ops.cs @@ -178,6 +178,13 @@ namespace Tensorflow return dtype; } + /// + /// Converts the given list or tuple to a tensor by packing. + /// + /// A (possibly nested) list or tuple containing a tensor. + /// + /// + /// A `tf.Tensor` with value equivalent to `list_or_tuple`. public static Tensor _autopacking_helper(object[] list_or_tuple, TF_DataType dtype, string name) { var must_pack = false; diff --git a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs index d151d024..e4f9cc92 100644 --- a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs @@ -122,6 +122,12 @@ namespace Tensorflow public static Tensor pack(Tensor[] values, int axis = 0, string name = null) { + if(tf.context.executing_eagerly()) + { + var _result = pywrap_tfe_src.TFE_Py_FastPathExecute(tf.context, tf.context.device_name, "Pack", name, null, values, "axis", axis); + return _result; + } + var _op = _op_def_lib._apply_op_helper("Pack", name: name, args: new { values, axis }); return _op.outputs[0]; diff --git a/src/TensorFlowNET.Core/ops.cs b/src/TensorFlowNET.Core/ops.cs index 15115d3f..9ac0a042 100644 --- a/src/TensorFlowNET.Core/ops.cs +++ b/src/TensorFlowNET.Core/ops.cs @@ -97,9 +97,6 @@ namespace Tensorflow /// public static Tensor convert_to_tensor(object value, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid) { - if (value is Tensor tensor) - return tensor; - return convert_to_tensor_v2(value, dtype, preferred_dtype, name); }