Home / Class/ PytorchLiteInstrumentedTests Class — pytorch Architecture

PytorchLiteInstrumentedTests Class — pytorch Architecture

Architecture documentation for the PytorchLiteInstrumentedTests class in PytorchLiteInstrumentedTests.java from the pytorch codebase.

Entity Profile

Relationship Graph

Source Code

android/pytorch_android/src/androidTest/java/org/pytorch/PytorchLiteInstrumentedTests.java lines 13–42

@RunWith(AndroidJUnit4.class)
public class PytorchLiteInstrumentedTests extends PytorchTestBase {

  @Override
  protected Module loadModel(String path) throws IOException {
    return LiteModuleLoader.load(assetFilePath(path));
  }

  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;
    }
  }
}

Analyze Your Own Codebase

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

Try Supermodel Free