Skip to content

Commit 28ff41e

Browse files
committed
[pytorch/executorch][diff_train] using-executorch-android.md: Use an easier example (#10008)
And it's working without additional requirements! Internal: << DO NOT EDIT BELOW THIS LINE >> **GitHub Author**: Hansong <[email protected]> (Meta Employee) **GitHub Repo**: [pytorch/executorch](https://github.com/pytorch/executorch) **GitHub Pull Request**: [#10008](#10008) Initially generated by: https://www.internalfb.com/intern/sandcastle/job/13510800659039904/ This was imported as part of a Diff Train. Please review this as soon as possible. Since it is a direct copy of a commit on GitHub, there shouldn't be much to do. diff-train-source-id: a1af1ff Differential Revision: [D72746022](https://our.internmc.facebook.com/intern/diff/D72746022/) [ghstack-poisoned]
1 parent caa4895 commit 28ff41e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

docs/source/using-executorch-android.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,22 @@ public class MainActivity extends Activity {
172172
protected void onCreate(Bundle savedInstanceState) {
173173
super.onCreate(savedInstanceState);
174174
// Load the ExecuTorch module
175-
module = Module.load("/path/to/module.pte");
176-
}
177-
public void runInference(View view) {
178-
// Prepare input data
179-
Tensor input = Tensor.fromBlob(getInputData());
180-
// Run inference
181-
Tensor output = module.forward(EValue.from(input))[0].toTensor();
182-
// Process output data
183-
processOutput(output);
175+
Module module = Module.load("/data/local/tmp/add.pte");
176+
Tensor tensor1 = Tensor.fromBlob(new float[] {1.0f}, new long[] {1});
177+
Tensor tensor2 = Tensor.fromBlob(new float[] {20.0f}, new long[] {1});
178+
179+
EValue eValue1 = EValue.from(tensor1);
180+
EValue eValue2 = EValue.from(tensor2);
181+
float result = module.forward(eValue1, eValue2)[0].toTensor().getDataAsFloatArray()[0];
184182
}
185183
}
186184
```
185+
186+
Push the corresponding pte file to the phone:
187+
```sh
188+
adb push extension/module/test/resources/add.pte /data/local/tmp/
189+
```
190+
187191
This example loads an ExecuTorch module, prepares input data, runs inference, and processes the output data.
188192

189193
Please use [DeepLabV3AndroidDemo](https://github.com/pytorch-labs/executorch-examples/tree/main/dl3/android/DeepLabV3Demo)

0 commit comments

Comments
 (0)