pytorch / pytorch/executorch

Android runtime execution - Execution of method forward failed with status 0x12

Open
#14,804 21 comments 0 reactions 1 assignee View on GitHub

@psiddh is already working on this.

Since Oct 4, 2025.

module: android need-user-input
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

Hi,

After loading my model in my Android application, when I attempted to run it execution failed with Execution of method forward failed with status 0x12 error.

Below you will find the trceback log produced by the error and the code where the error occurred.

I tried to look into the EValue and NativePeer source code but did not see anything that would explain what happened as I think the error occurred in NativePeer native source code (not visible to me)

Please let me know if you need any additional information

Thanks

SOURCE CODE

			float[] flat = flatten(tmpData);
			final long[]  shapeArrDataPytorchFlattened = new long[]{tmpData.length, 4, 1};
			arrDataPytorch = Tensor.fromBlob(flat, shapeArrDataPytorchFlattened);
			
			//arrDataPytorch IS float[][]
.
.
.

			try {
				Log.i(TAG, " - neuralNetworkloadAndRunPytorch - About to load module --- ");
				mModule = Module.load(moduleFileAbsoluteFilePath);   //EXECUTORCH
			} catch (Exception e) {
				Log.i(TAG, " - neuralNetworkloadAndRunPytorch - Loading of module FAILED --- ");
				throw new RuntimeException(e);
			}

			Tensor outputTensor = null;

			float[] scores = new float[1];

			try {
				Log.i(TAG, " - neuralNetworkloadAndRunPytorch - Abut to run inference --- ");
				outputTensor = mModule.forward()[0].toTensor();   //EXECUTORCH
				Log.i(TAG, " - neuralNetworkloadAndRunPytorch - outputTensor - "+outputTensor);

//FAILURE OCCURS HERE		outputTensor = mModule.forward(EValue.from(arrDataPytorch))[0].toTensor();   //EXECUTORCH
				Log.i(TAG, " - neuralNetworkloadAndRunPytorch - outputTensor - "+outputTensor);

			} catch (Exception e) {
				Log.i(TAG, " - neuralNetworkloadAndRunPytorch - Inference FAILED --- ");
				throw new RuntimeException(e);
			}

TRACEBACK LOG

10-04 12:28:02.544: E/ExecuTorch(21206): input 1 is none
10-04 12:28:02.546: I/NeuralNetworkService(21206):  - neuralNetworkloadAndRunPytorch - Inference FAILED --- 
10-04 12:28:02.547: W/System.err(21206): java.lang.RuntimeException: java.lang.Exception: Execution of method forward failed with status 0x12
10-04 12:28:02.547: W/System.err(21206): 	at com.android.contextq.neuralNetwork.NeuralNetworkService.neuralNetworkloadAndRunPytorch(NeuralNetworkService.java:3043)
10-04 12:28:02.547: W/System.err(21206): 	at com.android.contextq.neuralNetwork.NeuralNetworkService$NeuralNetworkServiceRunnable.run(NeuralNetworkService.java:10035)
10-04 12:28:02.548: W/System.err(21206): 	at java.lang.Thread.run(Thread.java:1119)
10-04 12:28:02.548: W/System.err(21206): Caused by: java.lang.Exception: Execution of method forward failed with status 0x12
10-04 12:28:02.548: W/System.err(21206): 	at org.pytorch.executorch.NativePeer.forward(Native Method)
10-04 12:28:02.548: W/System.err(21206): 	at org.pytorch.executorch.Module.forward(Module.java:75)
10-04 12:28:02.548: W/System.err(21206): 	at com.android.contextq.neuralNetwork.NeuralNetworkService.neuralNetworkloadAndRunPytorch(NeuralNetworkService.java:3035)
10-04 12:28:02.548: W/System.err(21206): 	... 2 more

cc @kirklandsign @cbilgin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.