@@ -14,7 +14,7 @@ public class OpDefLibrary
1414 {
1515 public Operation _apply_op_helper ( string op_type_name , string name = "" , dynamic args = null )
1616 {
17- var keywords = ConvertToDict ( args ) ;
17+ Dictionary < string , object > keywords = ConvertToDict ( args ) ;
1818 var g = ops . get_default_graph ( ) ;
1919 var op_def = g . GetOpDef ( op_type_name ) ;
2020
@@ -42,7 +42,8 @@ public Operation _apply_op_helper(string op_type_name, string name = "", dynamic
4242 var attrs = new Dictionary < string , object > ( ) ;
4343 var inputs = new List < Tensor > ( ) ;
4444 var input_types = new List < TF_DataType > ( ) ;
45-
45+ dynamic values = null ;
46+
4647 return Python . with < ops . name_scope , Operation > ( new ops . name_scope ( name ) , scope =>
4748 {
4849 var inferred_from = new Dictionary < string , object > ( ) ;
@@ -53,7 +54,17 @@ public Operation _apply_op_helper(string op_type_name, string name = "", dynamic
5354 foreach ( var input_arg in op_def . InputArg )
5455 {
5556 var input_name = input_arg . Name ;
56- var values = keywords [ input_name ] ;
57+
58+ if ( keywords . ContainsKey ( input_name ) )
59+ values = keywords [ input_name ] ;
60+ else if ( keywords . ContainsKey ( input_name + "_" ) )
61+ {
62+ input_name += "_" ;
63+ values = keywords [ input_name ] ;
64+ }
65+ else
66+ throw new TypeError ( "No argument for input " + input_name ) ;
67+
5768 // Goals:
5869 // * Convert values to Tensors if it contains constants.
5970 // * Verify that values is a list if that matches the input_arg's
@@ -92,8 +103,8 @@ public Operation _apply_op_helper(string op_type_name, string name = "", dynamic
92103
93104 values = ops . internal_convert_n_to_tensor ( values ,
94105 name : input_arg . Name ,
95- dtype : dtype ,
96- preferred_dtype : default_dtype ,
106+ dtype : dtype . as_tf_dtype ( ) ,
107+ preferred_dtype : default_dtype . as_tf_dtype ( ) ,
97108 as_ref : input_arg . IsRef ) ;
98109 }
99110 else
@@ -107,9 +118,9 @@ public Operation _apply_op_helper(string op_type_name, string name = "", dynamic
107118
108119 values = ops . internal_convert_to_tensor ( values ,
109120 name : input_name ,
110- dtype : dtype ,
121+ dtype : dtype . as_tf_dtype ( ) ,
111122 as_ref : input_arg . IsRef ,
112- preferred_dtype : default_dtype ) ;
123+ preferred_dtype : default_dtype . as_tf_dtype ( ) ) ;
113124
114125 //if (!String.IsNullOrEmpty(input_arg.TypeAttr))
115126 //attrs[input_arg.TypeAttr] = values.dtype;
0 commit comments