You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is actually a question regarding Torch and Lua, rather than TorchAndroid. As I understand the question @kk291 wants to know how one can pass for instance a vector (or tensor) to a Torch -script/Lua -script, in AndroidTorch.
Expecting that you have succeeded to add the compiled TorchAndroid .so/.h files to your Android project you can proceed with the following steps. The links refer to relevant lines in the bundled demo source.
Create a function in this class that can push a Tensor (or data of arbitrary kind) to TorchAndroid [i.e. your lua -file] and read the result
Here's the relevant lines invoking a function in the Lua -script with a Tensor argument:
lua_getglobal(L, "getTopOnly");
luaT_pushudata(L, testTensor, "torch.DoubleTensor");
if (lua_pcall(L, 1, 1, 0) != 0)
//error, retreive error
else
//success, retreive result
One needs to know that the C Lua api is stack based, meaning you interact with the Lua inerpreter as you do with a stack, refer to the links to see how.
This is not strictly related to TorchAndroid, but just the C/C++ Lua api.
Hi,
How are we supposed to pass arguments to a lua file in torch-android?
The text was updated successfully, but these errors were encountered: