Home / Function/ assetFilePath() — pytorch Function Reference

assetFilePath() — pytorch Function Reference

Architecture documentation for the assetFilePath() function in PytorchLiteInstrumentedTests.java from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  0be06db3_fddb_91db_a28f_ef40fb4eee78["assetFilePath()"]
  d30d8eed_5566_5e0a_5cc4_06583323c3fe["loadModel()"]
  d30d8eed_5566_5e0a_5cc4_06583323c3fe -->|calls| 0be06db3_fddb_91db_a28f_ef40fb4eee78
  style 0be06db3_fddb_91db_a28f_ef40fb4eee78 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

android/pytorch_android/src/androidTest/java/org/pytorch/PytorchLiteInstrumentedTests.java lines 21–41

  private String assetFilePath(String assetName) throws IOException {
    final Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    File file = new File(appContext.getFilesDir(), assetName);
    if (file.exists() && file.length() > 0) {
      return file.getAbsolutePath();
    }

    try (InputStream is = appContext.getAssets().open(assetName)) {
      try (OutputStream os = new FileOutputStream(file)) {
        byte[] buffer = new byte[4 * 1024];
        int read;
        while ((read = is.read(buffer)) != -1) {
          os.write(buffer, 0, read);
        }
        os.flush();
      }
      return file.getAbsolutePath();
    } catch (IOException e) {
      throw e;
    }
  }

Subdomains

Called By

Frequently Asked Questions

What does assetFilePath() do?
assetFilePath() is a function in the pytorch codebase.
What calls assetFilePath()?
assetFilePath() is called by 1 function(s): loadModel.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free