mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "Rename Version::ANDROID_* to kVersionFeatureLevel* -- hal" am: 8f6b82c7a5
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1896056 Change-Id: I698336ca059e99a4967c0612359ee0d5229f479e
This commit is contained in:
@@ -41,7 +41,7 @@ nn::GeneralResult<std::vector<bool>> supportedOperationsCallback(
|
||||
|
||||
// Converts the results of IDevice::prepareModel* to the NN canonical format. On success, this
|
||||
// function returns with a non-null nn::SharedPreparedModel with a feature level of
|
||||
// nn::Version::ANDROID_OC_MR1. On failure, this function returns with the appropriate
|
||||
// nn::kVersionFeatureLevel1. On failure, this function returns with the appropriate
|
||||
// nn::GeneralError.
|
||||
nn::GeneralResult<nn::SharedPreparedModel> prepareModelCallback(
|
||||
ErrorStatus status, const sp<IPreparedModel>& preparedModel);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
namespace android::hardware::neuralnetworks::V1_0::utils {
|
||||
|
||||
const auto kVersion = nn::Version::ANDROID_OC_MR1;
|
||||
constexpr auto kVersion = nn::kVersionFeatureLevel1;
|
||||
|
||||
template <typename Type>
|
||||
nn::Result<void> validate(const Type& halObject) {
|
||||
|
||||
@@ -99,7 +99,7 @@ const std::string& Device::getVersionString() const {
|
||||
}
|
||||
|
||||
nn::Version Device::getFeatureLevel() const {
|
||||
return nn::Version::ANDROID_OC_MR1;
|
||||
return kVersion;
|
||||
}
|
||||
|
||||
nn::DeviceType Device::getType() const {
|
||||
|
||||
@@ -233,7 +233,7 @@ TEST(DeviceTest, getFeatureLevel) {
|
||||
const auto featureLevel = device->getFeatureLevel();
|
||||
|
||||
// verify result
|
||||
EXPECT_EQ(featureLevel, nn::Version::ANDROID_OC_MR1);
|
||||
EXPECT_EQ(featureLevel, nn::kVersionFeatureLevel1);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCachedData) {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace android::hardware::neuralnetworks::V1_1::utils {
|
||||
|
||||
constexpr auto kDefaultExecutionPreference = ExecutionPreference::FAST_SINGLE_ANSWER;
|
||||
const auto kVersion = nn::Version::ANDROID_P;
|
||||
constexpr auto kVersion = nn::kVersionFeatureLevel2;
|
||||
|
||||
template <typename Type>
|
||||
nn::Result<void> validate(const Type& halObject) {
|
||||
|
||||
@@ -99,7 +99,7 @@ const std::string& Device::getVersionString() const {
|
||||
}
|
||||
|
||||
nn::Version Device::getFeatureLevel() const {
|
||||
return nn::Version::ANDROID_P;
|
||||
return kVersion;
|
||||
}
|
||||
|
||||
nn::DeviceType Device::getType() const {
|
||||
|
||||
@@ -243,7 +243,7 @@ TEST(DeviceTest, getFeatureLevel) {
|
||||
const auto featureLevel = device->getFeatureLevel();
|
||||
|
||||
// verify result
|
||||
EXPECT_EQ(featureLevel, nn::Version::ANDROID_P);
|
||||
EXPECT_EQ(featureLevel, nn::kVersionFeatureLevel2);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCachedData) {
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace android::hardware::neuralnetworks::V1_2::utils {
|
||||
|
||||
// Converts the results of IDevice::prepareModel* to the NN canonical format. On success, this
|
||||
// function returns with a non-null nn::SharedPreparedModel with a feature level of
|
||||
// nn::Version::ANDROID_Q. On failure, this function returns with the appropriate nn::GeneralError.
|
||||
// nn::kVersionFeatureLevel3. On failure, this function returns with the appropriate
|
||||
// nn::GeneralError.
|
||||
nn::GeneralResult<nn::SharedPreparedModel> prepareModelCallback(
|
||||
V1_0::ErrorStatus status, const sp<IPreparedModel>& preparedModel);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ using V1_1::utils::kDefaultExecutionPreference;
|
||||
constexpr auto kDefaultMesaureTiming = MeasureTiming::NO;
|
||||
constexpr auto kNoTiming = Timing{.timeOnDevice = std::numeric_limits<uint64_t>::max(),
|
||||
.timeInDriver = std::numeric_limits<uint64_t>::max()};
|
||||
const auto kVersion = nn::Version::ANDROID_Q;
|
||||
constexpr auto kVersion = nn::kVersionFeatureLevel3;
|
||||
|
||||
template <typename Type>
|
||||
nn::Result<void> validate(const Type& halObject) {
|
||||
|
||||
@@ -192,7 +192,7 @@ const std::string& Device::getVersionString() const {
|
||||
}
|
||||
|
||||
nn::Version Device::getFeatureLevel() const {
|
||||
return nn::Version::ANDROID_Q;
|
||||
return kVersion;
|
||||
}
|
||||
|
||||
nn::DeviceType Device::getType() const {
|
||||
|
||||
@@ -483,7 +483,7 @@ TEST(DeviceTest, getFeatureLevel) {
|
||||
const auto featureLevel = device->getFeatureLevel();
|
||||
|
||||
// verify result
|
||||
EXPECT_EQ(featureLevel, nn::Version::ANDROID_Q);
|
||||
EXPECT_EQ(featureLevel, nn::kVersionFeatureLevel3);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCachedData) {
|
||||
|
||||
@@ -47,7 +47,8 @@ nn::GeneralResult<std::vector<bool>> supportedOperationsCallback(
|
||||
|
||||
// Converts the results of IDevice::prepareModel* to the NN canonical format. On success, this
|
||||
// function returns with a non-null nn::SharedPreparedModel with a feature level of
|
||||
// nn::Version::ANDROID_R. On failure, this function returns with the appropriate nn::GeneralError.
|
||||
// nn::kVersionFeatureLevel4. On failure, this function returns with the appropriate
|
||||
// nn::GeneralError.
|
||||
nn::GeneralResult<nn::SharedPreparedModel> prepareModelCallback(
|
||||
ErrorStatus status, const sp<IPreparedModel>& preparedModel);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ using V1_2::utils::kDefaultMesaureTiming;
|
||||
using V1_2::utils::kNoTiming;
|
||||
|
||||
constexpr auto kDefaultPriority = Priority::MEDIUM;
|
||||
const auto kVersion = nn::Version::ANDROID_R;
|
||||
constexpr auto kVersion = nn::kVersionFeatureLevel4;
|
||||
|
||||
template <typename Type>
|
||||
nn::Result<void> validate(const Type& halObject) {
|
||||
|
||||
@@ -143,7 +143,7 @@ const std::string& Device::getVersionString() const {
|
||||
}
|
||||
|
||||
nn::Version Device::getFeatureLevel() const {
|
||||
return nn::Version::ANDROID_R;
|
||||
return kVersion;
|
||||
}
|
||||
|
||||
nn::DeviceType Device::getType() const {
|
||||
|
||||
@@ -505,7 +505,7 @@ TEST(DeviceTest, getFeatureLevel) {
|
||||
const auto featureLevel = device->getFeatureLevel();
|
||||
|
||||
// verify result
|
||||
EXPECT_EQ(featureLevel, nn::Version::ANDROID_R);
|
||||
EXPECT_EQ(featureLevel, nn::kVersionFeatureLevel4);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCachedData) {
|
||||
|
||||
@@ -30,18 +30,18 @@ namespace aidl::android::hardware::neuralnetworks::utils {
|
||||
|
||||
constexpr auto kDefaultPriority = Priority::MEDIUM;
|
||||
|
||||
inline std::optional<nn::Version> aidlVersionToCanonicalVersion(int aidlVersion) {
|
||||
constexpr std::optional<nn::Version> aidlVersionToCanonicalVersion(int aidlVersion) {
|
||||
switch (aidlVersion) {
|
||||
case 1:
|
||||
return nn::Version::ANDROID_S;
|
||||
return nn::kVersionFeatureLevel5;
|
||||
case 2:
|
||||
return nn::Version::FEATURE_LEVEL_6;
|
||||
return nn::kVersionFeatureLevel6;
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
const auto kVersion = aidlVersionToCanonicalVersion(IDevice::version).value();
|
||||
constexpr auto kVersion = aidlVersionToCanonicalVersion(IDevice::version).value();
|
||||
|
||||
template <typename Type>
|
||||
nn::Result<void> validate(const Type& halObject) {
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace {
|
||||
|
||||
// Converts the results of IDevice::prepareModel* to the NN canonical format. On success, this
|
||||
// function returns with a non-null nn::SharedPreparedModel with a feature level of
|
||||
// nn::Version::ANDROID_S. On failure, this function returns with the appropriate nn::GeneralError.
|
||||
// nn::kVersionFeatureLevel5. On failure, this function returns with the appropriate
|
||||
// nn::GeneralError.
|
||||
nn::GeneralResult<nn::SharedPreparedModel> prepareModelCallback(
|
||||
ErrorStatus status, const std::shared_ptr<IPreparedModel>& preparedModel) {
|
||||
HANDLE_STATUS_AIDL(status) << "model preparation failed with " << toString(status);
|
||||
|
||||
@@ -155,7 +155,7 @@ std::string printDeviceTest(const testing::TestParamInfo<nn::Version>& info) {
|
||||
const nn::Version version = info.param;
|
||||
CHECK(!version.runtimeOnlyFeatures);
|
||||
switch (version.level) {
|
||||
case nn::Version::Level::ANDROID_S:
|
||||
case nn::Version::Level::FEATURE_LEVEL_5:
|
||||
return "v1";
|
||||
case nn::Version::Level::FEATURE_LEVEL_6:
|
||||
return "v2";
|
||||
@@ -893,7 +893,7 @@ TEST_P(DeviceTest, allocateDeadObject) {
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(TestDevice, DeviceTest,
|
||||
::testing::Values(nn::Version::ANDROID_S, nn::Version::FEATURE_LEVEL_6),
|
||||
::testing::Values(nn::kVersionFeatureLevel5, nn::kVersionFeatureLevel6),
|
||||
printDeviceTest);
|
||||
|
||||
} // namespace aidl::android::hardware::neuralnetworks::utils
|
||||
|
||||
@@ -53,7 +53,7 @@ SharedMockDevice createConfiguredMockDevice() {
|
||||
// Setup default actions for each relevant call.
|
||||
constexpr auto getName_ret = []() -> const std::string& { return kName; };
|
||||
constexpr auto getVersionString_ret = []() -> const std::string& { return kVersionString; };
|
||||
const auto kFeatureLevel = nn::Version::ANDROID_OC_MR1;
|
||||
constexpr auto kFeatureLevel = nn::kVersionFeatureLevel1;
|
||||
constexpr auto kDeviceType = nn::DeviceType::ACCELERATOR;
|
||||
constexpr auto getSupportedExtensions_ret = []() -> const std::vector<nn::Extension>& {
|
||||
return kExtensions;
|
||||
@@ -141,7 +141,7 @@ TEST(ResilientDeviceTest, cachedData) {
|
||||
TEST(ResilientDeviceTest, getFeatureLevel) {
|
||||
// setup call
|
||||
const auto [mockDevice, mockDeviceFactory, device] = setup();
|
||||
const auto kFeatureLevel = nn::Version::ANDROID_OC_MR1;
|
||||
constexpr auto kFeatureLevel = nn::kVersionFeatureLevel1;
|
||||
EXPECT_CALL(*mockDevice, getFeatureLevel()).Times(1).WillOnce(Return(kFeatureLevel));
|
||||
|
||||
// run test
|
||||
@@ -591,7 +591,7 @@ TEST(ResilientDeviceTest, recoverCacheMismatchGetFeatureLevel) {
|
||||
const auto recoveredMockDevice = createConfiguredMockDevice();
|
||||
EXPECT_CALL(*recoveredMockDevice, getFeatureLevel())
|
||||
.Times(1)
|
||||
.WillOnce(Return(nn::Version::ANDROID_P));
|
||||
.WillOnce(Return(nn::kVersionFeatureLevel2));
|
||||
EXPECT_CALL(*mockDeviceFactory, Call(false)).Times(1).WillOnce(Return(recoveredMockDevice));
|
||||
|
||||
// run test
|
||||
|
||||
Reference in New Issue
Block a user