diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-08-28 18:23:20 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-08-28 18:23:20 +0000 |
commit | e75e195a6e889d745895f5f2506df97d74b717ce (patch) | |
tree | 04fde78447e33ee4c75f25381ecf2b4a054553f5 | |
parent | 4904fd64aedb9c2ff0b83a76c9678eab408f9140 (diff) | |
parent | ba0b3b2e8454b6e388bd5c7c496f9701c4c25685 (diff) | |
download | ml-e75e195a6e889d745895f5f2506df97d74b717ce.tar.gz |
Merge "nn: fix unneeded static initialisation" am: ba0b3b2e84
Original change: https://android-review.googlesource.com/c/platform/frameworks/ml/+/1407088
Change-Id: I6f08b15ad554e978564104faca3bb2fdd1da9076
-rw-r--r-- | nn/runtime/test/TestMemoryDomain.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/nn/runtime/test/TestMemoryDomain.cpp b/nn/runtime/test/TestMemoryDomain.cpp index 88632f331..c2cf8e852 100644 --- a/nn/runtime/test/TestMemoryDomain.cpp +++ b/nn/runtime/test/TestMemoryDomain.cpp @@ -143,26 +143,24 @@ class TestDriverLatest : public sample_driver::SampleDriver { // +--- SUB ---> temp ---+ // input2 ---+ // -test_wrapper::Model createTestModel() { - test_wrapper::Model model; +void createTestModel(test_wrapper::Model* model) { test_wrapper::OperandType tensorTypeFullySpecified(Type::TENSOR_FLOAT32, {1}); test_wrapper::OperandType tensorTypeDynamicShape(Type::TENSOR_FLOAT32, {0}); test_wrapper::OperandType actType(Type::INT32, {}); - uint32_t input0 = model.addOperand(&tensorTypeFullySpecified); - uint32_t input1 = model.addOperand(&tensorTypeFullySpecified); - uint32_t input2 = model.addOperand(&tensorTypeFullySpecified); - uint32_t temp = model.addOperand(&tensorTypeFullySpecified); - uint32_t output0 = model.addOperand(&tensorTypeFullySpecified); - uint32_t output1 = model.addOperand(&tensorTypeDynamicShape); - uint32_t act = model.addOperand(&actType); + uint32_t input0 = model->addOperand(&tensorTypeFullySpecified); + uint32_t input1 = model->addOperand(&tensorTypeFullySpecified); + uint32_t input2 = model->addOperand(&tensorTypeFullySpecified); + uint32_t temp = model->addOperand(&tensorTypeFullySpecified); + uint32_t output0 = model->addOperand(&tensorTypeFullySpecified); + uint32_t output1 = model->addOperand(&tensorTypeDynamicShape); + uint32_t act = model->addOperand(&actType); int32_t activation = 0; - model.setOperandValue(act, &activation, sizeof(int32_t)); - model.addOperation(ANEURALNETWORKS_ADD, {input0, input1, act}, {output0}); - model.addOperation(ANEURALNETWORKS_SUB, {input1, input2, act}, {temp}); - model.addOperation(ANEURALNETWORKS_MUL, {output0, temp, act}, {output1}); - model.identifyInputsAndOutputs({input0, input1, input2}, {output0, output1}); - EXPECT_EQ(model.finish(), Result::NO_ERROR); - return model; + model->setOperandValue(act, &activation, sizeof(int32_t)); + model->addOperation(ANEURALNETWORKS_ADD, {input0, input1, act}, {output0}); + model->addOperation(ANEURALNETWORKS_SUB, {input1, input2, act}, {temp}); + model->addOperation(ANEURALNETWORKS_MUL, {output0, temp, act}, {output1}); + model->identifyInputsAndOutputs({input0, input1, input2}, {output0, output1}); + EXPECT_EQ(model->finish(), Result::NO_ERROR); } class MemoryDomainTestBase : public ::testing::Test { @@ -172,6 +170,7 @@ class MemoryDomainTestBase : public ::testing::Test { if (DeviceManager::get()->getUseCpuOnly()) { GTEST_SKIP(); } + createTestModel(&mModel); // Clear the device list. DeviceManager::get()->forTest_setDevices({}); } @@ -202,10 +201,10 @@ class MemoryDomainTestBase : public ::testing::Test { [&deviceMap](const std::string& name) { return deviceMap.at(name); }); Result result; std::tie(result, compilation) = - test_wrapper::Compilation::createForDevices(&kModel, devices); + test_wrapper::Compilation::createForDevices(&mModel, devices); EXPECT_EQ(result, Result::NO_ERROR); } else { - compilation = test_wrapper::Compilation(&kModel); + compilation = test_wrapper::Compilation(&mModel); } EXPECT_EQ(compilation.finish(), Result::NO_ERROR); return compilation; @@ -233,11 +232,9 @@ class MemoryDomainTestBase : public ::testing::Test { return {n, test_wrapper::Memory(memory)}; } - static const test_wrapper::Model kModel; + test_wrapper::Model mModel; }; -const test_wrapper::Model MemoryDomainTestBase::kModel = createTestModel(); - // Test memory domain with the following parameters // - If true, use a V1_2 driver, otherwise, use the latest version; // - If true, compile with explicit device list, otherwise, compile in the default way; |