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

Updates libtorch #9

Merged
merged 19 commits into from
Oct 20, 2022
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
3 changes: 2 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2
if: ${{ !contains(matrix.config.os, 'm1') }}
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
Expand All @@ -52,7 +53,7 @@ jobs:
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: 'latest'
cmake-version: '3.18'

- if: ${{matrix.config.cuda != ''}}
uses: Jimver/cuda-toolkit@v0.2.7
Expand Down
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: torchvisionlib
Title: Additional Operators for Image Models
Version: 0.2.0.9000
Version: 0.2.0.9001
Authors@R: c(
person("Daniel", "Falbel", , "daniel@rstudio.com", role = c("aut", "cre")),
person(family = "RStudio", role = c("cph"))
Expand All @@ -20,7 +20,10 @@ Imports:
Rcpp,
torch (>= 0.8.0),
rlang,
glue
glue,
withr
Suggests:
testthat (>= 3.0.0)
Remotes:
mlverse/torch
Config/testthat/edition: 3
11 changes: 9 additions & 2 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ NULL
if (interactive())
warning("torchvisionlib is not installed. Run `intall_torchvisionlib()` before using the package.")
} else {
dyn.load(lib_path("torchvision"), local = FALSE)
dyn.load(lib_path("torchvisionlib"), local = FALSE)
if (grepl("mingw", R.version[["os"]])) {
libpath <- lib_path("torchvisionlib")
withr::with_dir(dirname(libpath), {
dyn.load(basename(libpath), local = FALSE)
})
} else {
dyn.load(lib_path("torchvision"), local = FALSE)
dyn.load(lib_path("torchvisionlib"), local = FALSE)
}

# when using devtools::load_all() the library might be available in
# `lib/pkg/src`
Expand Down
7 changes: 4 additions & 3 deletions csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ if(WIN32)
GIT_TAG v1.6.37
DEPENDS zlib
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libpng"
CMAKE_ARGS ${COMMON_CMAKE_ARGS}

CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DCMAKE_IGNORE_PATH=C:/rtools40/ucrt64/include
)
ExternalProject_Add(libjpeg
GIT_REPOSITORY https://github.com/libjpeg-turbo/libjpeg-turbo
Expand All @@ -59,6 +58,8 @@ set(TorchVision_DESTDIR ${CMAKE_CURRENT_BINARY_DIR}/lib/)
set(TORCHVISION_CMAKE_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_PREFIX=${TorchVision_DESTDIR})
if(WIN32)
set(TORCHVISION_CMAKE_ARGS ${TORCHVISION_CMAKE_ARGS} -DZLIB_LIBRARY=${ZLIB_LIBRARY} -DPNG_LIBRARY=${PNG_LIBRARY} -DPNG_INCLUDE_DIR=${PNG_INCLUDE_DIR} -DJPEG_LIBRARY=${JPEG_LIBRARY})
elseif(APPLE)
set(TORCHVISION_CMAKE_ARGS ${TORCHVISION_CMAKE_ARGS} -DCMAKE_FIND_FRAMEWORK=LAST)
endif()

if (WIN32)
Expand All @@ -69,7 +70,7 @@ endif()

ExternalProject_Add(TorchVision-project
GIT_REPOSITORY https://github.com/pytorch/vision
GIT_TAG release/0.12
GIT_TAG v0.13.1
DEPENDS ${TORCHVISION_DEPENDS}
CMAKE_ARGS ${TORCHVISION_CMAKE_ARGS}
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libtorchvision"
Expand Down