diff options
author | Jean-Luc Brouillet <jeanluc@google.com> | 2017-07-12 01:37:27 -0700 |
---|---|---|
committer | Jean-Luc Brouillet <jeanluc@google.com> | 2017-07-14 13:55:36 -0700 |
commit | 96775128e3bcfdc5be51b62edc50309c83861fe8 (patch) | |
tree | 1ba01d8c4e479fc15930916e9e87d492ce7cde9c /nn/runtime/test/TestMain.cpp | |
parent | 80df68389b6267a9c5ca73d04a046e6bf61d3901 (diff) | |
download | ml-96775128e3bcfdc5be51b62edc50309c83861fe8.tar.gz |
First implementation of the Neural Networks API.
This first version can run a simple query on the CPU either
via the fallback path or through a simulated driver.
This code has many deficiencies: single threaded, not all
validation are done, not going through HIDL, and not
enough unit tests. Expect more changes!
Test: Compiled and ran the unit tests
Change-Id: I9f6a485a2e7207aeb5f91a2904dcb4b7fd8a6f65
Diffstat (limited to 'nn/runtime/test/TestMain.cpp')
-rw-r--r-- | nn/runtime/test/TestMain.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nn/runtime/test/TestMain.cpp b/nn/runtime/test/TestMain.cpp new file mode 100644 index 000000000..e4e14c0ee --- /dev/null +++ b/nn/runtime/test/TestMain.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Manager.h" +#include "NeuralNetworksWrapper.h" +#include "SampleDriver.h" +#include "Utils.h" + +#include <gtest/gtest.h> + +using namespace android::nn::wrapper; + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + + // Test with the CPU default path + int n1 = RUN_ALL_TESTS(); + + // Create our own driver to simulate testing through the HAL. + // A real Android program would not do this. + nnAssert(ANeuralNetworksInitialize() == ANEURALNETWORKS_NO_ERROR); + std::shared_ptr<android::nn::SampleDriver> sampleDriver {new android::nn::SampleDriver()}; + android::nn::DriverManager::get()->registerDriver(sampleDriver); + + // Tests a second time. + int n2 = RUN_ALL_TESTS(); + ANeuralNetworksShutdown(); + + return n1 != 0 || n2 != 0;; +} |