Commit 0ec7cabe by Pariksheet Pinjari Committed by Tianqi Chen

JVM NDArray fatal exception fix (#1022)

parent 6292204e
...@@ -53,7 +53,7 @@ public class NDArray extends NDArrayBase { ...@@ -53,7 +53,7 @@ public class NDArray extends NDArrayBase {
} }
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
/** /**
...@@ -72,7 +72,7 @@ public class NDArray extends NDArrayBase { ...@@ -72,7 +72,7 @@ public class NDArray extends NDArrayBase {
} }
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
/** /**
...@@ -91,7 +91,7 @@ public class NDArray extends NDArrayBase { ...@@ -91,7 +91,7 @@ public class NDArray extends NDArrayBase {
} }
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
/** /**
...@@ -110,7 +110,7 @@ public class NDArray extends NDArrayBase { ...@@ -110,7 +110,7 @@ public class NDArray extends NDArrayBase {
} }
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
/** /**
...@@ -129,7 +129,7 @@ public class NDArray extends NDArrayBase { ...@@ -129,7 +129,7 @@ public class NDArray extends NDArrayBase {
} }
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
/** /**
...@@ -161,7 +161,7 @@ public class NDArray extends NDArrayBase { ...@@ -161,7 +161,7 @@ public class NDArray extends NDArrayBase {
} }
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(nativeArr, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
private void checkCopySize(int sourceLength) { private void checkCopySize(int sourceLength) {
...@@ -179,7 +179,7 @@ public class NDArray extends NDArrayBase { ...@@ -179,7 +179,7 @@ public class NDArray extends NDArrayBase {
public void copyFromRaw(byte[] sourceArray) { public void copyFromRaw(byte[] sourceArray) {
NDArray tmpArr = empty(shape(), this.dtype); NDArray tmpArr = empty(shape(), this.dtype);
Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(sourceArray, tmpArr.handle, handle)); Base.checkCall(Base._LIB.tvmArrayCopyFromJArray(sourceArray, tmpArr.handle, handle));
Base.checkCall(Base._LIB.tvmArrayFree(tmpArr.handle)); tmpArr.release();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment