diff options
Diffstat (limited to 'nerv/nerv')
-rw-r--r-- | nerv/nerv | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1,8 +1,8 @@ #! /usr/bin/env luajit require 'nerv' -local options = {{"help", "h", "bool", default = false, desc = "print this help message"}, - {"use-cpu", "c", "bool", default = false, desc = "use CPU by default (instead of gpu by default)"}, - {"select-gpu", nil, "int", default = nil, desc = "select the GPU for computation, fallback to auto mode if not specified"}} +local options = {{"help", "h", "boolean", default = false, desc = "print this help message"}, + {"use-cpu", "c", "boolean", default = false, desc = "use CPU by default (instead of gpu by default)"}, + {"select-gpu", nil, "int", default = -1, desc = "select the GPU for computation, fallback to auto mode if not specified"}} local function print_help() nerv.printf("Usage: <nerv_prog> [options] script.lua\n") @@ -24,10 +24,7 @@ local function _add_profile_method(cls) end if not opts["use-cpu"].val then - local dev = -1 - if opts["select-gpu"].val then - dev = opts["select-gpu"].val - end + local dev = opts["select-gpu"].val nerv.info("automatically initialize a default CuContext...") nerv.CuMatrix._default_context = nerv.CuContext(dev) nerv.info("the default CuContext is ok") |