Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ jobs:
- run: python3 --version
- run: pip3 install torch --extra-index-url https://download.pytorch.org/whl/cpu
- run: ./gradlew iosSimulatorX64Test
test-android-instrumented:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- run: xcrun simctl list devices iOS
- run: python3 --version
- run: pip3 install torch --extra-index-url https://download.pytorch.org/whl/cpu
- run: python3 build_dummy_model.py
- run: mkdir src/androidTest/assets
- run: mv dummy_module.ptl src/androidTest/assets/
- run: ./gradlew connectedAndroidTest
build:
runs-on: macos-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
ios/LibTorchWrapper/LibTorchWrapper.xcworkspace/xcuserdata
pytorch_lite_multiplatform.podspec
bin/
src/androidTest/assets/dummy_module.ptl
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ kotlin {
}
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13")
implementation("junit:junit:4.13.2")
implementation("androidx.test:core:1.5.0")
implementation("androidx.test:rules:1.5.0")
implementation("androidx.test:runner:1.5.2")
implementation("androidx.test.ext:junit:1.1.5")
}
}
}
Expand Down Expand Up @@ -154,6 +158,7 @@ android {
defaultConfig {
minSdkVersion(24)
targetSdkVersion(30)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("release") {
Expand Down
13 changes: 11 additions & 2 deletions build_dummy_model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from typing import Dict, List, Tuple
from typing import Dict, List, NamedTuple, Tuple

import torch
import torch.nn as nn

@torch.jit.export
class State(NamedTuple):
a: int
b: int

class DummyModel(nn.Module):
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -57,6 +62,10 @@ def identity_dict_long(self, x: Dict[int, int]):
def identity_string(self, x: str):
return x

@torch.jit.export
def identity_named_tuple(self, x: State):
return x

@torch.jit.export
def similarity(self, x: torch.Tensor, y: torch.Tensor):
return self.cos_sim(x, y)
Expand All @@ -74,4 +83,4 @@ def main():

if __name__ == "__main__":
print("PyTorch Version", torch.__version__)
main()
main()
Loading