Copy from a native array. The Tensor type must by float64 @param sourceArray the source data
(double[] sourceArray)
| 41 | * @param sourceArray the source data |
| 42 | */ |
| 43 | public void copyFrom(double[] sourceArray) { |
| 44 | checkCopySize(sourceArray.length); |
| 45 | if (dtype.typeCode != TVMType.FLOAT || dtype.bits != 64) { |
| 46 | throw new IllegalArgumentException("Cannot set double[] for " + dtype.toString() + " array"); |
| 47 | } |
| 48 | byte[] nativeArr = new byte[sourceArray.length * dtype.numOfBytes]; |
| 49 | for (int i = 0; i < sourceArray.length; ++i) { |
| 50 | wrapBytes(nativeArr, i * dtype.numOfBytes, dtype.numOfBytes).putDouble(sourceArray[i]); |
| 51 | } |
| 52 | Base.checkCall(Base._LIB.tvmFFIDLTensorCopyFromJArray(nativeArr, this.dltensorHandle)); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Copy from a native array. |