-
public class ModuleJava wrapper for ExecuTorch Module.
Warning: These APIs are experimental and subject to change without notice
-
-
Field Summary
Fields Modifier and Type Field Description public final static intLOAD_MODE_FILEpublic final static intLOAD_MODE_MMAPpublic final static intLOAD_MODE_MMAP_USE_MLOCKpublic final static intLOAD_MODE_MMAP_USE_MLOCK_IGNORE_ERRORS
-
Method Summary
Modifier and Type Method Description static Moduleload(String modelPath, int loadMode)Loads a serialized ExecuTorch module from the specified path on the disk. static Moduleload(String modelPath)Loads a serialized ExecuTorch module from the specified path on the disk to run on CPU. Array<EValue>forward(Array<EValue> inputs)Runs the 'forward' method of this module with the specified arguments. Array<EValue>execute(String methodName, Array<EValue> inputs)Runs the specified method of this module with the specified arguments. intloadMethod(String methodName)Load a method on this module. Array<String>readLogBuffer()Retrieve the in-memory log buffer, containing the most recent ExecuTorch log entries. voiddestroy()Explicitly destroys the native torch::jit::Module. -
-
Method Detail
-
load
static Module load(String modelPath, int loadMode)
Loads a serialized ExecuTorch module from the specified path on the disk.
- Parameters:
modelPath- path to file that contains the serialized ExecuTorch module.loadMode- load mode for the module.
-
load
static Module load(String modelPath)
Loads a serialized ExecuTorch module from the specified path on the disk to run on CPU.
- Parameters:
modelPath- path to file that contains the serialized ExecuTorch module.
-
forward
Array<EValue> forward(Array<EValue> inputs)
Runs the 'forward' method of this module with the specified arguments.
- Parameters:
inputs- arguments for the ExecuTorch module's 'forward' method.
-
execute
Array<EValue> execute(String methodName, Array<EValue> inputs)
Runs the specified method of this module with the specified arguments.
- Parameters:
methodName- name of the ExecuTorch method to run.inputs- arguments that will be passed to ExecuTorch method.
-
loadMethod
int loadMethod(String methodName)
Load a method on this module. This might help with the first time inference performance,because otherwise the method is loaded lazily when it's execute. Note: this function issynchronous, and will block until the method is loaded. Therefore, it is recommended to callthis on a background thread. However, users need to make sure that they don't execute beforethis function returns.
-
readLogBuffer
Array<String> readLogBuffer()
Retrieve the in-memory log buffer, containing the most recent ExecuTorch log entries.
-
destroy
void destroy()
Explicitly destroys the native torch::jit::Module. Calling this method is not required, as thenative object will be destroyed when this object is garbage-collected. However, the timing ofgarbage collection is not guaranteed, so proactively calling
{@code destroy}can free memorymore quickly. See resetNative.
-
-
-
-