Skip to content

Commit

Permalink
update packages for msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
BTNC committed Nov 28, 2016
1 parent b0acdb2 commit f2a545e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cd %TORCH_DISTRO%\pkg\optim && call %LUAROCKS_CMD% make optim-1.0.5-0.rockspec |

if not "%TORCH_SETUP_HAS_CUDA%" == "" if not "%TORCH_VS_TARGET%" == "x86" (
echo %ECHO_PREFIX% Found CUDA on your machine. Installing CUDA packages
cd %TORCH_DISTRO%\extra\cutorch && call %LUAROCKS_CMD% make rocks\cutorch-scm-1.rockspec || goto :FAIL
cd %TORCH_DISTRO%\extra\cutorch && git apply %TORCH_DISTRO%\win-files\patch\cutorch.patch --whitespace=fix & ( call %LUAROCKS_CMD% make rocks\cutorch-scm-1.rockspec || goto :FAIL ) & git apply %TORCH_DISTRO%\win-files\patch\cutorch.patch --reverse --whitespace=fix
cd %TORCH_DISTRO%\extra\cunn && git apply %TORCH_DISTRO%\win-files\patch\cunn.patch --whitespace=fix & ( call %LUAROCKS_CMD% make rocks\cunn-scm-1.rockspec || goto :FAIL ) & git apply %TORCH_DISTRO%\win-files\patch\cunn.patch --reverse --whitespace=fix
)

Expand Down
27 changes: 20 additions & 7 deletions win-files/patch/cunn.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/THCUNN.lua b/THCUNN.lua
index 490cd5c..9924944 100644
index ac05ee0..2daf271 100644
--- a/THCUNN.lua
+++ b/THCUNN.lua
@@ -6,6 +6,9 @@ local THCUNN = {}
Expand All @@ -12,7 +12,7 @@ index 490cd5c..9924944 100644
local THCState_ptr = ffi.typeof('THCState*')

function THCUNN.getState()
@@ -139,7 +142,7 @@ local transform_reals_to_half = function(func_name, real_args, ...)
@@ -140,7 +143,7 @@ local transform_reals_to_half = function(func_name, real_args, ...)
end
for k,v in ipairs(real_args[func_name]) do
-- first argument (THCState) is added implicitly by bind
Expand All @@ -21,8 +21,21 @@ index 490cd5c..9924944 100644
end
return t
end
diff --git a/lib/THCUNN/CMakeLists.txt b/lib/THCUNN/CMakeLists.txt
index d86dfdc..bce4cbd 100644
--- a/lib/THCUNN/CMakeLists.txt
+++ b/lib/THCUNN/CMakeLists.txt
@@ -10,7 +10,7 @@ IF(NOT CUDA_FOUND)
ENDIF()

# Detect CUDA architecture and get best NVCC flags
-IF(NOT COMMAND CUDA_SELECT_NVCC_ARCH_FLAGS)
+IF(NOT COMMAND CUDA_SELECT_NVCC_ARCH_FLAGS OR MSVC)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/select_compute_arch.cmake)
ENDIF()
CUDA_SELECT_NVCC_ARCH_FLAGS(NVCC_FLAGS_EXTRA $ENV{TORCH_CUDA_ARCH_LIST})
diff --git a/test.lua b/test.lua
index 7cb2854..ea214c3 100644
index 15f9990..d39ee92 100644
--- a/test.lua
+++ b/test.lua
@@ -5,6 +5,9 @@ local precision_backward = 1e-2
Expand All @@ -35,7 +48,7 @@ index 7cb2854..ea214c3 100644
--e.g.: th -lcunn -e "nn.testcuda{'Sigmoid_forward'}"

local typenames = {
@@ -348,17 +351,17 @@ function cunntest.Square_transposed()
@@ -362,17 +365,17 @@ function cunntest.Square_transposed()
end

function cunntest.SoftShrink_forward()
Expand All @@ -56,7 +69,7 @@ index 7cb2854..ea214c3 100644
pointwise_transposed(nn.SoftShrink(r), 'SoftShrink', precision_backward)
end

@@ -3377,7 +3380,7 @@ function cunntest.mse()
@@ -3399,7 +3402,7 @@ function cunntest.mse()
local cgin = cmod:backward(cinput,ctarget)

if (typename == 'torch.CudaHalfTensor') then
Expand All @@ -65,7 +78,7 @@ index 7cb2854..ea214c3 100644
end
mytester:assertlt(math.abs(fout-cout), precision_forward_type(0.02, typename),
string.format('error on output with %s', typename))
@@ -3411,7 +3414,7 @@ function cunntest.SmoothL1()
@@ -3433,7 +3436,7 @@ function cunntest.SmoothL1()
local cgin = cmod:backward(cinput,ctarget)

if (typename == 'torch.CudaHalfTensor') then
Expand All @@ -74,7 +87,7 @@ index 7cb2854..ea214c3 100644
end
mytester:assertlt(math.abs(fout-cout), 0.01, string.format('error on output with %s', typename))
local gerr = cgin:double() - fgin:double()
@@ -3976,7 +3979,7 @@ function cunntest.l1cost()
@@ -3998,7 +4001,7 @@ function cunntest.l1cost()
local cgin = cmod:backward(cinput)

if (typename == 'torch.CudaHalfTensor') then
Expand Down
13 changes: 13 additions & 0 deletions win-files/patch/cutorch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/THC/CMakeLists.txt b/lib/THC/CMakeLists.txt
index 08e6fbc..bc3cbfb 100644
--- a/lib/THC/CMakeLists.txt
+++ b/lib/THC/CMakeLists.txt
@@ -87,7 +87,7 @@ IF(APPLE)
ENDIF(APPLE)

# Detect CUDA architecture and get best NVCC flags
-IF(NOT COMMAND CUDA_SELECT_NVCC_ARCH_FLAGS)
+IF(NOT COMMAND CUDA_SELECT_NVCC_ARCH_FLAGS OR MSVC)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/select_compute_arch.cmake)
ENDIF()
LIST(APPEND CUDA_NVCC_FLAGS $ENV{TORCH_NVCC_FLAGS})
13 changes: 13 additions & 0 deletions win-files/patch/torch.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
diff --git a/lib/TH/generic/THTensorLapack.c b/lib/TH/generic/THTensorLapack.c
index fb1e246..fe82cc0 100644
--- a/lib/TH/generic/THTensorLapack.c
+++ b/lib/TH/generic/THTensorLapack.c
@@ -605,7 +605,7 @@ void THTensor_(potrf)(THTensor *ra_, THTensor *a, const char *uplo)
THLapack_(potrf)(uplo[0], n, THTensor_(data)(ra__), lda, &info);
THLapackCheckWithCleanup("Lapack Error in %s : the leading minor of order %d is not positive definite",
THCleanup(THTensor_(free)(ra__);),
- "potrf", info);
+ "potrf", info, "");

THTensor_(clearUpLoTriangle)(ra__, uplo);
THTensor_(freeCopyTo)(ra__, ra_);
diff --git a/lib/luaT/luaT.c b/lib/luaT/luaT.c
index 95166ed..2dc307a 100644
--- a/lib/luaT/luaT.c
Expand Down

0 comments on commit f2a545e

Please sign in to comment.