Skip to content

Commit

Permalink
rockspec, cmake, test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-leonard committed Oct 14, 2014
1 parent ee27d2a commit 19e1f48
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.6)
IF(LUAROCKS_PREFIX)
MESSAGE(STATUS "Installing Torch through Luarocks")
STRING(REGEX REPLACE "(.*)lib/luarocks/rocks.*" "\\1" CMAKE_INSTALL_PREFIX "${LUAROCKS_PREFIX}")
MESSAGE(STATUS "Prefix inferred from Luarocks: ${CMAKE_INSTALL_PREFIX}")
ENDIF()
FIND_PACKAGE(Torch REQUIRED)

FILE(GLOB luasrc *.lua)
SET(luasrc ${luasrc} test/test.lua)
ADD_TORCH_PACKAGE(torchx "" "${luasrc}" "Torch extensions")
28 changes: 27 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
Copyright 2014 Nicholas Léonard
Copyright (c) 2014, Nikopia (Nicholas Léonard)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notices, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the Nikopia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 changes: 17 additions & 0 deletions test/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local torchxtest = {}
local precision_forward = 1e-6
local precision_backward = 1e-6
local nloop = 50

--e.g. usage: th -ltorchx -e "torchx.test{'SoftMaxTree','BlockSparse'}"

function torchx.test(tests)
local oldtype = torch.getdefaulttensortype()
torch.setdefaulttensortype('torch.FloatTensor')
math.randomseed(os.time())
jac = nn.Jacobian
mytester = torch.Tester()
mytester:add(torchxtest)
mytester:run(tests)
torch.setdefaulttensortype(oldtype)
end
30 changes: 30 additions & 0 deletions torchx-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package = "torchx"
version = "scm-1"

source = {
url = "git://github.com/nicholas-leonard/torchx",
tag = "master"
}

description = {
summary = "torch extensions",
detailed = [[
Experimental torch extensions
]],
homepage = "https://github.com/nicholas-leonard/torchx/blob/master/README.md"
}

dependencies = {
"torch >= 7.0"
}

build = {
type = "command",
build_command = [[
cmake -E make_directory build;
cd build;
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)";
$(MAKE)
]],
install_command = "cd build && $(MAKE) install"
}

0 comments on commit 19e1f48

Please sign in to comment.