/// <summary> /// Execute a TensorFlow operation. /// </summary> /// <param name="op_name"> /// Name of the TensorFlow operation (see REGISTER_OP in C++ code) to /// execute. /// </param> /// <param name="num_outputs"> /// The number of outputs of the operation to fetch. /// </param> /// <param name="inputs"> /// A list of inputs to the operation. Each entry should be a Tensor, or /// a value which can be passed to the Tensor constructor to create one. /// </param> /// <param name="attrs"> /// A tuple with alternating string attr names and attr values for this /// operation. /// </param> /// <param name="ctx">The value of context.context().</param> /// <param name="name">Customized name for the operation.</param> /// <returns>List of output Tensor objects. The list is empty if there are no outputs</returns> public Tensor execute(Context ctx, string op_name, int num_outputs, Tensor[] inputs, object[] attrs, string name = null) { ctx.ensure_initialized(); // TFE_TensorHandle using var status = new Status(); /*var retVals = wrap_tfe_src.TFE_Execute(ctx, ctx.device_name, op_name, inputs, attrs, num_outputs, status); * * return new EagerTensor((TFE_TensorHandle)retVals[0]);*/ IntPtr[] outputs = new IntPtr[num_outputs]; c_api.TFE_QuickExecute(ctx, ctx.device_name, op_name, inputs.Select(x => (x as EagerTensor).GetTfeTensorHandle()).ToArray(), inputs.Length, op => wrap_tfe_src.SetOpAttrs(op, attrs), outputs, num_outputs, status); status.Check(true); TFE_TensorHandle tfe_tensor_handle = outputs[0]; return(new EagerTensor(tfe_tensor_handle)); }
public EagerTensor(NDArray value, string device_name) : base(value) { tfe_tensor_handle = c_api.TFE_NewTensorHandle(_handle, status); }
public EagerTensor(float value, string device_name) : base(value) { tfe_tensor_handle = c_api.TFE_NewTensorHandle(_handle, status); EagerTensorHandle = c_api.TFE_EagerTensorFromHandle(tf.context, tfe_tensor_handle); }
public EagerTensor(IntPtr handle) : base(handle) { tfe_tensor_handle = handle; _handle = c_api.TFE_TensorHandleResolve(handle, status); }
public EagerTensor(double[] value, string device_name) : base(value) { tfe_tensor_handle = c_api.TFE_NewTensorHandle(_handle, status); _id = ops.uid(); }
public EagerTensor(TFE_TensorHandle handle) : base(handle) { tfe_tensor_handle = handle; _handle = c_api.TFE_TensorHandleResolve(tfe_tensor_handle, status); EagerTensorHandle = c_api.TFE_EagerTensorFromHandle(tf.context, tfe_tensor_handle); }