Running onnx with nnapi

Which version of system do you use? Khadas official images, self built images, or others?

Khadas official images

Please describe your issue below:

I’m trying to run my onnx model with nnapi as Execution Provider.

Below is my source trying to run. I’m using kotlin.

when I enabled “ortoption.addNnapi(EnumSet.of(NNAPIFlags.USE_NCHW, NNAPIFlags.CPU_DISABLED));” code to run model with gpu, error was occured.

My model’s operators are compatible with nnapi feature level 3.

Please help me to solve this.

/=================================================================/

val ortoption = SessionOptions()

//ortoption.addNnapi();
//ortoption.addNnapi(EnumSet.of(NNAPIFlags.USE_NCHW, NNAPIFlags.CPU_DISABLED));

var orisession = ortEnv?.createSession(mobelbyteArray, ortoption);

val height:Long = 224
val width:Long = 224

val shape = longArrayOf(8, 3, height, width)
val env = OrtEnvironment.getEnvironment()

var duration: Long = 0;

val imgData = FloatBuffer.allocate(height.toInt() * width.toInt() * 3 * 8)

val inputName = orisession?.inputNames?.iterator()?.next()

env.use {
val tensor = OnnxTensor.createTensor(env, imgData, shape)
val startTime = SystemClock.uptimeMillis()
tensor.use {
duration = measureTimeMillis {
val output = orisession?.run(Collections.singletonMap(inputName, tensor))
}
println("Time is : " + duration)
}
}

/=================================================================/

Post a console log of your issue below:

ANEURALNETWORKS_OP_FAILED