| @@ -105,6 +105,9 @@ namespace Tensorflow | |||||
| public bool building_function; | public bool building_function; | ||||
| string _container = ""; | |||||
| public string Container => _container; | |||||
| int _seed; | int _seed; | ||||
| public int seed | public int seed | ||||
| { | { | ||||
| @@ -151,6 +154,8 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (obj is RefVariable var) | if (obj is RefVariable var) | ||||
| return var._as_graph_element(); | return var._as_graph_element(); | ||||
| else if (obj is ResourceVariable resVar) | |||||
| return resVar.GraphElement; | |||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -297,6 +297,21 @@ namespace Tensorflow | |||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static extern SafeImportGraphDefOptionsHandle TF_NewImportGraphDefOptions(); | public static extern SafeImportGraphDefOptionsHandle TF_NewImportGraphDefOptions(); | ||||
| /// <summary> | |||||
| /// Set the shapes and types of the output's handle. | |||||
| /// </summary> | |||||
| /// <param name="graph">TF_Graph*</param> | |||||
| /// <param name="output">TF_Output</param> | |||||
| /// <param name="num_shapes_and_types">int</param> | |||||
| /// <param name="shapes">const int64_t**</param> | |||||
| /// <param name="ranks">const int*</param> | |||||
| /// <param name="types">const TF_DataType*</param> | |||||
| /// <param name="status">TF_Status*</param> | |||||
| [DllImport(TensorFlowLibName)] | |||||
| public static extern void TF_GraphSetOutputHandleShapesAndTypes(IntPtr graph, TF_Output output, | |||||
| int num_shapes_and_types, IntPtr[] shapes, int[] ranks, DataType[] types, | |||||
| SafeStatusHandle status); | |||||
| /// <summary> | /// <summary> | ||||
| /// Updates 'dst' to consume 'new_src'. | /// Updates 'dst' to consume 'new_src'. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -145,10 +145,9 @@ namespace TensorFlowNET.UnitTest | |||||
| //tf.Session created an other graph | //tf.Session created an other graph | ||||
| using (var sess = tf.Session()) | using (var sess = tf.Session()) | ||||
| { | { | ||||
| Tensor t = null; | |||||
| for (int i = 0; i < 100; i++) | for (int i = 0; i < 100; i++) | ||||
| { | { | ||||
| t = new Tensor(new int[] {1, 2, 3}); | |||||
| var t = new Tensor(new int[] {1, 2, 3}); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -167,12 +166,9 @@ namespace TensorFlowNET.UnitTest | |||||
| { | { | ||||
| using (var sess = tf.Session()) | using (var sess = tf.Session()) | ||||
| { | { | ||||
| #pragma warning disable CS0219 // Variable is assigned but its value is never used | |||||
| Tensor t = null; | |||||
| #pragma warning restore CS0219 // Variable is assigned but its value is never used | |||||
| for (int i = 0; i < 100; i++) | for (int i = 0; i < 100; i++) | ||||
| { | { | ||||
| var v = (int*) Marshal.AllocHGlobal(sizeof(int)); | |||||
| var v = (int*)Marshal.AllocHGlobal(sizeof(int)); | |||||
| c_api.DeallocatorArgs _deallocatorArgs = new c_api.DeallocatorArgs(); | c_api.DeallocatorArgs _deallocatorArgs = new c_api.DeallocatorArgs(); | ||||
| var handle = c_api.TF_NewTensor(typeof(int).as_dtype(), dims: new long[0], num_dims: 0, | var handle = c_api.TF_NewTensor(typeof(int).as_dtype(), dims: new long[0], num_dims: 0, | ||||
| data: (IntPtr) v, len: (UIntPtr) sizeof(int), | data: (IntPtr) v, len: (UIntPtr) sizeof(int), | ||||