diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 09:35:43 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 09:35:43 +0000 |
commit | d909394181fd40369dddcf35b5e35f61e6baff42 (patch) | |
tree | 4f38cdbacb54a515da07941c0aae50d8aa398172 | |
parent | 0526ee3cceab1f69b5e95491fdae990f4704774c (diff) | |
parent | a68fb57f2037e5925eb0fad49ede637ab04e20e6 (diff) | |
download | NeuralNetworks-aml_tz5_341510010.tar.gz |
Snap for 11224086 from a68fb57f2037e5925eb0fad49ede637ab04e20e6 to mainline-tzdata5-releaseaml_tz5_341510070aml_tz5_341510050aml_tz5_341510010aml_tz5_341510010
Change-Id: Ife213c05a128f210d97b34b786962305c13b7f25
-rw-r--r-- | runtime/Manager.cpp | 4 | ||||
-rw-r--r-- | runtime/test/TestTrivialModel.cpp | 18 | ||||
-rw-r--r-- | shim_and_sl/ShimConverter.cpp | 4 |
3 files changed, 20 insertions, 6 deletions
diff --git a/runtime/Manager.cpp b/runtime/Manager.cpp index 75f62432e..c3fada328 100644 --- a/runtime/Manager.cpp +++ b/runtime/Manager.cpp @@ -91,7 +91,9 @@ Version getRuntimeFeatureLevelVersion() { bool getWhetherPlatformTelemetryIsEnabled() { #if !defined(NN_COMPATIBILITY_LIBRARY_BUILD) && !defined(NN_EXPERIMENTAL_FEATURE) - return getServerTelemetryEnableFlag(); + // b/287186978, force enable telemetry on the platform NNAPI + // return getServerTelemetryEnableFlag(); + return true; #else // !defined(NN_COMPATIBILITY_LIBRARY_BUILD) && !defined(NN_EXPERIMENTAL_FEATURE) return false; #endif // !defined(NN_COMPATIBILITY_LIBRARY_BUILD) && !defined(NN_EXPERIMENTAL_FEATURE) diff --git a/runtime/test/TestTrivialModel.cpp b/runtime/test/TestTrivialModel.cpp index 999a27dfb..9c168dfa8 100644 --- a/runtime/test/TestTrivialModel.cpp +++ b/runtime/test/TestTrivialModel.cpp @@ -37,7 +37,8 @@ class TrivialTest : public ::testing::Test { virtual void SetUp() {} #if defined(__ANDROID__) - void testAddTwoWithHardwareBufferInput(uint64_t additionalAhwbUsage); + void testAddTwoWithHardwareBufferInput(uint64_t additionalAhwbUsage, + bool allowAllocationFailure); #endif const Matrix3x4 matrix1 = {{1.f, 2.f, 3.f, 4.f}, {5.f, 6.f, 7.f, 8.f}, {9.f, 10.f, 11.f, 12.f}}; @@ -133,7 +134,8 @@ TEST_F(TrivialTest, AddTwo) { // Hardware buffers are an Android concept, which aren't necessarily // available on other platforms such as ChromeOS, which also build NNAPI. #if defined(__ANDROID__) -void TrivialTest::testAddTwoWithHardwareBufferInput(uint64_t additionalAhwbUsage) { +void TrivialTest::testAddTwoWithHardwareBufferInput(uint64_t additionalAhwbUsage, + bool allowAllocationFailure) { Model modelAdd2; CreateAddTwoTensorModel(&modelAdd2); @@ -147,7 +149,11 @@ void TrivialTest::testAddTwoWithHardwareBufferInput(uint64_t additionalAhwbUsage .usage = cpuUsage | additionalAhwbUsage, }; AHardwareBuffer* matrix1Buffer = nullptr; - ASSERT_EQ(AHardwareBuffer_allocate(&desc, &matrix1Buffer), 0); + int err = AHardwareBuffer_allocate(&desc, &matrix1Buffer); + if (allowAllocationFailure && err != 0) { + GTEST_SKIP() << "Test skipped: AHardwareBuffer_allocate failed"; + } + ASSERT_EQ(err, 0); auto allocateGuard = android::base::make_scope_guard( [matrix1Buffer]() { AHardwareBuffer_release(matrix1Buffer); }); @@ -194,11 +200,13 @@ void TrivialTest::testAddTwoWithHardwareBufferInput(uint64_t additionalAhwbUsage } TEST_F(TrivialTest, AddTwoWithHardwareBufferInput) { - testAddTwoWithHardwareBufferInput(/* no additional usage */ 0u); + testAddTwoWithHardwareBufferInput(/* no additional usage */ 0u, + /*allowAllocationFailure=*/false); } TEST_F(TrivialTest, AddTwoWithHardwareBufferInputWithGPUUsage) { - testAddTwoWithHardwareBufferInput(AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER); + testAddTwoWithHardwareBufferInput(AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER, + /*allowAllocationFailure=*/true); } #endif diff --git a/shim_and_sl/ShimConverter.cpp b/shim_and_sl/ShimConverter.cpp index ed3cda236..9914af19b 100644 --- a/shim_and_sl/ShimConverter.cpp +++ b/shim_and_sl/ShimConverter.cpp @@ -154,6 +154,10 @@ ANeuralNetworksModel* convertSubgraphFromHAL( break; } case OperandLifeTime::CONSTANT_POOL: { + if (operand.location.poolIndex >= memoryPools.size()) { + *errorStatus = ErrorStatus::INVALID_ARGUMENT; + return nullptr; + } resultModel.setOperandValueFromMemory( i, memoryPools[operand.location.poolIndex].get(), operand.location.offset, operand.location.length); |