Return a copied flat java array of current array (row-major). The Tensor dtype must be int16 @return A copy of array content.
()
| 271 | * @return A copy of array content. |
| 272 | */ |
| 273 | public short[] asShortArray() { |
| 274 | if (dtype.typeCode != TVMType.INT || dtype.bits != 16) { |
| 275 | throw new IllegalArgumentException( |
| 276 | "Cannot set convert to short[] for " + dtype.toString() + " array"); |
| 277 | } |
| 278 | byte[][] units = groupInternalBytes(); |
| 279 | short[] array = new short[units.length]; |
| 280 | for (int i = 0; i < units.length; ++i) { |
| 281 | array[i] = wrapBytes(units[i]).getShort(); |
| 282 | } |
| 283 | return array; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Return a copied flat java array of current array (row-major). |