@@ -93,7 +93,7 @@ private static NDArray buildUByte(SharedMemoryArray tensor, NDManager manager)
93
93
if (!tensor .isNumpyFormat ())
94
94
throw new IllegalArgumentException ("Shared memory arrays must be saved in numpy format." );
95
95
ByteBuffer buff = tensor .getDataBufferNoHeader ();
96
- NDArray ndarray = manager .create (buff . array () , new Shape (ogShape ));
96
+ NDArray ndarray = manager .create (buff , new Shape (ogShape ));
97
97
return ndarray ;
98
98
}
99
99
@@ -108,9 +108,7 @@ private static NDArray buildInt(SharedMemoryArray tensor, NDManager manager)
108
108
throw new IllegalArgumentException ("Shared memory arrays must be saved in numpy format." );
109
109
ByteBuffer buff = tensor .getDataBufferNoHeader ();
110
110
IntBuffer intBuff = buff .asIntBuffer ();
111
- int [] intArray = new int [intBuff .capacity ()];
112
- intBuff .get (intArray );
113
- NDArray ndarray = manager .create (intBuff .array (), new Shape (ogShape ));
111
+ NDArray ndarray = manager .create (intBuff , new Shape (ogShape ));
114
112
return ndarray ;
115
113
}
116
114
@@ -125,9 +123,7 @@ private static NDArray buildLong(SharedMemoryArray tensor, NDManager manager)
125
123
throw new IllegalArgumentException ("Shared memory arrays must be saved in numpy format." );
126
124
ByteBuffer buff = tensor .getDataBufferNoHeader ();
127
125
LongBuffer longBuff = buff .asLongBuffer ();
128
- long [] longArray = new long [longBuff .capacity ()];
129
- longBuff .get (longArray );
130
- NDArray ndarray = manager .create (longBuff .array (), new Shape (ogShape ));
126
+ NDArray ndarray = manager .create (longBuff , new Shape (ogShape ));
131
127
return ndarray ;
132
128
}
133
129
@@ -142,8 +138,6 @@ private static NDArray buildFloat(SharedMemoryArray tensor, NDManager manager)
142
138
throw new IllegalArgumentException ("Shared memory arrays must be saved in numpy format." );
143
139
ByteBuffer buff = tensor .getDataBufferNoHeader ();
144
140
FloatBuffer floatBuff = buff .asFloatBuffer ();
145
- //float[] floatArray = new float[floatBuff.capacity()];
146
- //floatBuff.get(floatArray);
147
141
NDArray ndarray = manager .create (floatBuff , new Shape (ogShape ));
148
142
return ndarray ;
149
143
}
@@ -159,9 +153,7 @@ private static NDArray buildDouble(SharedMemoryArray tensor, NDManager manager)
159
153
throw new IllegalArgumentException ("Shared memory arrays must be saved in numpy format." );
160
154
ByteBuffer buff = tensor .getDataBufferNoHeader ();
161
155
DoubleBuffer doubleBuff = buff .asDoubleBuffer ();
162
- double [] doubleArray = new double [doubleBuff .capacity ()];
163
- doubleBuff .get (doubleArray );
164
- NDArray ndarray = manager .create (doubleBuff .array (), new Shape (ogShape ));
156
+ NDArray ndarray = manager .create (doubleBuff , new Shape (ogShape ));
165
157
return ndarray ;
166
158
}
167
159
}
0 commit comments