Implement NDK interface for dynamic output shape.
Implement the following NDK interfaces
- ANeuralNetworksExecution_getOutputOperandDimensions
- ANeuralNetworksExecution_getOutputOperandRank
Bug: 73506513
Test: NeuralNetworksTest_static
Change-Id: I3e0238ec701a0bffbdb5682ee1787df198fe9816
Merged-In: I3e0238ec701a0bffbdb5682ee1787df198fe9816
(cherry picked from commit d2442daafb99f04a1320d0b4bd45ecde9d983b05)
diff --git a/runtime/NeuralNetworks.cpp b/runtime/NeuralNetworks.cpp
index 091d942..d103f9f 100644
--- a/runtime/NeuralNetworks.cpp
+++ b/runtime/NeuralNetworks.cpp
@@ -701,6 +701,28 @@
delete r;
}
+int ANeuralNetworksExecution_getOutputOperandRank(ANeuralNetworksExecution* execution,
+ int32_t index, uint32_t* rank) {
+ NNTRACE_RT(NNTRACE_PHASE_EXECUTION, "ANeuralNetworksExecution_getOutputOperandRank");
+ if (!execution || !rank) {
+ LOG(ERROR) << "ANeuralNetworksExecution_getOutputOperandRank passed a nullptr";
+ return ANEURALNETWORKS_UNEXPECTED_NULL;
+ }
+ ExecutionBuilder* r = reinterpret_cast<ExecutionBuilder*>(execution);
+ return r->getOutputOperandRank(index, rank);
+}
+
+int ANeuralNetworksExecution_getOutputOperandDimensions(ANeuralNetworksExecution* execution,
+ int32_t index, uint32_t* dimensions) {
+ NNTRACE_RT(NNTRACE_PHASE_EXECUTION, "ANeuralNetworksExecution_getOutputOperandDimensions");
+ if (!execution || !dimensions) {
+ LOG(ERROR) << "ANeuralNetworksExecution_getOutputOperandDimensions passed a nullptr";
+ return ANEURALNETWORKS_UNEXPECTED_NULL;
+ }
+ ExecutionBuilder* r = reinterpret_cast<ExecutionBuilder*>(execution);
+ return r->getOutputOperandDimensions(index, dimensions);
+}
+
int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution* execution, int32_t index,
const ANeuralNetworksOperandType* type, const void* buffer,
size_t length) {