@@ -25,17 +25,17 @@ public static Tensor convert_to_tensor(object value, string name = "")
2525
2626 public static unsafe IntPtr _create_c_op ( Graph graph , NodeDef node_def , List < Tensor > inputs )
2727 {
28- var op_desc = c_api . TF_NewOperation ( graph , node_def . Op , node_def . Name ) ;
28+ var op_desc = graph . NewOperation ( node_def . Op , node_def . Name ) ;
2929
3030 // Add inputs
3131 if ( inputs != null && inputs . Count > 0 )
3232 {
33- foreach ( var op_input in inputs )
33+ /* foreach (var op_input in inputs)
3434 {
3535 c_api.TF_AddInput(op_desc, op_input._as_tf_output());
36- }
36+ }*/
3737
38- // c_api.TF_AddInputList(op_desc, inputs.Select(x => x._as_tf_output()).ToArray(), inputs.Count);
38+ c_api . TF_AddInputList ( op_desc , inputs . Select ( x => x . _as_tf_output ( ) ) . ToArray ( ) , inputs . Count ) ;
3939 }
4040
4141 var status = new Status ( ) ;
@@ -48,9 +48,10 @@ public static unsafe IntPtr _create_c_op(Graph graph, NodeDef node_def, List<Ten
4848 var bytes = attr . Value . ToByteArray ( ) ;
4949 var proto = Marshal . AllocHGlobal ( bytes . Length ) ;
5050 Marshal . Copy ( bytes , 0 , proto , bytes . Length ) ;
51- c_api . TF_SetAttrValueProto ( op_desc , attr . Key , proto , proto_len : ( UIntPtr ) bytes . Length , status : status ) ;
51+
52+ c_api . TF_SetAttrValueProto ( op_desc , attr . Key , proto , proto_len : ( uint ) bytes . Length , status : status ) ;
5253
53- if ( status . Code != TF_Code . TF_OK ) throw new Exception ( status . Message ) ;
54+ status . Check ( true ) ;
5455 }
5556
5657 var c_op = c_api . TF_FinishOperation ( op_desc , status ) ;
@@ -60,6 +61,11 @@ public static unsafe IntPtr _create_c_op(Graph graph, NodeDef node_def, List<Ten
6061 return c_op ;
6162 }
6263
64+ public static OpDef _get_op_def ( Graph graph , string type )
65+ {
66+ return graph . GetOpDef ( type ) ;
67+ }
68+
6369 public static NodeDef _NodeDef ( string op_type , string name , string device = "" , Dictionary < string , AttrValue > attrs = null )
6470 {
6571 var node_def = new node_def_pb2 . NodeDef ( ) ;
0 commit comments