Skip to content

Commit

Permalink
DataType check
Browse files Browse the repository at this point in the history
  • Loading branch information
KexinFeng committed May 11, 2022
1 parent ea84044 commit 706ec85
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,18 @@ public static void set(PtNDArray self, ByteBuffer data) {
}

public static PtNDArray gather(PtNDArray ndArray, PtNDArray index, long dim) {
if (index.getDataType() != DataType.INT64) {
index = index.toType(DataType.INT64, true);
}
return new PtNDArray(
ndArray.getManager(),
PyTorchLibrary.LIB.torchGather(ndArray.getHandle(), index.getHandle(), dim, false));
}

public static PtNDArray take(PtNDArray ndArray, PtNDArray index) {
if (index.getDataType() != DataType.INT64) {
index = index.toType(DataType.INT64, true);
}
return new PtNDArray(
ndArray.getManager(),
PyTorchLibrary.LIB.torchTake(ndArray.getHandle(), index.getHandle()));
Expand Down

0 comments on commit 706ec85

Please sign in to comment.