Beispiel #1
0
        public static TF_Output tf_output(IntPtr c_op, int index)
        {
            var ret = new TF_Output();

            ret.oper  = c_op;
            ret.index = index;

            return(ret);
        }
Beispiel #2
0
        public TF_Output[] ReturnOutputs(IntPtr results)
        {
            IntPtr return_output_handle = IntPtr.Zero;
            int    num_return_outputs   = 0;

            c_api.TF_ImportGraphDefResultsReturnOutputs(results, ref num_return_outputs, ref return_output_handle);
            TF_Output[] return_outputs = new TF_Output[num_return_outputs];
            for (int i = 0; i < num_return_outputs; i++)
            {
                var handle = return_output_handle + (Marshal.SizeOf <TF_Output>() * i);
                return_outputs[i] = Marshal.PtrToStructure <TF_Output>(handle);
            }

            return(return_outputs);
        }
Beispiel #3
0
        public unsafe TF_Output[] ImportGraphDefWithReturnOutputs(Buffer graph_def, ImportGraphDefOptions opts, Status s)
        {
            var num_return_outputs = opts.NumReturnOutputs;
            var return_outputs     = new TF_Output[num_return_outputs];
            int size = Marshal.SizeOf <TF_Output>();
            var return_output_handle = Marshal.AllocHGlobal(size * num_return_outputs);

            c_api.TF_GraphImportGraphDefWithReturnOutputs(_handle, graph_def, opts, return_output_handle, num_return_outputs, s);
            for (int i = 0; i < num_return_outputs; i++)
            {
                var handle = return_output_handle + i * size;
                return_outputs[i] = Marshal.PtrToStructure <TF_Output>(handle);
            }

            return(return_outputs);
        }
        public static string[] TF_OperationOutputConsumers_wrapper(TF_Output oper_out)
        {
            int num_consumers = TF_OperationOutputNumConsumers(oper_out);
            int size          = Marshal.SizeOf <TF_Input>();
            var handle        = Marshal.AllocHGlobal(size * num_consumers);
            int num           = TF_OperationOutputConsumers(oper_out, handle, num_consumers);
            var consumers     = new string[num_consumers];

            for (int i = 0; i < num; i++)
            {
                TF_Input input = Marshal.PtrToStructure <TF_Input>(handle + i * size);
                consumers[i] = Marshal.PtrToStringAnsi(TF_OperationName(input.oper));
            }

            return(consumers);
        }
        public static string[] TF_OperationOutputConsumers_wrapper(TF_Output oper_out)
        {
            int num_consumers = TF_OperationOutputNumConsumers(oper_out);
            int size          = Marshal.SizeOf <TF_Input>();
            var handle        = Marshal.AllocHGlobal(size * num_consumers);
            int num           = TF_OperationOutputConsumers(oper_out, handle, num_consumers);
            var consumers     = new string[num_consumers];

            unsafe
            {
                var inputptr = (TF_Input *)handle;
                for (int i = 0; i < num; i++)
                {
                    var oper = (inputptr + i)->oper;
                    consumers[i] = Marshal.PtrToStringAnsi(TF_OperationName(oper));
                }
            }

            return(consumers);
        }
        public unsafe TF_Output[] ImportGraphDefWithReturnOutputs(Buffer graph_def, ImportGraphDefOptions opts, Status s)
        {
            as_default();
            var num_return_outputs = opts.NumReturnOutputs;
            var return_outputs     = new TF_Output[num_return_outputs];
            int size = Marshal.SizeOf <TF_Output>();
            var return_output_handle = Marshal.AllocHGlobal(size * num_return_outputs);

            c_api.TF_GraphImportGraphDefWithReturnOutputs(_handle, graph_def, opts, return_output_handle, num_return_outputs, s);

            var tf_output_ptr = (TF_Output *)return_output_handle;

            for (int i = 0; i < num_return_outputs; i++)
            {
                return_outputs[i] = *(tf_output_ptr + i);
            }

            Marshal.FreeHGlobal(return_output_handle);

            return(return_outputs);
        }
Beispiel #7
0
        /// <summary>
        /// Create and return a new TF_Output for output_idx'th output of this op.
        /// </summary>
        public TF_Output _tf_output(int output_idx)
        {
            var tf_output = new TF_Output(op, output_idx);

            return(tf_output);
        }
Beispiel #8
0
 public static extern int TF_GraphGetTensorNumDims(IntPtr graph, TF_Output output, SafeStatusHandle status);
Beispiel #9
0
 public static extern void UpdateEdge(IntPtr graph, TF_Output new_src, TF_Input dst, IntPtr status);
Beispiel #10
0
 public static extern void TF_GraphGetTensorShape(IntPtr graph, TF_Output output, long[] dims, int num_dims, IntPtr status);
Beispiel #11
0
 public static extern int TF_GraphGetTensorNumDims(IntPtr graph, TF_Output output, IntPtr status);
Beispiel #12
0
 public static extern void TF_ImportGraphDefOptionsAddInputMapping(IntPtr opts, string src_name, int src_index, TF_Output dst);
Beispiel #13
0
 public static extern void TF_GraphSetOutputHandleShapesAndTypes(IntPtr graph, TF_Output output,
                                                                 int num_shapes_and_types, IntPtr[] shapes, int[] ranks, DataType[] types,
                                                                 SafeStatusHandle status);
Beispiel #14
0
 public static extern void TF_UpdateEdge(IntPtr graph, TF_Output new_src, TF_Input dst, SafeStatusHandle status);
Beispiel #15
0
 public static extern void TF_GraphSetTensorShape(IntPtr graph, TF_Output output, long[] dims, int num_dims, SafeStatusHandle status);
Beispiel #16
0
 public static extern bool TF_TryEvaluateConstant(IntPtr graph, TF_Output output, IntPtr[] result, SafeStatusHandle status);
Beispiel #17
0
 public static unsafe extern void TF_AddInput(TF_OperationDescription desc, TF_Output input);
Beispiel #18
0
 public static extern void TF_AddInput(IntPtr desc, TF_Output input);
Beispiel #19
0
 public static extern TF_DataType TF_OperationOutputType(TF_Output oper_out);
Beispiel #20
0
 public static extern unsafe int TF_OperationOutputConsumers(TF_Output oper_out, IntPtr consumers, int max_consumers);
Beispiel #21
0
 public static extern int TF_OperationOutputNumConsumers(TF_Output oper_out);