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

[ci] Fixes pytorch jni build for 1.13.1 #3184

Merged
merged 1 commit into from
May 13, 2024
Merged
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
6 changes: 5 additions & 1 deletion engines/pytorch/pytorch-native/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [[ ! -d "libtorch" ]]; then
curl -s https://download.pytorch.org/libtorch/${FLAVOR}/libtorch${CXX11ABI}-shared-with-deps-${VERSION}%2B${FLAVOR}.zip | jar xv >/dev/null
fi
elif [[ $PLATFORM == 'darwin' ]]; then
if [[ "$VERSION" =~ ^(2.2.)* ]]; then
if [[ "$VERSION" =~ ^(2.[2-9].*)$ ]]; then
if [[ $ARCH == 'aarch64' ]]; then
curl -s https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-${VERSION}.zip | jar xv >/dev/null
else
Expand All @@ -53,6 +53,10 @@ if [[ ! -d "libtorch" ]]; then
fi
fi

if [[ "$VERSION" == "1.13.1" ]]; then
PT_VERSION=V1_13_X
fi

if [[ "$FLAVOR" = cu* ]]; then
USE_CUDA=1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#include <torch/script.h>

#include <iostream>
#ifdef V1_13_X
#include <c10/util/variant.h>
#else
#include <variant>
#endif

#include "djl_pytorch_jni_log.h"

Expand All @@ -30,10 +34,16 @@ namespace utils {

#if !defined(__ANDROID__)
// for image interpolation
#ifdef V1_13_X
typedef torch::variant<torch::enumtype::kNearest, torch::enumtype::kLinear, torch::enumtype::kBilinear,
torch::enumtype::kBicubic, torch::enumtype::kTrilinear, torch::enumtype::kArea, torch::enumtype::kNearestExact>
mode_t;
#else
typedef std::variant<torch::enumtype::kNearest, torch::enumtype::kLinear, torch::enumtype::kBilinear,
torch::enumtype::kBicubic, torch::enumtype::kTrilinear, torch::enumtype::kArea, torch::enumtype::kNearestExact>
mode_t;
#endif
#endif

inline jint GetDTypeFromScalarType(const torch::ScalarType& type) {
if (torch::kFloat32 == type) {
Expand Down
Loading