Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix torch tensor dlpack contiguous issue when dim size is 1 server issue num 6102 #393

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ FetchContent_MakeAvailable(dlpack)
#
ExternalProject_Add(
boostorg
URL https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz
# URL https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz
URL https://archives.boost.io/release/1.79.0/source/boost_1_79_0.tar.gz
URL_HASH SHA256=273f1be93238a068aba4f9735a4a2b003019af067b9c183ed227780b8f36062c
PREFIX "boost-src"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy_directory
Expand Down
12 changes: 7 additions & 5 deletions src/pb_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,14 @@ PbTensor::FromDLPackCapsule(
int64_t calculated_stride{1};
bool is_contiguous_c_order = true;
for (size_t i = 1; i < dims.size(); i++) {
if (strides[ndim - i] != calculated_stride) {
is_contiguous_c_order = false;
break;
}
if (dims[ndim - i] != 1) {
if (strides[ndim - i] != calculated_stride) {
is_contiguous_c_order = false;
break;
}

calculated_stride *= dims[ndim - i];
calculated_stride *= dims[ndim - i];
}
}

if (!is_contiguous_c_order) {
Expand Down