[WIP] one small fix (#207)

* one small fix

Signed-off-by: raver119 <raver119@gmail.com>

* assert added

Signed-off-by: raver119 <raver119@gmail.com>
master
raver119 2020-02-02 19:17:26 +03:00 committed by GitHub
parent 0756e3fe70
commit 81efa5c3b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

View File

@ -1050,21 +1050,33 @@ public abstract class BaseCudaDataBuffer extends BaseDataBuffer implements JCuda
@Override
public void setData(int[] data) {
if (data.length == 0)
return;
set(data, data.length, 0, 0);
}
@Override
public void setData(long[] data) {
if (data.length == 0)
return;
set(data, data.length, 0, 0);
}
@Override
public void setData(float[] data) {
if (data.length == 0)
return;
set(data, data.length, 0, 0);
}
@Override
public void setData(double[] data) {
if (data.length == 0)
return;
set(data, data.length, 0, 0);
}

View File

@ -3804,7 +3804,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
public NDArray(Pointer buffer, byte order, @Cast("Nd4jLong*") @StdVector long[] shape, @Cast("nd4j::DataType") int dtype) { super((Pointer)null); allocate(buffer, order, shape, dtype); }
private native void allocate(Pointer buffer, byte order, @Cast("Nd4jLong*") @StdVector long[] shape, @Cast("nd4j::DataType") int dtype);
/**
* This method returns new array with the same shape & data type
* @return

View File

@ -3807,7 +3807,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
public NDArray(Pointer buffer, byte order, @Cast("Nd4jLong*") @StdVector long[] shape, @Cast("nd4j::DataType") int dtype) { super((Pointer)null); allocate(buffer, order, shape, dtype); }
private native void allocate(Pointer buffer, byte order, @Cast("Nd4jLong*") @StdVector long[] shape, @Cast("nd4j::DataType") int dtype);
/**
* This method returns new array with the same shape & data type
* @return

View File

@ -320,6 +320,12 @@ public class EmptyTests extends BaseNd4jTest {
Nd4j.exec(op);
}
@Test
public void testEmptyConstructor_1() {
val x = Nd4j.create(new double[0]);
assertTrue(x.isEmpty());
}
@Override
public char ordering() {
return 'c';