Return a copied flat java array of current array (row-major). The Tensor dtype must be float32 @return A copy of array content.
()
| 217 | * @return A copy of array content. |
| 218 | */ |
| 219 | public float[] asFloatArray() { |
| 220 | if (dtype.typeCode != TVMType.FLOAT || dtype.bits != 32) { |
| 221 | throw new IllegalArgumentException( |
| 222 | "Cannot set convert to float[] for " + dtype.toString() + " array"); |
| 223 | } |
| 224 | byte[][] units = groupInternalBytes(); |
| 225 | float[] array = new float[units.length]; |
| 226 | for (int i = 0; i < units.length; ++i) { |
| 227 | array[i] = wrapBytes(units[i]).getFloat(); |
| 228 | } |
| 229 | return array; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Return a copied flat java array of current array (row-major). |