| @@ -178,6 +178,13 @@ namespace Tensorflow | |||||
| return dtype; | return dtype; | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Converts the given list or tuple to a tensor by packing. | |||||
| /// </summary> | |||||
| /// <param name="list_or_tuple">A (possibly nested) list or tuple containing a tensor.</param> | |||||
| /// <param name="dtype"></param> | |||||
| /// <param name="name"></param> | |||||
| /// <returns>A `tf.Tensor` with value equivalent to `list_or_tuple`.</returns> | |||||
| public static Tensor _autopacking_helper(object[] list_or_tuple, TF_DataType dtype, string name) | public static Tensor _autopacking_helper(object[] list_or_tuple, TF_DataType dtype, string name) | ||||
| { | { | ||||
| var must_pack = false; | var must_pack = false; | ||||
| @@ -122,6 +122,12 @@ namespace Tensorflow | |||||
| public static Tensor pack(Tensor[] values, int axis = 0, string name = null) | 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 }); | var _op = _op_def_lib._apply_op_helper("Pack", name: name, args: new { values, axis }); | ||||
| return _op.outputs[0]; | return _op.outputs[0]; | ||||
| @@ -97,9 +97,6 @@ namespace Tensorflow | |||||
| /// <returns></returns> | /// <returns></returns> | ||||
| public static Tensor convert_to_tensor(object value, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid) | 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); | return convert_to_tensor_v2(value, dtype, preferred_dtype, name); | ||||
| } | } | ||||