diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2019-02-09 02:18:40 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-02-09 02:18:40 +0000 |
| commit | b683609c98a7e6560c74a694837d6c02f796014c (patch) | |
| tree | e4bfc13b2d16f31c82433fc1bb8cfadff1cf5264 | |
| parent | c5193fce6ccf499a527761351d1fb1e76cd62411 (diff) | |
| parent | 412352b37accb6e8f3684aae162b82e1a6a2d528 (diff) | |
| download | android_hardware_interfaces-b683609c98a7e6560c74a694837d6c02f796014c.tar.gz android_hardware_interfaces-b683609c98a7e6560c74a694837d6c02f796014c.tar.bz2 android_hardware_interfaces-b683609c98a7e6560c74a694837d6c02f796014c.zip | |
Snap for 5180536 from 412352b37accb6e8f3684aae162b82e1a6a2d528 to pi-platform-release
Change-Id: I378cf141149edc38d0e65749085821427b973578
7 files changed, 185 insertions, 62 deletions
diff --git a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp index bb1d26f92..a08a2d62b 100644 --- a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp @@ -661,8 +661,8 @@ static R extract(Return<R> ret) { code; \ } -TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with", - ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount()))) +TEST_IO_STREAM(GetFrameCount, "Check that getting stream frame count does not crash the HAL.", + ASSERT_TRUE(stream->getFrameCount().isOk())) TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with", ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate()))) diff --git a/audio/core/4.0/vts/functional/Android.bp b/audio/core/4.0/vts/functional/Android.bp index 22c5493dd..e3b376ca8 100644 --- a/audio/core/4.0/vts/functional/Android.bp +++ b/audio/core/4.0/vts/functional/Android.bp @@ -29,6 +29,9 @@ cc_test { "libicuuc_stubdata", "libxml2", ], + shared_libs: [ + "libfmq", + ], header_libs: [ "android.hardware.audio.common.util@all-versions", ], diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp index 0f8996fc5..46c228a19 100644 --- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp @@ -29,6 +29,8 @@ #include <fcntl.h> #include <unistd.h> +#include <hwbinder/IPCThreadState.h> + #include <VtsHalHidlTargetTestBase.h> #include <android-base/logging.h> @@ -38,6 +40,8 @@ #include <android/hardware/audio/4.0/IPrimaryDevice.h> #include <android/hardware/audio/4.0/types.h> #include <android/hardware/audio/common/4.0/types.h> +#include <fmq/EventFlag.h> +#include <fmq/MessageQueue.h> #include <common/all-versions/VersionUtils.h> @@ -55,13 +59,17 @@ using std::vector; using std::list; using ::android::sp; -using ::android::hardware::Return; +using ::android::hardware::EventFlag; using ::android::hardware::hidl_bitfield; using ::android::hardware::hidl_enum_iterator; using ::android::hardware::hidl_handle; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; +using ::android::hardware::kSynchronizedReadWrite; +using ::android::hardware::IPCThreadState; +using ::android::hardware::MessageQueue; using ::android::hardware::MQDescriptorSync; +using ::android::hardware::Return; using ::android::hardware::audio::V4_0::AudioDrain; using ::android::hardware::audio::V4_0::DeviceAddress; using ::android::hardware::audio::V4_0::IDevice; @@ -71,6 +79,7 @@ using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode; using ::android::hardware::audio::V4_0::IDevicesFactory; using ::android::hardware::audio::V4_0::IStream; using ::android::hardware::audio::V4_0::IStreamIn; +using ::android::hardware::audio::V4_0::MessageQueueFlagBits; using ::android::hardware::audio::V4_0::TimeSpec; using ReadParameters = ::android::hardware::audio::V4_0::IStreamIn::ReadParameters; using ReadStatus = ::android::hardware::audio::V4_0::IStreamIn::ReadStatus; @@ -164,15 +173,25 @@ TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) { TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { doc::test("Calling openDevice(\"primary\") should return the primary device."); - Result result; - sp<IDevice> baseDevice; - ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice))); - ASSERT_OK(result); - ASSERT_TRUE(baseDevice != nullptr); - - Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice); - ASSERT_TRUE(primaryDevice.isOk()); - ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr); + { + Result result; + sp<IDevice> baseDevice; + ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice))); + ASSERT_OK(result); + ASSERT_TRUE(baseDevice != nullptr); + + Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice); + ASSERT_TRUE(primaryDevice.isOk()); + ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr); + } // Destroy local IDevice proxy + // FIXME: there is no way to know when the remote IDevice is being destroyed + // Binder does not support testing if an object is alive, thus + // wait for 100ms to let the binder destruction propagates and + // the remote device has the time to be destroyed. + // flushCommand makes sure all local command are sent, thus should reduce + // the latency between local and remote destruction. + IPCThreadState::self()->flushCommands(); + usleep(100); } ////////////////////////////////////////////////////////////////////////////// @@ -489,7 +508,7 @@ TEST_F(AudioPrimaryHidlTest, getParameters) { } ////////////////////////////////////////////////////////////////////////////// -/////////////////////////////// getMicrophones /////////////////////////////// +/////////////////////////// get(Active)Microphones /////////////////////////// ////////////////////////////////////////////////////////////////////////////// TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) { @@ -497,6 +516,76 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) { hidl_vec<MicrophoneInfo> microphones; ASSERT_OK(device->getMicrophones(returnIn(res, microphones))); ASSERT_OK(res); + if (microphones.size() > 0) { + // When there is microphone on the phone, try to open an input stream + // and query for the active microphones. + doc::test( + "Make sure getMicrophones always succeeds" + "and getActiveMicrophones always succeeds when recording from these microphones."); + AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE; + AudioConfig config{}; + config.channelMask = mkBitfield(AudioChannelMask::IN_MONO); + config.sampleRateHz = 8000; + config.format = AudioFormat::PCM_16_BIT; + auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE); + const SinkMetadata initialMetadata = {{{AudioSource::MIC, 1 /* gain */}}}; + EventFlag* efGroup; + for (auto microphone : microphones) { + if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) { + continue; + } + sp<IStreamIn> stream; + AudioConfig suggestedConfig{}; + ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags, + initialMetadata, + returnIn(res, stream, suggestedConfig))); + if (res != Result::OK) { + ASSERT_TRUE(stream == nullptr); + AudioConfig suggestedConfigRetry{}; + ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, + suggestedConfig, flags, initialMetadata, + returnIn(res, stream, suggestedConfigRetry))); + } + ASSERT_OK(res); + hidl_vec<MicrophoneInfo> activeMicrophones; + Result readRes; + typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ; + typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ; + std::unique_ptr<CommandMQ> commandMQ; + std::unique_ptr<DataMQ> dataMQ; + size_t frameSize = stream->getFrameSize(); + size_t frameCount = stream->getBufferSize() / frameSize; + ASSERT_OK(stream->prepareForReading( + frameSize, frameCount, [&](auto r, auto& c, auto& d, auto&, auto&) { + readRes = r; + if (readRes == Result::OK) { + commandMQ.reset(new CommandMQ(c)); + dataMQ.reset(new DataMQ(d)); + if (dataMQ->isValid() && dataMQ->getEventFlagWord()) { + EventFlag::createEventFlag(dataMQ->getEventFlagWord(), &efGroup); + } + } + })); + ASSERT_OK(readRes); + ReadParameters params; + params.command = IStreamIn::ReadCommand::READ; + ASSERT_TRUE(commandMQ != nullptr); + ASSERT_TRUE(commandMQ->isValid()); + ASSERT_TRUE(commandMQ->write(¶ms)); + efGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL)); + uint32_t efState = 0; + efGroup->wait(static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY), &efState); + if (efState & static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY)) { + ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones))); + ASSERT_OK(res); + ASSERT_NE(0U, activeMicrophones.size()); + } + stream->close(); + if (efGroup) { + EventFlag::deleteEventFlag(&efGroup); + } + } + } } ////////////////////////////////////////////////////////////////////////////// @@ -734,8 +823,8 @@ static R extract(Return<R> ret) { code; \ } -TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with", - ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount()))) +TEST_IO_STREAM(GetFrameCount, "Check that getting stream frame count does not crash the HAL.", + ASSERT_TRUE(stream->getFrameCount().isOk())) TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with", ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate()))) @@ -1104,14 +1193,6 @@ TEST_P(InputStreamTest, updateSinkMetadata) { ASSERT_OK(stream->updateSinkMetadata(initialMetadata)); } -TEST_P(InputStreamTest, getActiveMicrophones) { - doc::test("Getting active microphones should always succeed"); - hidl_vec<MicrophoneInfo> microphones; - ASSERT_OK(device->getMicrophones(returnIn(res, microphones))); - ASSERT_OK(res); - ASSERT_TRUE(microphones.size() > 0); -} - ////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// StreamOut ////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -1402,6 +1483,7 @@ TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) { "Make sure setBtHfpVolume is either not supported or " "only succeed if volume is in [0,1]"); auto ret = device->setBtHfpVolume(0.0); + ASSERT_TRUE(ret.isOk()); if (ret == Result::NOT_SUPPORTED) { doc::partialTest("setBtHfpVolume is not supported"); return; diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index 439333d9c..71b78f492 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -1172,6 +1172,14 @@ TEST_F(CameraHidlTest, noHal1AfterP) { } ASSERT_GT(firstApiLevel, 0); // first_api_level must exist + // all devices with first API level == 28 and <= 1GB of RAM must set low_ram + // and thus be allowed to continue using HAL1 + if ((firstApiLevel == HAL1_PHASE_OUT_API_LEVEL) && + (property_get_bool("ro.config.low_ram", /*default*/ false))) { + ALOGI("Hal1 allowed for low ram device"); + return; + } + if (firstApiLevel >= HAL1_PHASE_OUT_API_LEVEL) { hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider); for (const auto& name : cameraDeviceNames) { diff --git a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp index c9f840e37..2d901f330 100644 --- a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp @@ -119,6 +119,11 @@ IGnssConfiguration::BlacklistedSource FindStrongFrequentNonGpsSource( struct ComparableBlacklistedSource { IGnssConfiguration::BlacklistedSource id; + ComparableBlacklistedSource() { + id.constellation = GnssConstellationType::UNKNOWN; + id.svid = 0; + } + bool operator<(const ComparableBlacklistedSource& compare) const { return ((id.svid < compare.id.svid) || ((id.svid == compare.id.svid) && (id.constellation < compare.id.constellation))); @@ -191,18 +196,21 @@ IGnssConfiguration::BlacklistedSource FindStrongFrequentNonGpsSource( * 3) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding * GnssStatus does not use those satellites. * 4a & b) Turns off location, and send in empty blacklist. - * 5) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding + * 5a) Restart location, wait for 3 locations, ensuring they are valid, and checks corresponding * GnssStatus does re-use at least the previously strongest satellite + * 5b) Retry a few times, in case GNSS search strategy takes a while to reacquire even the + * formerly strongest satellite */ TEST_F(GnssHalTest, BlacklistIndividualSatellites) { const int kLocationsToAwait = 3; + const int kRetriesToUnBlacklist = 10; StartAndCheckLocations(kLocationsToAwait); // Tolerate 1 less sv status to handle edge cases in reporting. EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait); - ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(), - kLocationsToAwait); + ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)", + (int)list_gnss_sv_status_.size(), kLocationsToAwait, location_called_count_); /* * Identify strongest SV seen at least kLocationsToAwait -1 times @@ -237,13 +245,18 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) { // retry and ensure satellite not used list_gnss_sv_status_.clear(); - location_called_count_ = 0; StartAndCheckLocations(kLocationsToAwait); + // early exit if test is being run with insufficient signal + if (location_called_count_ == 0) { + ALOGE("0 Gnss locations received - ensure sufficient signal and retry"); + } + ASSERT_TRUE(location_called_count_ > 0); + // Tolerate 1 less sv status to handle edge cases in reporting. EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait); - ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(), - kLocationsToAwait); + ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)", + (int)list_gnss_sv_status_.size(), kLocationsToAwait, location_called_count_); for (const auto& gnss_sv_status : list_gnss_sv_status_) { for (uint32_t iSv = 0; iSv < gnss_sv_status.numSvs; iSv++) { const auto& gnss_sv = gnss_sv_status.gnssSvList[iSv]; @@ -260,28 +273,40 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) { ASSERT_TRUE(result.isOk()); EXPECT_TRUE(result); - StopAndClearLocations(); - list_gnss_sv_status_.clear(); + bool strongest_sv_is_reobserved = false; + // do several loops awaiting a few locations, allowing non-immediate reacquisition strategies + int unblacklist_loops_remaining = kRetriesToUnBlacklist; + while (!strongest_sv_is_reobserved && (unblacklist_loops_remaining-- > 0)) { + StopAndClearLocations(); + list_gnss_sv_status_.clear(); - StartAndCheckLocations(kLocationsToAwait); + StartAndCheckLocations(kLocationsToAwait); - // Tolerate 1 less sv status to handle edge cases in reporting. - EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait); - ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(), - kLocationsToAwait); - - bool strongest_sv_is_reobserved = false; - for (const auto& gnss_sv_status : list_gnss_sv_status_) { - for (uint32_t iSv = 0; iSv < gnss_sv_status.numSvs; iSv++) { - const auto& gnss_sv = gnss_sv_status.gnssSvList[iSv]; - if ((gnss_sv.svid == source_to_blacklist.svid) && - (gnss_sv.constellation == source_to_blacklist.constellation) && - (gnss_sv.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX)) { - strongest_sv_is_reobserved = true; - break; + // early exit loop if test is being run with insufficient signal + if (location_called_count_ == 0) { + ALOGE("0 Gnss locations received - ensure sufficient signal and retry"); + } + ASSERT_TRUE(location_called_count_ > 0); + + // Tolerate 1 less sv status to handle edge cases in reporting. + EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait); + ALOGD( + "Clear blacklist, observed %d GnssSvStatus, while awaiting %d Locations" + ", tries remaining %d", + (int)list_gnss_sv_status_.size(), kLocationsToAwait, unblacklist_loops_remaining); + + for (const auto& gnss_sv_status : list_gnss_sv_status_) { + for (uint32_t iSv = 0; iSv < gnss_sv_status.numSvs; iSv++) { + const auto& gnss_sv = gnss_sv_status.gnssSvList[iSv]; + if ((gnss_sv.svid == source_to_blacklist.svid) && + (gnss_sv.constellation == source_to_blacklist.constellation) && + (gnss_sv.svFlag & IGnssCallback::GnssSvFlags::USED_IN_FIX)) { + strongest_sv_is_reobserved = true; + break; + } } + if (strongest_sv_is_reobserved) break; } - if (strongest_sv_is_reobserved) break; } EXPECT_TRUE(strongest_sv_is_reobserved); StopAndClearLocations(); @@ -304,8 +329,8 @@ TEST_F(GnssHalTest, BlacklistConstellation) { // Tolerate 1 less sv status to handle edge cases in reporting. EXPECT_GE((int)list_gnss_sv_status_.size() + 1, kLocationsToAwait); - ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations", (int)list_gnss_sv_status_.size(), - kLocationsToAwait); + ALOGD("Observed %d GnssSvStatus, while awaiting %d Locations (%d received)", + (int)list_gnss_sv_status_.size(), kLocationsToAwait, location_called_count_); // Find first non-GPS constellation to blacklist GnssConstellationType constellation_to_blacklist = GnssConstellationType::UNKNOWN; diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp index 23bf5583b..951e874e9 100644 --- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp +++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp @@ -18,11 +18,11 @@ #include <VtsHalHidlTargetTestBase.h> #include <android-base/logging.h> -#include <android/hardware/graphics/mapper/2.1/IMapper.h> +#include <android/hardware/graphics/mapper/2.0/IMapper.h> #include <composer-vts/2.1/GraphicsComposerCallback.h> #include <composer-vts/2.1/TestCommandReader.h> #include <composer-vts/2.2/ComposerVts.h> -#include <mapper-vts/2.1/MapperVts.h> +#include <mapper-vts/2.0/MapperVts.h> namespace android { namespace hardware { @@ -40,8 +40,8 @@ using android::hardware::graphics::common::V1_1::Dataspace; using android::hardware::graphics::common::V1_1::PixelFormat; using android::hardware::graphics::common::V1_1::RenderIntent; using android::hardware::graphics::composer::V2_2::IComposerClient; -using android::hardware::graphics::mapper::V2_1::IMapper; -using android::hardware::graphics::mapper::V2_1::vts::Gralloc; +using android::hardware::graphics::mapper::V2_0::IMapper; +using android::hardware::graphics::mapper::V2_0::vts::Gralloc; using GrallocError = android::hardware::graphics::mapper::V2_0::Error; // Test environment for graphics.composer @@ -136,7 +136,7 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest { info.width = 64; info.height = 64; info.layerCount = 1; - info.format = PixelFormat::RGBA_8888; + info.format = static_cast<common::V1_0::PixelFormat>(PixelFormat::RGBA_8888); info.usage = static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN); @@ -280,7 +280,7 @@ TEST_F(GraphicsComposerHidlTest, setReadbackBuffer) { info.height = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config, IComposerClient::Attribute::HEIGHT); info.layerCount = 1; - info.format = pixelFormat; + info.format = static_cast<common::V1_0::PixelFormat>(pixelFormat); // BufferUsage::COMPOSER_OUTPUT is missing info.usage = static_cast<uint64_t>(BufferUsage::COMPOSER_OVERLAY | BufferUsage::CPU_READ_OFTEN); diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp index 0682ab95b..64495cf76 100644 --- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp +++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp @@ -66,8 +66,8 @@ void copy_back(MixedTyped* dst, const std::vector<RequestArgument>& ra, char* sr // Top level driver for models and examples generated by test_generator.py // Test driver for those generated from ml/nn/runtime/test/spec void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool(int)> is_ignored, - const std::vector<MixedTypedExampleType>& examples, - float fpRange = 1e-5f) { + const std::vector<MixedTypedExampleType>& examples, float fpAtol = 1e-5f, + float fpRtol = 1e-5f) { const uint32_t INPUT = 0; const uint32_t OUTPUT = 1; @@ -175,7 +175,7 @@ void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool MixedTyped filtered_test = filter(test, is_ignored); // We want "close-enough" results for float - compare(filtered_golden, filtered_test, fpRange); + compare(filtered_golden, filtered_test, fpAtol, fpRtol); } } @@ -220,7 +220,8 @@ void Execute(const sp<V1_0::IDevice>& device, std::function<V1_0::Model(void)> c EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus); ASSERT_NE(nullptr, preparedModel.get()); - EvaluatePreparedModel(preparedModel, is_ignored, examples); + float fpAtol = 1e-5f, fpRtol = 5.0f * 1.1920928955078125e-7f; + EvaluatePreparedModel(preparedModel, is_ignored, examples, fpAtol, fpRtol); } void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> create_model, @@ -265,9 +266,13 @@ void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> c EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus); ASSERT_NE(nullptr, preparedModel.get()); - // If in relaxed mode, set the error range to be 5ULP of FP16. - float fpRange = !model.relaxComputationFloat32toFloat16 ? 1e-5f : 5.0f * 0.0009765625f; - EvaluatePreparedModel(preparedModel, is_ignored, examples, fpRange); + // TODO: Adjust the error limit based on testing. + // If in relaxed mode, set the absolute tolerance to be 5ULP of FP16. + float fpAtol = !model.relaxComputationFloat32toFloat16 ? 1e-5f : 5.0f * 0.0009765625f; + // Set the relative tolerance to be 5ULP of the corresponding FP precision. + float fpRtol = !model.relaxComputationFloat32toFloat16 ? 5.0f * 1.1920928955078125e-7f + : 5.0f * 0.0009765625f; + EvaluatePreparedModel(preparedModel, is_ignored, examples, fpAtol, fpRtol); } } // namespace generated_tests |
