diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-17 07:21:57 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-17 07:21:57 +0000 |
commit | eca19e045e53582487709377dade37642116fe95 (patch) | |
tree | 5238f417f6603850a59d82c4275bc5d6cccb3be4 | |
parent | 390542478ff81446d654b226b09b945648d74c88 (diff) | |
parent | f315e6afa7cff2b271a4c4c8f0643d43508f92db (diff) | |
download | ml-oreo-mr1-security-release.tar.gz |
Snap for 4399693 from f315e6afa7cff2b271a4c4c8f0643d43508f92db to oc-mr1-releaseandroid-wear-8.1.0_r1android-vts-8.1_r3android-security-8.1.0_r93android-security-8.1.0_r92android-security-8.1.0_r91android-security-8.1.0_r90android-security-8.1.0_r89android-security-8.1.0_r88android-security-8.1.0_r87android-security-8.1.0_r86android-security-8.1.0_r85android-security-8.1.0_r84android-security-8.1.0_r83android-security-8.1.0_r82android-cts-8.1_r2android-cts-8.1_r1android-8.1.0_r81android-8.1.0_r80android-8.1.0_r79android-8.1.0_r78android-8.1.0_r77android-8.1.0_r76android-8.1.0_r75android-8.1.0_r74android-8.1.0_r73android-8.1.0_r72android-8.1.0_r71android-8.1.0_r70android-8.1.0_r69android-8.1.0_r68android-8.1.0_r66android-8.1.0_r6android-8.1.0_r5android-8.1.0_r4android-8.1.0_r3android-8.1.0_r23android-8.1.0_r19android-8.1.0_r16android-8.1.0_r15android-8.1.0_r12android-8.1.0_r11android-8.1.0_r10android-8.1.0_r1security-oc-mr1-releaseoreo-mr1-wear-releaseoreo-mr1-security-releaseoreo-mr1-s1-releaseoreo-mr1-releaseoreo-mr1-cuttlefish-testingoreo-m4-s1-release
Change-Id: I20fa06c560213d572c7a5f7d5940d43aea4822a6
-rw-r--r-- | nn/runtime/Manager.cpp | 29 | ||||
-rw-r--r-- | nn/runtime/Manager.h | 9 | ||||
-rw-r--r-- | nn/runtime/test/generated/models/conv_3_h3_w2_SAME.model.cpp | 2 | ||||
-rw-r--r-- | nn/runtime/test/generated/models/conv_3_h3_w2_VALID.model.cpp | 2 |
4 files changed, 27 insertions, 15 deletions
diff --git a/nn/runtime/Manager.cpp b/nn/runtime/Manager.cpp index 25ccb21d9..bdf0b1257 100644 --- a/nn/runtime/Manager.cpp +++ b/nn/runtime/Manager.cpp @@ -31,7 +31,7 @@ namespace android { namespace nn { // TODO: handle errors from initialize correctly -void Device::initialize() { +bool Device::initialize() { #ifdef NN_DEBUGGABLE static const char samplePrefix[] = "sample"; @@ -39,16 +39,24 @@ void Device::initialize() { (mName.substr(0, sizeof(samplePrefix) - 1) == samplePrefix) ? getProp("debug.nn.sample.supported") : 0; #endif // NN_DEBUGGABLE - - mInterface->getCapabilities([&](ErrorStatus status, const Capabilities& capabilities) { + bool success = false; + auto ret = mInterface->getCapabilities([&](ErrorStatus status, + const Capabilities& capabilities) { if (status != ErrorStatus::NONE) { LOG(ERROR) << "IDevice::getCapabilities returned the error " << toString(status); + } else { + VLOG(MANAGER) << "Capab " << capabilities.float32Performance.execTime; + VLOG(MANAGER) << "Capab " << capabilities.quantized8Performance.execTime; + mFloat32Performance = capabilities.float32Performance; + mQuantized8Performance = capabilities.quantized8Performance; + success = true; } - VLOG(MANAGER) << "Capab " << capabilities.float32Performance.execTime; - VLOG(MANAGER) << "Capab " << capabilities.quantized8Performance.execTime; - mFloat32Performance = capabilities.float32Performance; - mQuantized8Performance = capabilities.quantized8Performance; }); + if (!ret.isOk()) { + LOG(ERROR) << "IDevice::getCapabilities failed for " << getName() + << ": " << ret.description(); + } + return success; } void Device::getSupportedOperations(const Model& hidlModel, @@ -139,6 +147,13 @@ void DeviceManager::findAvailableDevices() { }); } +void DeviceManager::registerDevice(const char* name, const sp<IDevice>& device) { + auto d = std::make_shared<Device>(name, device); + if (d->initialize()) { + mDevices.push_back(d); + } +} + DeviceManager::DeviceManager() { VLOG(MANAGER) << "DeviceManager::DeviceManager"; findAvailableDevices(); diff --git a/nn/runtime/Manager.h b/nn/runtime/Manager.h index 721e72fe4..12295528a 100644 --- a/nn/runtime/Manager.h +++ b/nn/runtime/Manager.h @@ -34,7 +34,8 @@ public: Device(const std::string& name, const sp<IDevice>& device) : mName(name), mInterface(device) {} sp<IDevice> getInterface() { return mInterface; } const std::string& getName() const { return mName; } - void initialize(); + // Returns true if succesfully initialized. + bool initialize(); void getSupportedOperations(const Model& hidlModel, hidl_vec<bool>* supportedOperations) const; @@ -92,11 +93,7 @@ private: DeviceManager(); // Adds a device for the manager to use. - void registerDevice(const char* name, const sp<IDevice>& device) { - auto d = std::make_shared<Device>(name, device); - mDevices.push_back(d); - d->initialize(); - } + void registerDevice(const char* name, const sp<IDevice>& device); void findAvailableDevices(); diff --git a/nn/runtime/test/generated/models/conv_3_h3_w2_SAME.model.cpp b/nn/runtime/test/generated/models/conv_3_h3_w2_SAME.model.cpp index dec85782d..5424ef003 100644 --- a/nn/runtime/test/generated/models/conv_3_h3_w2_SAME.model.cpp +++ b/nn/runtime/test/generated/models/conv_3_h3_w2_SAME.model.cpp @@ -24,7 +24,7 @@ void CreateModel(Model *model) { model->setOperandValue(b6, b6_init, sizeof(int32_t) * 1); int32_t b7_init[] = {0}; model->setOperandValue(b7, b7_init, sizeof(int32_t) * 1); - float op0_init[] = {-0.966213, -0.579455, -0.684259, 0.738216, 0.184325, 0.0973683, -0.176863, -0.23936, -0.000233404, 0.055546, -0.232658, -0.316404, -0.012904, 0.320705, -0.326657, -0.919674, 0.868081, -0.824608, -0.467474, 0.0278809, 0.563238, 0.386045, -0.270568, -0.941308, -0.779227, -0.261492, -0.774804, -0.79665, 0.22473, -0.414312, 0.685897, -0.327792, 0.77395, -0.714578, -0.972365, 0.0696099, -0.82203, -0.79946, 0.37289, -0.917775, 0.82236, -0.144706, -0.167188, 0.268062, 0.702641, -0.412223, 0.755759, 0.721547, -0.43637, -0.274905, -0.269165, 0.16102, 0.819857, -0.312008}; + static float op0_init[] = {-0.966213, -0.579455, -0.684259, 0.738216, 0.184325, 0.0973683, -0.176863, -0.23936, -0.000233404, 0.055546, -0.232658, -0.316404, -0.012904, 0.320705, -0.326657, -0.919674, 0.868081, -0.824608, -0.467474, 0.0278809, 0.563238, 0.386045, -0.270568, -0.941308, -0.779227, -0.261492, -0.774804, -0.79665, 0.22473, -0.414312, 0.685897, -0.327792, 0.77395, -0.714578, -0.972365, 0.0696099, -0.82203, -0.79946, 0.37289, -0.917775, 0.82236, -0.144706, -0.167188, 0.268062, 0.702641, -0.412223, 0.755759, 0.721547, -0.43637, -0.274905, -0.269165, 0.16102, 0.819857, -0.312008}; model->setOperandValue(op0, op0_init, sizeof(float) * 54); float op1_init[] = {0, 0, 0}; model->setOperandValue(op1, op1_init, sizeof(float) * 3); diff --git a/nn/runtime/test/generated/models/conv_3_h3_w2_VALID.model.cpp b/nn/runtime/test/generated/models/conv_3_h3_w2_VALID.model.cpp index c6cbb0ac4..3ee875265 100644 --- a/nn/runtime/test/generated/models/conv_3_h3_w2_VALID.model.cpp +++ b/nn/runtime/test/generated/models/conv_3_h3_w2_VALID.model.cpp @@ -22,7 +22,7 @@ void CreateModel(Model *model) { model->setOperandValue(b6, b6_init, sizeof(int32_t) * 1); int32_t b7_init[] = {0}; model->setOperandValue(b7, b7_init, sizeof(int32_t) * 1); - float op0_init[] = {-0.966213, -0.579455, -0.684259, 0.738216, 0.184325, 0.0973683, -0.176863, -0.23936, -0.000233404, 0.055546, -0.232658, -0.316404, -0.012904, 0.320705, -0.326657, -0.919674, 0.868081, -0.824608, -0.467474, 0.0278809, 0.563238, 0.386045, -0.270568, -0.941308, -0.779227, -0.261492, -0.774804, -0.79665, 0.22473, -0.414312, 0.685897, -0.327792, 0.77395, -0.714578, -0.972365, 0.0696099, -0.82203, -0.79946, 0.37289, -0.917775, 0.82236, -0.144706, -0.167188, 0.268062, 0.702641, -0.412223, 0.755759, 0.721547, -0.43637, -0.274905, -0.269165, 0.16102, 0.819857, -0.312008}; + static float op0_init[] = {-0.966213, -0.579455, -0.684259, 0.738216, 0.184325, 0.0973683, -0.176863, -0.23936, -0.000233404, 0.055546, -0.232658, -0.316404, -0.012904, 0.320705, -0.326657, -0.919674, 0.868081, -0.824608, -0.467474, 0.0278809, 0.563238, 0.386045, -0.270568, -0.941308, -0.779227, -0.261492, -0.774804, -0.79665, 0.22473, -0.414312, 0.685897, -0.327792, 0.77395, -0.714578, -0.972365, 0.0696099, -0.82203, -0.79946, 0.37289, -0.917775, 0.82236, -0.144706, -0.167188, 0.268062, 0.702641, -0.412223, 0.755759, 0.721547, -0.43637, -0.274905, -0.269165, 0.16102, 0.819857, -0.312008}; model->setOperandValue(op0, op0_init, sizeof(float) * 54); float op1_init[] = {0, 0, 0}; model->setOperandValue(op1, op1_init, sizeof(float) * 3); |