@@ -21,11 +21,7 @@ public Action<int> Constant
2121 public Action < int > Constant2x3
2222 => ( iterate ) =>
2323 {
24- var nd = np . array ( new byte [ , ]
25- {
26- { 1 , 2 , 3 } ,
27- { 4 , 5 , 6 }
28- } ) ;
24+ var nd = np . arange ( 1000 ) . reshape ( 10 , 100 ) ;
2925 for ( int i = 0 ; i < iterate ; i ++ )
3026 {
3127 var tensor = tf . constant ( nd ) ;
@@ -38,7 +34,8 @@ public Action<int> Variable
3834 {
3935 for ( int i = 0 ; i < iterate ; i ++ )
4036 {
41- var tensor = tf . Variable ( 3112.0f ) ;
37+ var nd = np . arange ( 128 * 128 * 3 ) . reshape ( 128 , 128 , 3 ) ;
38+ var variable = tf . Variable ( nd ) ;
4239 }
4340 } ;
4441
@@ -66,5 +63,51 @@ public Action<int> Gradient
6663 var grad = tape . gradient ( loss , w ) ;
6764 }
6865 } ;
66+
67+ public Action < int > Conv2dWithVariable
68+ => ( iterate ) =>
69+ {
70+ for ( int i = 0 ; i < iterate ; i ++ )
71+ {
72+ var input = array_ops . zeros ( ( 10 , 32 , 32 , 3 ) , dtypes . float32 ) ;
73+ var filter = tf . Variable ( array_ops . zeros ( ( 3 , 3 , 3 , 32 ) , dtypes . float32 ) ) ;
74+ var strides = new [ ] { 1 , 1 , 1 , 1 } ;
75+ var dilations = new [ ] { 1 , 1 , 1 , 1 } ;
76+
77+ var results = tf . Runner . TFE_FastPathExecute ( tf . Context , tf . Context . DeviceName ,
78+ "Conv2D" , null ,
79+ null ,
80+ input , filter ,
81+ "strides" , strides ,
82+ "use_cudnn_on_gpu" , true ,
83+ "padding" , "VALID" ,
84+ "explicit_paddings" , new int [ 0 ] ,
85+ "data_format" , "NHWC" ,
86+ "dilations" , dilations ) ;
87+ }
88+ } ;
89+
90+ public Action < int > Conv2dWithTensor
91+ => ( iterate ) =>
92+ {
93+ for ( int i = 0 ; i < iterate ; i ++ )
94+ {
95+ var input = array_ops . zeros ( ( 10 , 32 , 32 , 3 ) , dtypes . float32 ) ;
96+ var filter = array_ops . zeros ( ( 3 , 3 , 3 , 32 ) , dtypes . float32 ) ;
97+ var strides = new [ ] { 1 , 1 , 1 , 1 } ;
98+ var dilations = new [ ] { 1 , 1 , 1 , 1 } ;
99+
100+ var results = tf . Runner . TFE_FastPathExecute ( tf . Context , tf . Context . DeviceName ,
101+ "Conv2D" , null ,
102+ null ,
103+ input , filter ,
104+ "strides" , strides ,
105+ "use_cudnn_on_gpu" , true ,
106+ "padding" , "VALID" ,
107+ "explicit_paddings" , new int [ 0 ] ,
108+ "data_format" , "NHWC" ,
109+ "dilations" , dilations ) ;
110+ }
111+ } ;
69112 }
70113}
0 commit comments