summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestNeuralNetworksWrapper.h
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2019-12-23 16:18:11 -0800
committerMiao Wang <miaowang@google.com>2020-01-22 12:25:47 -0800
commit688992b3e241dd8936d63c6a21977bfc6b6f0773 (patch)
treee74dc38ae874002c519bd1f075c55cdc2af063d3 /nn/runtime/test/TestNeuralNetworksWrapper.h
parent991050faa2101656eca61c3acf0c98f8aa8cf106 (diff)
downloadml-688992b3e241dd8936d63c6a21977bfc6b6f0773.tar.gz
Add tests for sync fence related API.
The following tests are added: - basic validation tests - generated tests for ANeuralNetworksExecution_startComputeWithDependencies. Bug: 142778241 Test: mm Change-Id: I5591db4583e8b752868d06e16874780800d4410e
Diffstat (limited to 'nn/runtime/test/TestNeuralNetworksWrapper.h')
-rw-r--r--nn/runtime/test/TestNeuralNetworksWrapper.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/nn/runtime/test/TestNeuralNetworksWrapper.h b/nn/runtime/test/TestNeuralNetworksWrapper.h
index 05e68ace2..3111d148b 100644
--- a/nn/runtime/test/TestNeuralNetworksWrapper.h
+++ b/nn/runtime/test/TestNeuralNetworksWrapper.h
@@ -376,6 +376,18 @@ class Execution {
ANeuralNetworksBurst_free(burst);
return result;
}
+ case ComputeMode::FENCED: {
+ ANeuralNetworksEvent* event = nullptr;
+ Result result =
+ static_cast<Result>(ANeuralNetworksExecution_startComputeWithDependencies(
+ mExecution, nullptr, 0, &event));
+ if (result != Result::NO_ERROR) {
+ return result;
+ }
+ result = static_cast<Result>(ANeuralNetworksEvent_wait(event));
+ ANeuralNetworksEvent_free(event);
+ return result;
+ }
}
return Result::BAD_DATA;
}
@@ -386,7 +398,7 @@ class Execution {
// or
// - use the burst API
// Returns the previous ComputeMode.
- enum class ComputeMode { SYNC, ASYNC, BURST };
+ enum class ComputeMode { SYNC, ASYNC, BURST, FENCED };
static ComputeMode setComputeMode(ComputeMode mode) {
ComputeMode oldComputeMode = mComputeMode;
mComputeMode = mode;
@@ -407,6 +419,8 @@ class Execution {
return result;
}
+ ANeuralNetworksExecution* getHandle() { return mExecution; };
+
private:
ANeuralNetworksCompilation* mCompilation = nullptr;
ANeuralNetworksExecution* mExecution = nullptr;