@@ -64,48 +64,50 @@ public Tensor(IntPtr handle)
6464#endif
6565 }
6666
67+ unsafe internal Tensor ( Shape shape , TF_DataType dtype )
68+ => _handle = TF_NewTensor ( shape , dtype , null ) ;
69+
6770 internal Tensor ( Array array , Shape ? shape = null )
6871 => InitTensor ( array , shape ) ;
6972
7073 unsafe void InitTensor ( Array array , Shape ? shape = null )
7174 {
7275 shape = shape ?? array . GetShape ( ) ;
7376 var dtype = array . GetType ( ) . GetElementType ( ) . as_tf_dtype ( ) ;
74- var length = ( ulong ) ( array . Length * dtype . get_datatype_size ( ) ) ;
7577
7678 switch ( array )
7779 {
7880 case bool [ ] val :
7981 fixed ( void * addr = & val [ 0 ] )
80- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
82+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
8183 break ;
8284 case int [ ] val :
8385 fixed ( void * addr = & val [ 0 ] )
84- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
86+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
8587 break ;
8688 case int [ , ] val :
8789 fixed ( void * addr = & val [ 0 , 0 ] )
88- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
90+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
8991 break ;
9092 case long [ ] val :
9193 fixed ( void * addr = & val [ 0 ] )
92- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
94+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
9395 break ;
9496 case float [ ] val :
9597 fixed ( void * addr = & val [ 0 ] )
96- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
98+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
9799 break ;
98100 case float [ , ] val :
99101 fixed ( void * addr = & val [ 0 , 0 ] )
100- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
102+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
101103 break ;
102104 case double [ ] val :
103105 fixed ( void * addr = & val [ 0 ] )
104- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
106+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
105107 break ;
106108 case double [ , ] val :
107109 fixed ( void * addr = & val [ 0 , 0 ] )
108- _handle = TF_NewTensor ( shape , dtype , addr , length ) ;
110+ _handle = TF_NewTensor ( shape , dtype , addr ) ;
109111 break ;
110112 default :
111113 throw new NotImplementedException ( "" ) ;
@@ -131,7 +133,7 @@ public Tensor(IntPtr data_ptr, long[] shape, TF_DataType dType, int num_bytes)
131133 }
132134
133135 public unsafe Tensor ( NDArray nd )
134- => _handle = TF_NewTensor ( nd . shape , nd . dtype . as_tf_dtype ( ) , nd . data . ToPointer ( ) , nd . size * nd . dtypesize ) ;
136+ => _handle = TF_NewTensor ( nd . shape , nd . dtype . as_tf_dtype ( ) , nd . data . ToPointer ( ) ) ;
135137
136138 #region scala
137139 public Tensor ( bool value ) => _handle = TF_NewTensor ( value ) ;
0 commit comments