int luaopen_libcutorch(lua_State *L) { lua_newtable(L); luaL_setfuncs(L, cutorch_stuff__, 0); THCState* state = (THCState*)malloc(sizeof(THCState)); THCudaInit(state); /* Register torch.CudaHostAllocator. */ luaT_pushudata(L, state->cudaHostAllocator, "torch.Allocator"); lua_setfield(L, -2, "CudaHostAllocator"); #ifdef USE_MAGMA THCMagma_init(state); lua_pushboolean(L, 1); lua_setfield(L, -2, "magma"); #endif cutorch_CudaStorage_init(L); cutorch_CudaTensor_init(L); cutorch_CudaTensorMath_init(L); cutorch_CudaTensorOperator_init(L); /* Store state in cutorch table. */ lua_pushlightuserdata(L, state); lua_setfield(L, -2, "_state"); return 1; }
DLL_EXPORT int luaopen_libcutorch(lua_State *L) { lua_newtable(L); luaL_register(L, NULL, cutorch_stuff__); THCudaInit(); cutorch_CudaStorage_init(L); cutorch_CudaTensor_init(L); cutorch_CudaTensorMath_init(L); return 1; }