diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile | 71 | ||||
-rwxr-xr-x | build_luajit.sh | 5 | ||||
m--------- | luarocks | 0 | ||||
-rwxr-xr-x | nerv | 2 | ||||
-rw-r--r-- | nerv/.gitignore | 1 | ||||
-rw-r--r-- | nerv/Makefile | 60 | ||||
-rw-r--r-- | nerv/common.c (renamed from common.c) | 0 | ||||
-rw-r--r-- | nerv/common.h (renamed from common.h) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv.md (renamed from doc/nerv.md) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv_class.md (renamed from doc/nerv_class.md) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv_io.md (renamed from doc/nerv_io.md) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv_layer.md (renamed from doc/nerv_layer.md) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv_matrix.md (renamed from doc/nerv_matrix.md) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv_nn.md (renamed from doc/nerv_nn.md) | 0 | ||||
-rw-r--r-- | nerv/doc/nerv_param.md (renamed from doc/nerv_param.md) | 0 | ||||
-rw-r--r-- | nerv/examples/asr_trainer.lua (renamed from examples/asr_trainer.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/chunk_file_example.lua (renamed from examples/chunk_file_example.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/cumatrix_example.lua (renamed from examples/cumatrix_example.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/cumatrix_from_mmatrix.lua (renamed from examples/cumatrix_from_mmatrix.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/mmatrix_example.lua (renamed from examples/mmatrix_example.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/oop_example.c (renamed from examples/oop_example.c) | 0 | ||||
-rw-r--r-- | nerv/examples/oop_example.lua (renamed from examples/oop_example.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/swb_baseline.lua (renamed from examples/swb_baseline.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/test_dnn_layers.lua (renamed from examples/test_dnn_layers.lua) | 0 | ||||
-rw-r--r-- | nerv/examples/test_nn_lib.lua (renamed from examples/test_nn_lib.lua) | 0 | ||||
-rw-r--r-- | nerv/init.lua (renamed from nerv.lua) | 22 | ||||
-rw-r--r-- | nerv/io/chunk_file.c (renamed from io/chunk_file.c) | 0 | ||||
-rw-r--r-- | nerv/io/chunk_file.h (renamed from io/chunk_file.h) | 0 | ||||
-rw-r--r-- | nerv/io/init.c (renamed from io/init.c) | 0 | ||||
-rw-r--r-- | nerv/io/init.lua (renamed from io/init.lua) | 2 | ||||
-rw-r--r-- | nerv/io/sgd_buffer.lua (renamed from io/sgd_buffer.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/affine.lua (renamed from layer/affine.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/bias.lua (renamed from layer/bias.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/combiner.lua (renamed from layer/combiner.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/init.lua (renamed from layer/init.lua) | 14 | ||||
-rw-r--r-- | nerv/layer/mse.lua (renamed from layer/mse.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/sigmoid.lua (renamed from layer/sigmoid.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/softmax_ce.lua (renamed from layer/softmax_ce.lua) | 0 | ||||
-rw-r--r-- | nerv/layer/window.lua (renamed from layer/window.lua) | 0 | ||||
-rw-r--r-- | nerv/luaT/README.md (renamed from luaT/README.md) | 0 | ||||
-rw-r--r-- | nerv/luaT/luaT.c (renamed from luaT/luaT.c) | 0 | ||||
-rw-r--r-- | nerv/luaT/luaT.h (renamed from luaT/luaT.h) | 0 | ||||
-rw-r--r-- | nerv/matrix/cuda_helper.h (renamed from matrix/cuda_helper.h) | 0 | ||||
-rw-r--r-- | nerv/matrix/cukernel.cu (renamed from matrix/cukernel.cu) | 0 | ||||
-rw-r--r-- | nerv/matrix/cukernel.h (renamed from matrix/cukernel.h) | 0 | ||||
-rw-r--r-- | nerv/matrix/cumatrix.c (renamed from matrix/cumatrix.c) | 0 | ||||
-rw-r--r-- | nerv/matrix/generic/cukernel.cu (renamed from matrix/generic/cukernel.cu) | 0 | ||||
-rw-r--r-- | nerv/matrix/generic/cumatrix.c (renamed from matrix/generic/cumatrix.c) | 0 | ||||
-rw-r--r-- | nerv/matrix/generic/elem_type.h (renamed from matrix/generic/elem_type.h) | 0 | ||||
-rw-r--r-- | nerv/matrix/generic/matrix.c (renamed from matrix/generic/matrix.c) | 0 | ||||
-rw-r--r-- | nerv/matrix/generic/matrix.h (renamed from matrix/generic/matrix.h) | 0 | ||||
-rw-r--r-- | nerv/matrix/generic/mmatrix.c (renamed from matrix/generic/mmatrix.c) | 0 | ||||
-rw-r--r-- | nerv/matrix/init.c (renamed from matrix/init.c) | 0 | ||||
-rw-r--r-- | nerv/matrix/init.lua (renamed from matrix/init.lua) | 0 | ||||
-rw-r--r-- | nerv/matrix/mmatrix.c (renamed from matrix/mmatrix.c) | 0 | ||||
-rw-r--r-- | nerv/nerv | 13 | ||||
-rw-r--r-- | nerv/nerv-scm-1.rockspec | 38 | ||||
-rw-r--r-- | nerv/nerv.c (renamed from nerv.c) | 0 | ||||
-rw-r--r-- | nerv/nn/init.lua | 3 | ||||
-rw-r--r-- | nerv/nn/layer_dag.lua (renamed from nn/layer_dag.lua) | 0 | ||||
-rw-r--r-- | nerv/nn/layer_repo.lua (renamed from nn/layer_repo.lua) | 0 | ||||
-rw-r--r-- | nerv/nn/param_repo.lua (renamed from nn/param_repo.lua) | 0 | ||||
-rw-r--r-- | nn/init.lua | 3 | ||||
-rw-r--r-- | pl/compat.lua | 137 | ||||
-rw-r--r-- | pl/utils.lua | 476 | ||||
m--------- | speech | 0 | ||||
-rwxr-xr-x | tools/build_luajit.sh | 4 | ||||
-rwxr-xr-x | tools/build_luarocks.sh | 4 |
70 files changed, 162 insertions, 698 deletions
@@ -1,4 +1,4 @@ *.o -build/ +install/ *.swp *.swo diff --git a/.gitmodules b/.gitmodules index 2bb1788..1432de9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "speech"] path = speech url = https://github.com/Determinant/nerv-speech.git +[submodule "luarocks"] + path = luarocks + url = https://github.com/keplerproject/luarocks.git @@ -1,63 +1,10 @@ -.PHONY: all clean luajit -BUILD_DIR := $(CURDIR)/build -OBJS := nerv.o luaT.o common.o \ - matrix/mmatrix.o matrix/cumatrix.o matrix/init.o matrix/cukernel.o \ - io/init.o io/chunk_file.o \ - examples/oop_example.o -LIBS := libnerv.so -LUA_LIBS := matrix/init.lua io/init.lua nerv.lua \ - pl/utils.lua pl/compat.lua \ - layer/init.lua layer/affine.lua layer/sigmoid.lua layer/softmax_ce.lua \ - layer/window.lua layer/bias.lua layer/combiner.lua layer/mse.lua \ - nn/init.lua nn/layer_repo.lua nn/param_repo.lua nn/layer_dag.lua \ - io/sgd_buffer.lua -INCLUDE := -I build/luajit-2.0/include/luajit-2.0/ -DLUA_USE_APICHECK -CUDA_BASE := /usr/local/cuda-6.5 -#CUDA_BASE := /usr/local/cuda-5.0 -CUDA_INCLUDE := -I $(CUDA_BASE)/include/ -INCLUDE += $(CUDA_INCLUDE) -LDFLAGS := -L$(CUDA_BASE)/lib64/ -Wl,-rpath=$(CUDA_BASE)/lib64/ -lcudart -lcublas -CFLAGS := -Wall -Wextra -O2 -OBJ_DIR := $(BUILD_DIR)/objs -LUA_DIR := $(BUILD_DIR)/lua -LIB_DIR := $(BUILD_DIR)/lib -SUBDIR := matrix io layer examples pl nn -NVCC := $(CUDA_BASE)/bin/nvcc -NVCC_FLAGS := -Xcompiler -fPIC,-Wall,-Wextra - -OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS)) -OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR)) -LUA_SUBDIR := $(addprefix $(LUA_DIR)/,$(SUBDIR)) -LIBS := $(addprefix $(BUILD_DIR)/lib/,$(LIBS)) -LUA_LIBS := $(addprefix $(LUA_DIR)/,$(LUA_LIBS)) - -all: luajit $(OBJ_DIR) $(LIB_DIR) $(OBJ_SUBDIR) $(LIBS) $(LUA_DIR) $(LUA_SUBDIR) $(LUA_LIBS) +.PHONY: all clean install luajit luarocks nerv +SHELL := /bin/bash +PREFIX := $(CURDIR)/install/ +all: luajit luarocks luajit: - ./build_luajit.sh -$(OBJ_DIR) $(LIB_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR): - -mkdir -p $@ -$(OBJ_DIR)/%.o: %.c $(patsubst /%.o,/%.c,$@) - gcc -c -o $@ $< $(INCLUDE) -fPIC $(CFLAGS) -$(OBJ_DIR)/matrix/cukernel.o: matrix/cukernel.cu - $(NVCC) -c -o $@ $< $(INCLUDE) $(NVCC_FLAGS) -$(LUA_DIR)/%.lua: %.lua - cp $< $@ -$(OBJ_DIR)/luaT.o: - gcc -c -o $@ luaT/luaT.c $(INCLUDE) -fPIC -$(LIBS): $(OBJS) - gcc -shared -o $@ $(OBJS) $(LDFLAGS) - -$(OBJ_DIR)/matrix/cumatrix.o: matrix/generic/cumatrix.c matrix/generic/matrix.c matrix/generic/cukernel.cu -$(OBJ_DIR)/matrix/mmatrix.o: matrix/generic/mmatrix.c matrix/generic/matrix.c -$(OBJ_DIR)/matrix/cukernel.o: matrix/generic/cukernel.cu - -.PHONY: speech - -speech: - -mkdir -p build/objs/speech/tnet_io - $(MAKE) -C speech/ BUILD_DIR=$(BUILD_DIR) LIB_DIR=$(LIB_DIR) OBJ_DIR=$(CURDIR)/build/objs/speech/ LUA_DIR=$(LUA_DIR) - -clean: - -rm -rf $(OBJ_DIR) - -rm -rf $(LUA_DIR) - -rm -rf $(LIB_DIR) + PREFIX=$(PREFIX) ./tools/build_luajit.sh +luarocks: + PREFIX=$(PREFIX) ./tools/build_luarocks.sh +install: + cd nerv; $(PREFIX)/bin/luarocks make diff --git a/build_luajit.sh b/build_luajit.sh deleted file mode 100755 index bb23b5f..0000000 --- a/build_luajit.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -PREFIX="${PWD}/build" -LUAJIT_SRC='luajit-2.0/' -LUAJIT_PREFIX="${PREFIX}/luajit-2.0" -[[ -d $LUAJIT_PREFIX ]] || (cd "$LUAJIT_SRC"; make && make PREFIX="$LUAJIT_PREFIX" install) diff --git a/luarocks b/luarocks new file mode 160000 +Subproject a0315b7bc2432ea517bb90ce39df0cc8b1cd2f6 @@ -1,2 +0,0 @@ -#!/bin/bash -exec 'build/luajit-2.0/bin/luajit' -e "package.cpath=\"${PWD}/build/lib/?.so\"" -e "package.path=\"${PWD}/build/lua/?/init.lua;${PWD}/build/lua/?.lua;${PWD}/?.lua\"" -e "require 'nerv'" "$@" diff --git a/nerv/.gitignore b/nerv/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/nerv/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/nerv/Makefile b/nerv/Makefile new file mode 100644 index 0000000..b69a63e --- /dev/null +++ b/nerv/Makefile @@ -0,0 +1,60 @@ +.PHONY: build install clean +SHELL := /bin/bash +BUILD_DIR := $(CURDIR)/build +OBJS := nerv.o luaT.o common.o \ + matrix/mmatrix.o matrix/cumatrix.o matrix/init.o matrix/cukernel.o \ + io/init.o io/chunk_file.o \ + examples/oop_example.o +LIBS := libnerv.so +LUA_LIBS := matrix/init.lua io/init.lua init.lua \ + layer/init.lua layer/affine.lua layer/sigmoid.lua layer/softmax_ce.lua \ + layer/window.lua layer/bias.lua layer/combiner.lua layer/mse.lua \ + nn/init.lua nn/layer_repo.lua nn/param_repo.lua nn/layer_dag.lua \ + io/sgd_buffer.lua +INCLUDE := -I $(LUA_INCDIR) -DLUA_USE_APICHECK +CUDA_BASE := /usr/local/cuda-6.5 +#CUDA_BASE := /usr/local/cuda-5.0 +CUDA_INCLUDE := -I $(CUDA_BASE)/include/ +INCLUDE += $(CUDA_INCLUDE) +LDFLAGS := -L$(CUDA_BASE)/lib64/ -Wl,-rpath=$(CUDA_BASE)/lib64/ -lcudart -lcublas +CFLAGS := -Wall -Wextra -O2 +OBJ_DIR := $(BUILD_DIR)/objs +SUBDIR := matrix io layer examples nn +NVCC := $(CUDA_BASE)/bin/nvcc +NVCC_FLAGS := -Xcompiler -fPIC,-Wall,-Wextra + +LUA_DIR = $(INST_LUADIR)/nerv +OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS)) +OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR)) +LUA_SUBDIR := $(addprefix $(LUA_DIR)/,$(SUBDIR)) +LIBS := $(addprefix $(INST_LIBDIR)/,$(LIBS)) +LUA_LIBS := $(addprefix $(LUA_DIR)/,$(LUA_LIBS)) + +build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS) +$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR): + -mkdir -p $@ +$(OBJ_DIR)/%.o: %.c $(patsubst /%.o,/%.c,$@) + gcc -c -o $@ $< $(INCLUDE) -fPIC $(CFLAGS) +$(OBJ_DIR)/matrix/cukernel.o: matrix/cukernel.cu + $(NVCC) -c -o $@ $< $(INCLUDE) $(NVCC_FLAGS) +$(LUA_DIR)/%.lua: %.lua + cp $< $@ +$(OBJ_DIR)/luaT.o: + gcc -c -o $@ luaT/luaT.c $(INCLUDE) -fPIC +$(LIBS): $(OBJS) + gcc -shared -o $@ $(OBJS) $(LDFLAGS) + +$(OBJ_DIR)/matrix/cumatrix.o: matrix/generic/cumatrix.c matrix/generic/matrix.c matrix/generic/cukernel.cu +$(OBJ_DIR)/matrix/mmatrix.o: matrix/generic/mmatrix.c matrix/generic/matrix.c +$(OBJ_DIR)/matrix/cukernel.o: matrix/generic/cukernel.cu + +.PHONY: speech + +speech: + -mkdir -p build/objs/speech/tnet_io + $(MAKE) -C speech/ BUILD_DIR=$(BUILD_DIR) LIB_DIR=$(LIB_DIR) OBJ_DIR=$(CURDIR)/build/objs/speech/ LUA_DIR=$(LUA_DIR) + +clean: + -rm -rf $(OBJ_DIR) + +install: $(LIBS) $(LUA_DIR) $(LUA_SUBDIR) $(LUA_LIBS) diff --git a/doc/nerv.md b/nerv/doc/nerv.md index 28411f5..28411f5 100644 --- a/doc/nerv.md +++ b/nerv/doc/nerv.md diff --git a/doc/nerv_class.md b/nerv/doc/nerv_class.md index 99f63e7..99f63e7 100644 --- a/doc/nerv_class.md +++ b/nerv/doc/nerv_class.md diff --git a/doc/nerv_io.md b/nerv/doc/nerv_io.md index 07589df..07589df 100644 --- a/doc/nerv_io.md +++ b/nerv/doc/nerv_io.md diff --git a/doc/nerv_layer.md b/nerv/doc/nerv_layer.md index de2fb12..de2fb12 100644 --- a/doc/nerv_layer.md +++ b/nerv/doc/nerv_layer.md diff --git a/doc/nerv_matrix.md b/nerv/doc/nerv_matrix.md index 22971d2..22971d2 100644 --- a/doc/nerv_matrix.md +++ b/nerv/doc/nerv_matrix.md diff --git a/doc/nerv_nn.md b/nerv/doc/nerv_nn.md index c57447d..c57447d 100644 --- a/doc/nerv_nn.md +++ b/nerv/doc/nerv_nn.md diff --git a/doc/nerv_param.md b/nerv/doc/nerv_param.md index 167cb11..167cb11 100644 --- a/doc/nerv_param.md +++ b/nerv/doc/nerv_param.md diff --git a/examples/asr_trainer.lua b/nerv/examples/asr_trainer.lua index a5727be..a5727be 100644 --- a/examples/asr_trainer.lua +++ b/nerv/examples/asr_trainer.lua diff --git a/examples/chunk_file_example.lua b/nerv/examples/chunk_file_example.lua index 5961c98..5961c98 100644 --- a/examples/chunk_file_example.lua +++ b/nerv/examples/chunk_file_example.lua diff --git a/examples/cumatrix_example.lua b/nerv/examples/cumatrix_example.lua index 544fc7f..544fc7f 100644 --- a/examples/cumatrix_example.lua +++ b/nerv/examples/cumatrix_example.lua diff --git a/examples/cumatrix_from_mmatrix.lua b/nerv/examples/cumatrix_from_mmatrix.lua index 2309e14..2309e14 100644 --- a/examples/cumatrix_from_mmatrix.lua +++ b/nerv/examples/cumatrix_from_mmatrix.lua diff --git a/examples/mmatrix_example.lua b/nerv/examples/mmatrix_example.lua index 8ddfe84..8ddfe84 100644 --- a/examples/mmatrix_example.lua +++ b/nerv/examples/mmatrix_example.lua diff --git a/examples/oop_example.c b/nerv/examples/oop_example.c index 59dfc5a..59dfc5a 100644 --- a/examples/oop_example.c +++ b/nerv/examples/oop_example.c diff --git a/examples/oop_example.lua b/nerv/examples/oop_example.lua index b753288..b753288 100644 --- a/examples/oop_example.lua +++ b/nerv/examples/oop_example.lua diff --git a/examples/swb_baseline.lua b/nerv/examples/swb_baseline.lua index 8b7e01a..8b7e01a 100644 --- a/examples/swb_baseline.lua +++ b/nerv/examples/swb_baseline.lua diff --git a/examples/test_dnn_layers.lua b/nerv/examples/test_dnn_layers.lua index 64c0dec..64c0dec 100644 --- a/examples/test_dnn_layers.lua +++ b/nerv/examples/test_dnn_layers.lua diff --git a/examples/test_nn_lib.lua b/nerv/examples/test_nn_lib.lua index 5444810..5444810 100644 --- a/examples/test_nn_lib.lua +++ b/nerv/examples/test_nn_lib.lua @@ -108,7 +108,21 @@ function nerv.is_type(obj, tname) return false end -require 'matrix.init' -require 'io.init' -require 'layer.init' -require 'nn.init' +function nerv.dirname(filename) + if filename:match(".-/.-") then + local name = string.gsub(filename, "(.*/)(.*)", "%1") + return name + else + return '' + end +end + +function nerv.include(filename) + local caller = debug.getinfo(2, "S").source:sub(2) + dofile(nerv.dirname(caller) .. filename) +end + +nerv.include('matrix/init.lua') +nerv.include('io/init.lua') +nerv.include('layer/init.lua') +nerv.include('nn/init.lua') diff --git a/io/chunk_file.c b/nerv/io/chunk_file.c index c0b6b9f..c0b6b9f 100644 --- a/io/chunk_file.c +++ b/nerv/io/chunk_file.c diff --git a/io/chunk_file.h b/nerv/io/chunk_file.h index 9bae59d..9bae59d 100644 --- a/io/chunk_file.h +++ b/nerv/io/chunk_file.h diff --git a/io/init.c b/nerv/io/init.c index 70585f7..70585f7 100644 --- a/io/init.c +++ b/nerv/io/init.c diff --git a/io/init.lua b/nerv/io/init.lua index b722a81..647ff93 100644 --- a/io/init.lua +++ b/nerv/io/init.lua @@ -52,4 +52,4 @@ function DataBuffer:get_batch() nerv.error_method_not_implemented() end -require 'io.sgd_buffer' +nerv.include('sgd_buffer.lua') diff --git a/io/sgd_buffer.lua b/nerv/io/sgd_buffer.lua index f4f7dfe..f4f7dfe 100644 --- a/io/sgd_buffer.lua +++ b/nerv/io/sgd_buffer.lua diff --git a/layer/affine.lua b/nerv/layer/affine.lua index 00cbcfb..00cbcfb 100644 --- a/layer/affine.lua +++ b/nerv/layer/affine.lua diff --git a/layer/bias.lua b/nerv/layer/bias.lua index c99274d..c99274d 100644 --- a/layer/bias.lua +++ b/nerv/layer/bias.lua diff --git a/layer/combiner.lua b/nerv/layer/combiner.lua index 7bd7617..7bd7617 100644 --- a/layer/combiner.lua +++ b/nerv/layer/combiner.lua diff --git a/layer/init.lua b/nerv/layer/init.lua index e39af94..3c55a94 100644 --- a/layer/init.lua +++ b/nerv/layer/init.lua @@ -70,10 +70,10 @@ function Layer:get_dim() return self.dim_in, self.dim_out end -require 'layer.affine' -require 'layer.sigmoid' -require 'layer.softmax_ce' -require 'layer.bias' -require 'layer.window' -require 'layer.mse' -require 'layer.combiner' +nerv.include('affine.lua') +nerv.include('sigmoid.lua') +nerv.include('softmax_ce.lua') +nerv.include('bias.lua') +nerv.include('window.lua') +nerv.include('mse.lua') +nerv.include('combiner.lua') diff --git a/layer/mse.lua b/nerv/layer/mse.lua index 9a97add..9a97add 100644 --- a/layer/mse.lua +++ b/nerv/layer/mse.lua diff --git a/layer/sigmoid.lua b/nerv/layer/sigmoid.lua index dfd09eb..dfd09eb 100644 --- a/layer/sigmoid.lua +++ b/nerv/layer/sigmoid.lua diff --git a/layer/softmax_ce.lua b/nerv/layer/softmax_ce.lua index daf891e..daf891e 100644 --- a/layer/softmax_ce.lua +++ b/nerv/layer/softmax_ce.lua diff --git a/layer/window.lua b/nerv/layer/window.lua index 4e9a3b1..4e9a3b1 100644 --- a/layer/window.lua +++ b/nerv/layer/window.lua diff --git a/luaT/README.md b/nerv/luaT/README.md index 6e9cf0d..6e9cf0d 100644 --- a/luaT/README.md +++ b/nerv/luaT/README.md diff --git a/luaT/luaT.c b/nerv/luaT/luaT.c index 7b85ce3..7b85ce3 100644 --- a/luaT/luaT.c +++ b/nerv/luaT/luaT.c diff --git a/luaT/luaT.h b/nerv/luaT/luaT.h index 5e8dd2f..5e8dd2f 100644 --- a/luaT/luaT.h +++ b/nerv/luaT/luaT.h diff --git a/matrix/cuda_helper.h b/nerv/matrix/cuda_helper.h index fde6f18..fde6f18 100644 --- a/matrix/cuda_helper.h +++ b/nerv/matrix/cuda_helper.h diff --git a/matrix/cukernel.cu b/nerv/matrix/cukernel.cu index a19030a..a19030a 100644 --- a/matrix/cukernel.cu +++ b/nerv/matrix/cukernel.cu diff --git a/matrix/cukernel.h b/nerv/matrix/cukernel.h index 8a1494f..8a1494f 100644 --- a/matrix/cukernel.h +++ b/nerv/matrix/cukernel.h diff --git a/matrix/cumatrix.c b/nerv/matrix/cumatrix.c index af34fb4..af34fb4 100644 --- a/matrix/cumatrix.c +++ b/nerv/matrix/cumatrix.c diff --git a/matrix/generic/cukernel.cu b/nerv/matrix/generic/cukernel.cu index d6c8adc..d6c8adc 100644 --- a/matrix/generic/cukernel.cu +++ b/nerv/matrix/generic/cukernel.cu diff --git a/matrix/generic/cumatrix.c b/nerv/matrix/generic/cumatrix.c index b5d1a35..b5d1a35 100644 --- a/matrix/generic/cumatrix.c +++ b/nerv/matrix/generic/cumatrix.c diff --git a/matrix/generic/elem_type.h b/nerv/matrix/generic/elem_type.h index bffe940..bffe940 100644 --- a/matrix/generic/elem_type.h +++ b/nerv/matrix/generic/elem_type.h diff --git a/matrix/generic/matrix.c b/nerv/matrix/generic/matrix.c index e17fb42..e17fb42 100644 --- a/matrix/generic/matrix.c +++ b/nerv/matrix/generic/matrix.c diff --git a/matrix/generic/matrix.h b/nerv/matrix/generic/matrix.h index 833724b..833724b 100644 --- a/matrix/generic/matrix.h +++ b/nerv/matrix/generic/matrix.h diff --git a/matrix/generic/mmatrix.c b/nerv/matrix/generic/mmatrix.c index b0f0791..b0f0791 100644 --- a/matrix/generic/mmatrix.c +++ b/nerv/matrix/generic/mmatrix.c diff --git a/matrix/init.c b/nerv/matrix/init.c index c29d7e9..c29d7e9 100644 --- a/matrix/init.c +++ b/nerv/matrix/init.c diff --git a/matrix/init.lua b/nerv/matrix/init.lua index 1a8925f..1a8925f 100644 --- a/matrix/init.lua +++ b/nerv/matrix/init.lua diff --git a/matrix/mmatrix.c b/nerv/matrix/mmatrix.c index d1d68b9..d1d68b9 100644 --- a/matrix/mmatrix.c +++ b/nerv/matrix/mmatrix.c diff --git a/nerv/nerv b/nerv/nerv new file mode 100644 index 0000000..7571659 --- /dev/null +++ b/nerv/nerv @@ -0,0 +1,13 @@ +#! /usr/bin/env luajit +require 'nerv' +print("Greetings") +if #arg < 1 then + return +end +local script = arg[1] +local script_arg = {} +for i = 2, #arg do + table.insert(script_arg, arg[i]) +end +arg = script_arg +dofile(script) diff --git a/nerv/nerv-scm-1.rockspec b/nerv/nerv-scm-1.rockspec new file mode 100644 index 0000000..d14140a --- /dev/null +++ b/nerv/nerv-scm-1.rockspec @@ -0,0 +1,38 @@ +package = "nerv" +version = "scm-1" +source = { + url = "..." -- We don't have one yet +} +description = { + summary = "An example for the LuaRocks tutorial.", + detailed = [[ + ]], + homepage = "https://github.com/Determinant/nerv", -- We don't have one yet + license = "BSD" -- or whatever you like +} +dependencies = { + "lua >= 5.1" + -- If you depend on other rocks, add them here +} +build = { + -- We'll start here. + type = "make", + build_variables = { + CFLAGS="$(CFLAGS)", + LIBFLAG="$(LIBFLAG)", + LUA_LIBDIR="$(LUA_LIBDIR)", + LUA_BINDIR="$(LUA_BINDIR)", + LUA_INCDIR="$(LUA_INCDIR)", + LUA="$(LUA)", + }, + install_variables = { + INST_PREFIX="$(PREFIX)", + INST_BINDIR="$(BINDIR)", + INST_LIBDIR="$(LIBDIR)", + INST_LUADIR="$(LUADIR)", + INST_CONFDIR="$(CONFDIR)", + }, + install = { + bin = {"nerv"} + } +} diff --git a/nerv/nn/init.lua b/nerv/nn/init.lua new file mode 100644 index 0000000..cbaf52b --- /dev/null +++ b/nerv/nn/init.lua @@ -0,0 +1,3 @@ +nerv.include('layer_repo.lua') +nerv.include('param_repo.lua') +nerv.include('layer_dag.lua') diff --git a/nn/layer_dag.lua b/nerv/nn/layer_dag.lua index 8e30216..8e30216 100644 --- a/nn/layer_dag.lua +++ b/nerv/nn/layer_dag.lua diff --git a/nn/layer_repo.lua b/nerv/nn/layer_repo.lua index 602c37c..602c37c 100644 --- a/nn/layer_repo.lua +++ b/nerv/nn/layer_repo.lua diff --git a/nn/param_repo.lua b/nerv/nn/param_repo.lua index ab971ba..ab971ba 100644 --- a/nn/param_repo.lua +++ b/nerv/nn/param_repo.lua diff --git a/nn/init.lua b/nn/init.lua deleted file mode 100644 index 1bafa77..0000000 --- a/nn/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -require 'nn.layer_repo' -require 'nn.param_repo' -require 'nn.layer_dag' diff --git a/pl/compat.lua b/pl/compat.lua deleted file mode 100644 index 7959ac3..0000000 --- a/pl/compat.lua +++ /dev/null @@ -1,137 +0,0 @@ -----------------
---- Lua 5.1/5.2 compatibility
--- Ensures that `table.pack` and `package.searchpath` are available
--- for Lua 5.1 and LuaJIT.
--- The exported function `load` is Lua 5.2 compatible.
--- `compat.setfenv` and `compat.getfenv` are available for Lua 5.2, although
--- they are not always guaranteed to work.
--- @module pl.compat
-
-local compat = {}
-
-compat.lua51 = _VERSION == 'Lua 5.1'
-
---- execute a shell command.
--- This is a compatibility function that returns the same for Lua 5.1 and Lua 5.2
--- @param cmd a shell command
--- @return true if successful
--- @return actual return code
-function compat.execute (cmd)
- local res1,res2,res2 = os.execute(cmd)
- if compat.lua51 then
- return res1==0,res1
- else
- return not not res1,res2
- end
-end
-
-----------------
--- Load Lua code as a text or binary chunk.
--- @param ld code string or loader
--- @param[opt] source name of chunk for errors
--- @param[opt] mode 'b', 't' or 'bt'
--- @param[opt] env environment to load the chunk in
--- @function compat.load
-
----------------
--- Get environment of a function.
--- With Lua 5.2, may return nil for a function with no global references!
--- Based on code by [Sergey Rozhenko](http://lua-users.org/lists/lua-l/2010-06/msg00313.html)
--- @param f a function or a call stack reference
--- @function compat.setfenv
-
----------------
--- Set environment of a function
--- @param f a function or a call stack reference
--- @param env a table that becomes the new environment of `f`
--- @function compat.setfenv
-
-if compat.lua51 then -- define Lua 5.2 style load()
- if not tostring(assert):match 'builtin' then -- but LuaJIT's load _is_ compatible
- local lua51_load = load
- function compat.load(str,src,mode,env)
- local chunk,err
- if type(str) == 'string' then
- if str:byte(1) == 27 and not (mode or 'bt'):find 'b' then
- return nil,"attempt to load a binary chunk"
- end
- chunk,err = loadstring(str,src)
- else
- chunk,err = lua51_load(str,src)
- end
- if chunk and env then setfenv(chunk,env) end
- return chunk,err
- end
- else
- compat.load = load
- end
- compat.setfenv, compat.getfenv = setfenv, getfenv
-else
- compat.load = load
- -- setfenv/getfenv replacements for Lua 5.2
- -- by Sergey Rozhenko
- -- http://lua-users.org/lists/lua-l/2010-06/msg00313.html
- -- Roberto Ierusalimschy notes that it is possible for getfenv to return nil
- -- in the case of a function with no globals:
- -- http://lua-users.org/lists/lua-l/2010-06/msg00315.html
- function compat.setfenv(f, t)
- f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func)
- local name
- local up = 0
- repeat
- up = up + 1
- name = debug.getupvalue(f, up)
- until name == '_ENV' or name == nil
- if name then
- debug.upvaluejoin(f, up, function() return name end, 1) -- use unique upvalue
- debug.setupvalue(f, up, t)
- end
- if f ~= 0 then return f end
- end
-
- function compat.getfenv(f)
- local f = f or 0
- f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func)
- local name, val
- local up = 0
- repeat
- up = up + 1
- name, val = debug.getupvalue(f, up)
- until name == '_ENV' or name == nil
- return val
- end
-end
-
---- Lua 5.2 Functions Available for 5.1
--- @section lua52
-
---- pack an argument list into a table.
--- @param ... any arguments
--- @return a table with field n set to the length
--- @return the length
--- @function table.pack
-if not table.pack then
- function table.pack (...)
- return {n=select('#',...); ...}
- end
-end
-
-------
--- return the full path where a Lua module name would be matched.
--- @param mod module name, possibly dotted
--- @param path a path in the same form as package.path or package.cpath
--- @see path.package_path
--- @function package.searchpath
-if not package.searchpath then
- local sep = package.config:sub(1,1)
- function package.searchpath (mod,path)
- mod = mod:gsub('%.',sep)
- for m in path:gmatch('[^;]+') do
- local nm = m:gsub('?',mod)
- local f = io.open(nm,'r')
- if f then f:close(); return nm end
- end
- end
-end
-
-return compat
diff --git a/pl/utils.lua b/pl/utils.lua deleted file mode 100644 index f933afb..0000000 --- a/pl/utils.lua +++ /dev/null @@ -1,476 +0,0 @@ ---- Generally useful routines. --- See @{01-introduction.md.Generally_useful_functions|the Guide}. --- @module pl.utils -local format,gsub,byte = string.format,string.gsub,string.byte -local compat = require 'pl.compat' -local clock = os.clock -local stdout = io.stdout -local append = table.insert -local unpack = rawget(_G,'unpack') or rawget(table,'unpack') - -local collisions = {} - -local utils = { - _VERSION = "1.3.2", - lua51 = compat.lua51, - setfenv = compat.setfenv, - getfenv = compat.getfenv, - load = compat.load, - execute = compat.execute, - dir_separator = _G.package.config:sub(1,1), - unpack = unpack -} - ---- end this program gracefully. --- @param code The exit code or a message to be printed --- @param ... extra arguments for message's format' --- @see utils.fprintf -function utils.quit(code,...) - if type(code) == 'string' then - utils.fprintf(io.stderr,code,...) - code = -1 - else - utils.fprintf(io.stderr,...) - end - io.stderr:write('\n') - os.exit(code) -end - ---- print an arbitrary number of arguments using a format. --- @param fmt The format (see string.format) --- @param ... Extra arguments for format -function utils.printf(fmt,...) - utils.assert_string(1,fmt) - utils.fprintf(stdout,fmt,...) -end - ---- write an arbitrary number of arguments to a file using a format. --- @param f File handle to write to. --- @param fmt The format (see string.format). --- @param ... Extra arguments for format -function utils.fprintf(f,fmt,...) - utils.assert_string(2,fmt) - f:write(format(fmt,...)) -end - -local function import_symbol(T,k,v,libname) - local key = rawget(T,k) - -- warn about collisions! - if key and k ~= '_M' and k ~= '_NAME' and k ~= '_PACKAGE' and k ~= '_VERSION' then - utils.printf("warning: '%s.%s' will not override existing symbol\n",libname,k) - return - end - rawset(T,k,v) -end - -local function lookup_lib(T,t) - for k,v in pairs(T) do - if v == t then return k end - end - return '?' -end - -local already_imported = {} - ---- take a table and 'inject' it into the local namespace. --- @param t The Table --- @param T An optional destination table (defaults to callers environment) -function utils.import(t,T) - T = T or _G - t = t or utils - if type(t) == 'string' then - t = require (t) - end - local libname = lookup_lib(T,t) - if already_imported[t] then return end - already_imported[t] = libname - for k,v in pairs(t) do - import_symbol(T,k,v,libname) - end -end - -utils.patterns = { - FLOAT = '[%+%-%d]%d*%.?%d*[eE]?[%+%-]?%d*', - INTEGER = '[+%-%d]%d*', - IDEN = '[%a_][%w_]*', - FILE = '[%a%.\\][:%][%w%._%-\\]*' -} - ---- escape any 'magic' characters in a string --- @param s The input string -function utils.escape(s) - utils.assert_string(1,s) - return (s:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1')) -end - ---- return either of two values, depending on a condition. --- @param cond A condition --- @param value1 Value returned if cond is true --- @param value2 Value returned if cond is false (can be optional) -function utils.choose(cond,value1,value2) - if cond then return value1 - else return value2 - end -end - -local raise - ---- return the contents of a file as a string --- @param filename The file path --- @param is_bin open in binary mode --- @return file contents -function utils.readfile(filename,is_bin) - local mode = is_bin and 'b' or '' - utils.assert_string(1,filename) - local f,err = io.open(filename,'r'..mode) - if not f then return utils.raise (err) end - local res,err = f:read('*a') - f:close() - if not res then return raise (err) end - return res -end - ---- write a string to a file --- @param filename The file path --- @param str The string --- @return true or nil --- @return error message --- @raise error if filename or str aren't strings -function utils.writefile(filename,str) - utils.assert_string(1,filename) - utils.assert_string(2,str) - local f,err = io.open(filename,'w') - if not f then return raise(err) end - f:write(str) - f:close() - return true -end - ---- return the contents of a file as a list of lines --- @param filename The file path --- @return file contents as a table --- @raise errror if filename is not a string -function utils.readlines(filename) - utils.assert_string(1,filename) - local f,err = io.open(filename,'r') - if not f then return raise(err) end - local res = {} - for line in f:lines() do - append(res,line) - end - f:close() - return res -end - ---- split a string into a list of strings separated by a delimiter. --- @param s The input string --- @param re A Lua string pattern; defaults to '%s+' --- @param plain don't use Lua patterns --- @param n optional maximum number of splits --- @return a list-like table --- @raise error if s is not a string -function utils.split(s,re,plain,n) - utils.assert_string(1,s) - local find,sub,append = string.find, string.sub, table.insert - local i1,ls = 1,{} - if not re then re = '%s+' end - if re == '' then return {s} end - while true do - local i2,i3 = find(s,re,i1,plain) - if not i2 then - local last = sub(s,i1) - if last ~= '' then append(ls,last) end - if #ls == 1 and ls[1] == '' then - return {} - else - return ls - end - end - append(ls,sub(s,i1,i2-1)) - if n and #ls == n then - ls[#ls] = sub(s,i1) - return ls - end - i1 = i3+1 - end -end - ---- split a string into a number of values. --- @param s the string --- @param re the delimiter, default space --- @return n values --- @usage first,next = splitv('jane:doe',':') --- @see split -function utils.splitv (s,re) - return unpack(utils.split(s,re)) -end - ---- convert an array of values to strings. --- @param t a list-like table --- @param temp buffer to use, otherwise allocate --- @param tostr custom tostring function, called with (value,index). --- Otherwise use `tostring` --- @return the converted buffer -function utils.array_tostring (t,temp,tostr) - temp, tostr = temp or {}, tostr or tostring - for i = 1,#t do - temp[i] = tostr(t[i],i) - end - return temp -end - ---- execute a shell command and return the output. --- This function redirects the output to tempfiles and returns the content of those files. --- @param cmd a shell command --- @param bin boolean, if true, read output as binary file --- @return true if successful --- @return actual return code --- @return stdout output (string) --- @return errout output (string) -function utils.executeex(cmd, bin) - local mode - local outfile = os.tmpname() - local errfile = os.tmpname() - - if utils.dir_separator == '\\' then - outfile = os.getenv('TEMP')..outfile - errfile = os.getenv('TEMP')..errfile - end - cmd = cmd .. [[ >"]]..outfile..[[" 2>"]]..errfile..[["]] - - local success, retcode = utils.execute(cmd) - local outcontent = utils.readfile(outfile, bin) - local errcontent = utils.readfile(errfile, bin) - os.remove(outfile) - os.remove(errfile) - return success, retcode, (outcontent or ""), (errcontent or "") -end - ---- 'memoize' a function (cache returned value for next call). --- This is useful if you have a function which is relatively expensive, --- but you don't know in advance what values will be required, so --- building a table upfront is wasteful/impossible. --- @param func a function of at least one argument --- @return a function with at least one argument, which is used as the key. -function utils.memoize(func) - return setmetatable({}, { - __index = function(self, k, ...) - local v = func(k,...) - self[k] = v - return v - end, - __call = function(self, k) return self[k] end - }) -end - - -utils.stdmt = { - List = {_name='List'}, Map = {_name='Map'}, - Set = {_name='Set'}, MultiMap = {_name='MultiMap'} -} - -local _function_factories = {} - ---- associate a function factory with a type. --- A function factory takes an object of the given type and --- returns a function for evaluating it --- @tab mt metatable --- @func fun a callable that returns a function -function utils.add_function_factory (mt,fun) - _function_factories[mt] = fun -end - -local function _string_lambda(f) - local raise = utils.raise - if f:find '^|' or f:find '_' then - local args,body = f:match '|([^|]*)|(.+)' - if f:find '_' then - args = '_' - body = f - else - if not args then return raise 'bad string lambda' end - end - local fstr = 'return function('..args..') return '..body..' end' - local fn,err = utils.load(fstr) - if not fn then return raise(err) end - fn = fn() - return fn - else return raise 'not a string lambda' - end -end - ---- an anonymous function as a string. This string is either of the form --- '|args| expression' or is a function of one argument, '_' --- @param lf function as a string --- @return a function --- @usage string_lambda '|x|x+1' (2) == 3 --- @usage string_lambda '_+1 (2) == 3 --- @function utils.string_lambda -utils.string_lambda = utils.memoize(_string_lambda) - -local ops - ---- process a function argument. --- This is used throughout Penlight and defines what is meant by a function: --- Something that is callable, or an operator string as defined by <code>pl.operator</code>, --- such as '>' or '#'. If a function factory has been registered for the type, it will --- be called to get the function. --- @param idx argument index --- @param f a function, operator string, or callable object --- @param msg optional error message --- @return a callable --- @raise if idx is not a number or if f is not callable -function utils.function_arg (idx,f,msg) - utils.assert_arg(1,idx,'number') - local tp = type(f) - if tp == 'function' then return f end -- no worries! - -- ok, a string can correspond to an operator (like '==') - if tp == 'string' then - if not ops then ops = require 'pl.operator'.optable end - local fn = ops[f] - if fn then return fn end - local fn, err = utils.string_lambda(f) - if not fn then error(err..': '..f) end - return fn - elseif tp == 'table' or tp == 'userdata' then - local mt = getmetatable(f) - if not mt then error('not a callable object',2) end - local ff = _function_factories[mt] - if not ff then - if not mt.__call then error('not a callable object',2) end - return f - else - return ff(f) -- we have a function factory for this type! - end - end - if not msg then msg = " must be callable" end - if idx > 0 then - error("argument "..idx..": "..msg,2) - else - error(msg,2) - end -end - ---- bind the first argument of the function to a value. --- @param fn a function of at least two values (may be an operator string) --- @param p a value --- @return a function such that f(x) is fn(p,x) --- @raise same as @{function_arg} --- @see func.bind1 -function utils.bind1 (fn,p) - fn = utils.function_arg(1,fn) - return function(...) return fn(p,...) end -end - ---- bind the second argument of the function to a value. --- @param fn a function of at least two values (may be an operator string) --- @param p a value --- @return a function such that f(x) is fn(x,p) --- @raise same as @{function_arg} -function utils.bind2 (fn,p) - fn = utils.function_arg(1,fn) - return function(x,...) return fn(x,p,...) end -end - - ---- assert that the given argument is in fact of the correct type. --- @param n argument index --- @param val the value --- @param tp the type --- @param verify an optional verfication function --- @param msg an optional custom message --- @param lev optional stack position for trace, default 2 --- @raise if the argument n is not the correct type --- @usage assert_arg(1,t,'table') --- @usage assert_arg(n,val,'string',path.isdir,'not a directory') -function utils.assert_arg (n,val,tp,verify,msg,lev) - if type(val) ~= tp then - error(("argument %d expected a '%s', got a '%s'"):format(n,tp,type(val)),lev or 2) - end - if verify and not verify(val) then - error(("argument %d: '%s' %s"):format(n,val,msg),lev or 2) - end -end - ---- assert the common case that the argument is a string. --- @param n argument index --- @param val a value that must be a string --- @raise val must be a string -function utils.assert_string (n,val) - utils.assert_arg(n,val,'string',nil,nil,3) -end - -local err_mode = 'default' - ---- control the error strategy used by Penlight. --- Controls how <code>utils.raise</code> works; the default is for it --- to return nil and the error string, but if the mode is 'error' then --- it will throw an error. If mode is 'quit' it will immediately terminate --- the program. --- @param mode - either 'default', 'quit' or 'error' --- @see utils.raise -function utils.on_error (mode) - if ({['default'] = 1, ['quit'] = 2, ['error'] = 3})[mode] then - err_mode = mode - else - -- fail loudly - if err_mode == 'default' then err_mode = 'error' end - utils.raise("Bad argument expected string; 'default', 'quit', or 'error'. Got '"..tostring(mode).."'") - end -end - ---- used by Penlight functions to return errors. Its global behaviour is controlled --- by <code>utils.on_error</code> --- @param err the error string. --- @see utils.on_error -function utils.raise (err) - if err_mode == 'default' then return nil,err - elseif err_mode == 'quit' then utils.quit(err) - else error(err,2) - end -end - ---- is the object of the specified type?. --- If the type is a string, then use type, otherwise compare with metatable --- @param obj An object to check --- @param tp String of what type it should be -function utils.is_type (obj,tp) - if type(tp) == 'string' then return type(obj) == tp end - local mt = getmetatable(obj) - return tp == mt -end - -raise = utils.raise - ---- load a code string or bytecode chunk. --- @param code Lua code as a string or bytecode --- @param name for source errors --- @param mode kind of chunk, 't' for text, 'b' for bytecode, 'bt' for all (default) --- @param env the environment for the new chunk (default nil) --- @return compiled chunk --- @return error message (chunk is nil) --- @function utils.load - ---------------- --- Get environment of a function. --- With Lua 5.2, may return nil for a function with no global references! --- Based on code by [Sergey Rozhenko](http://lua-users.org/lists/lua-l/2010-06/msg00313.html) --- @param f a function or a call stack reference --- @function utils.getfenv - ---------------- --- Set environment of a function --- @param f a function or a call stack reference --- @param env a table that becomes the new environment of `f` --- @function utils.setfenv - ---- execute a shell command. --- This is a compatibility function that returns the same for Lua 5.1 and Lua 5.2 --- @param cmd a shell command --- @return true if successful --- @return actual return code --- @function utils.execute - -return utils - - diff --git a/speech b/speech -Subproject 3910eb670f3c29aba95596bb8c55cbee3368f80 +Subproject 32eac093cc431849a92e5a2297c5fe646fd6055 diff --git a/tools/build_luajit.sh b/tools/build_luajit.sh new file mode 100755 index 0000000..7a66412 --- /dev/null +++ b/tools/build_luajit.sh @@ -0,0 +1,4 @@ +#!/bin/bash +LUAJIT_PREFIX="$PREFIX" +LUAJIT_SRC='luajit-2.0/' +[[ -f "$LUAJIT_PREFIX/bin/luajit" ]] || (cd "$LUAJIT_SRC"; make && make PREFIX="$LUAJIT_PREFIX" install) diff --git a/tools/build_luarocks.sh b/tools/build_luarocks.sh new file mode 100755 index 0000000..e1f1c0b --- /dev/null +++ b/tools/build_luarocks.sh @@ -0,0 +1,4 @@ +#!/bin/bash +LUAROCKS_PREFIX="$PREFIX" +LUAROCKS_SRC='luarocks/' +[[ -f "$LUAROCKS_PREFIX/bin/luarocks" ]] || (cd "$LUAROCKS_SRC"; ./configure --prefix=$LUAROCKS_PREFIX --with-lua-include="$LUAROCKS_PREFIX/include/luajit-2.0/" --with-lua="$LUAROCKS_PREFIX" --lua-suffix='jit' --with-lua-lib="$LUAROCKS_PREFIX/lib/"; make clean && make build && make bootstrap ) |