pytorch
ee2de8ae - [android] Module load extraFiles (#55644)

Commit
3 years ago
[android] Module load extraFiles (#55644) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55644 Testing: Prepare the model with extra: ``` extra_files = {} extra_files["model/live.spec.json"] = '{ "spec": "spec_value"}' torch.jit.save(script_model, "extra.pt", _extra_files=extra_files) script_model._save_for_lite_interpreter("extra.ptl"), _extra_files=extra_files) ``` Change android/test_app/app/src/main/java/org/pytorch/testapp/MainActivity.java 1. Full jit ``` Map<String, String> map = new HashMap<>(); map.put("model/live.spec.json", ""); mModule = Module.load(assetFilePath(this, BuildConfig.MODULE_ASSET_NAME), map, Device.CPU); android.util.Log.i("XXX", "map:" + map); ``` `gradle -p android test_app:installMnetLocalBaseDebug -PABI_FILTERS=arm64-v8a` 2. Lite ``` Map<String, String> map = new HashMap<>(); map.put("model/live.spec.json", ""); mModule = LiteModuleLoader.load(assetFilePath(this, BuildConfig.MODULE_ASSET_NAME), map, Device.CPU); android.util.Log.i("XXX", "map:" + map); ``` `BUILD_LITE_INTERPRETER=1 gradle -p android test_app:installMnetLocalBaseDebug -PABI_FILTERS=arm64-v8a` Check logcat Test Plan: Imported from OSS Reviewed By: ljk53 Differential Revision: D27663624 Pulled By: IvanKobzarev fbshipit-source-id: 0dcd93b2fddaacd221db0306d18afee2584fcb85
Author
Parents
  • android/pytorch_android/src/main
    • cpp
      • File
        pytorch_jni_jit.cpp
      • File
        pytorch_jni_lite.cpp
    • java/org/pytorch
      • File
        LiteModuleLoader.java
      • File
        LiteNativePeer.java
      • File
        Module.java
      • File
        NativePeer.java