Package org.pytorch

Class LiteModuleLoader


  • public class LiteModuleLoader
    extends Object
    • Constructor Detail

      • LiteModuleLoader

        public LiteModuleLoader()
    • Method Detail

      • load

        public static Module load​(String modelPath,
                                  Map<String,​String> extraFiles,
                                  Device device)
        Loads a serialized TorchScript module from the specified path on the disk to run on specified device. The model should be generated from this api _save_for_lite_interpreter().
        Parameters:
        modelPath - path to file that contains the serialized TorchScript module.
        extraFiles - map with extra files names as keys, content of them will be loaded to values.
        device - Device to use for running specified module.
        Returns:
        new Module object which owns torch::jit::mobile::Module.
      • load

        public static Module load​(String modelPath)
        Loads a serialized TorchScript module from the specified path on the disk to run on CPU. The model should be generated from this api _save_for_lite_interpreter().
        Parameters:
        modelPath - path to file that contains the serialized TorchScript module.
        Returns:
        new Module object which owns torch::jit::mobile::Module.
      • loadModuleFromAsset

        public static Module loadModuleFromAsset​(AssetManager assetManager,
                                                 String assetName,
                                                 Device device)
        Attention: This is not recommended way of loading production modules, as prepackaged assets increase apk size etc. For production usage consider using loading from file on the disk Module.load(String).

        This method is meant to use in tests and demos.