From 5289884ac4df7d4b476f0a8cf04c1de9d61254f8 Mon Sep 17 00:00:00 2001 From: MatthieuTPHR Date: Tue, 25 Jul 2023 16:33:09 +0000 Subject: [PATCH 1/3] Skip dimension of size 1 in contiguous checks. Since PyTorch 1.13 dimension of size 1 have normalised strides in PyTorch which fail here when using DLPack. This was done to conform the torch stride representation and the one from numpy. Unfortunately this means we are stuck with PyTorch 1.12.0 in python models. --- src/pb_tensor.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pb_tensor.cc b/src/pb_tensor.cc index 4011faad..f045df9b 100644 --- a/src/pb_tensor.cc +++ b/src/pb_tensor.cc @@ -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) { From d0c23778d5b9c347b6530ecf909bac2aa26d9ae3 Mon Sep 17 00:00:00 2001 From: MatthieuTPHR Date: Wed, 16 Aug 2023 08:56:59 +0000 Subject: [PATCH 2/3] Conform to pre-commit guidelines --- src/pb_tensor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pb_tensor.cc b/src/pb_tensor.cc index f045df9b..84cd8f3f 100644 --- a/src/pb_tensor.cc +++ b/src/pb_tensor.cc @@ -433,7 +433,7 @@ PbTensor::FromDLPackCapsule( int64_t calculated_stride{1}; bool is_contiguous_c_order = true; for (size_t i = 1; i < dims.size(); i++) { - if (dims[ndim-i] != 1) { + if (dims[ndim - i] != 1) { if (strides[ndim - i] != calculated_stride) { is_contiguous_c_order = false; break; From 8b20985b81da335683a85fdad317c85fa6692838 Mon Sep 17 00:00:00 2001 From: Matthieu Toulemont <75613333+MatthieuToulemont@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:41:01 +0100 Subject: [PATCH 3/3] Update CMakeLists.txt --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93a7ae60..ae9fcd75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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