mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Add isUpdatable to NNAPI canonical IDevice -- hal
Bug: 177284207 Test: mma Change-Id: I580d5325be91f566ee1c591736a87a94d0a74315
This commit is contained in:
@@ -52,6 +52,7 @@ class Device final : public nn::IDevice {
|
||||
const std::string& getVersionString() const override;
|
||||
nn::Version getFeatureLevel() const override;
|
||||
nn::DeviceType getType() const override;
|
||||
bool isUpdatable() const override;
|
||||
const std::vector<nn::Extension>& getSupportedExtensions() const override;
|
||||
const nn::Capabilities& getCapabilities() const override;
|
||||
std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded() const override;
|
||||
|
||||
@@ -106,6 +106,10 @@ nn::DeviceType Device::getType() const {
|
||||
return nn::DeviceType::OTHER;
|
||||
}
|
||||
|
||||
bool Device::isUpdatable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<nn::Extension>& Device::getSupportedExtensions() const {
|
||||
return kExtensions;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class Device final : public nn::IDevice {
|
||||
const std::string& getVersionString() const override;
|
||||
nn::Version getFeatureLevel() const override;
|
||||
nn::DeviceType getType() const override;
|
||||
bool isUpdatable() const override;
|
||||
const std::vector<nn::Extension>& getSupportedExtensions() const override;
|
||||
const nn::Capabilities& getCapabilities() const override;
|
||||
std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded() const override;
|
||||
|
||||
@@ -106,6 +106,10 @@ nn::DeviceType Device::getType() const {
|
||||
return nn::DeviceType::UNKNOWN;
|
||||
}
|
||||
|
||||
bool Device::isUpdatable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<nn::Extension>& Device::getSupportedExtensions() const {
|
||||
return kExtensions;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ class Device final : public nn::IDevice {
|
||||
const std::string& getVersionString() const override;
|
||||
nn::Version getFeatureLevel() const override;
|
||||
nn::DeviceType getType() const override;
|
||||
bool isUpdatable() const override;
|
||||
const std::vector<nn::Extension>& getSupportedExtensions() const override;
|
||||
const nn::Capabilities& getCapabilities() const override;
|
||||
std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded() const override;
|
||||
|
||||
@@ -199,6 +199,10 @@ nn::DeviceType Device::getType() const {
|
||||
return kDeviceType;
|
||||
}
|
||||
|
||||
bool Device::isUpdatable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<nn::Extension>& Device::getSupportedExtensions() const {
|
||||
return kExtensions;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class Device final : public nn::IDevice {
|
||||
const std::string& getVersionString() const override;
|
||||
nn::Version getFeatureLevel() const override;
|
||||
nn::DeviceType getType() const override;
|
||||
bool isUpdatable() const override;
|
||||
const std::vector<nn::Extension>& getSupportedExtensions() const override;
|
||||
const nn::Capabilities& getCapabilities() const override;
|
||||
std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded() const override;
|
||||
|
||||
@@ -150,6 +150,10 @@ nn::DeviceType Device::getType() const {
|
||||
return kDeviceType;
|
||||
}
|
||||
|
||||
bool Device::isUpdatable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<nn::Extension>& Device::getSupportedExtensions() const {
|
||||
return kExtensions;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace android::hardware::neuralnetworks::utils {
|
||||
class InvalidDevice final : public nn::IDevice {
|
||||
public:
|
||||
InvalidDevice(std::string name, std::string versionString, nn::Version featureLevel,
|
||||
nn::DeviceType type, std::vector<nn::Extension> extensions,
|
||||
nn::DeviceType type, bool isUpdatable, std::vector<nn::Extension> extensions,
|
||||
nn::Capabilities capabilities,
|
||||
std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded);
|
||||
|
||||
@@ -40,6 +40,7 @@ class InvalidDevice final : public nn::IDevice {
|
||||
const std::string& getVersionString() const override;
|
||||
nn::Version getFeatureLevel() const override;
|
||||
nn::DeviceType getType() const override;
|
||||
bool isUpdatable() const override;
|
||||
const std::vector<nn::Extension>& getSupportedExtensions() const override;
|
||||
const nn::Capabilities& getCapabilities() const override;
|
||||
std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded() const override;
|
||||
@@ -70,6 +71,7 @@ class InvalidDevice final : public nn::IDevice {
|
||||
const std::string kVersionString;
|
||||
const nn::Version kFeatureLevel;
|
||||
const nn::DeviceType kType;
|
||||
const bool kIsUpdatable;
|
||||
const std::vector<nn::Extension> kExtensions;
|
||||
const nn::Capabilities kCapabilities;
|
||||
const std::pair<uint32_t, uint32_t> kNumberOfCacheFilesNeeded;
|
||||
|
||||
@@ -53,6 +53,7 @@ class ResilientDevice final : public nn::IDevice,
|
||||
const std::string& getVersionString() const override;
|
||||
nn::Version getFeatureLevel() const override;
|
||||
nn::DeviceType getType() const override;
|
||||
bool isUpdatable() const override;
|
||||
const std::vector<nn::Extension>& getSupportedExtensions() const override;
|
||||
const nn::Capabilities& getCapabilities() const override;
|
||||
std::pair<uint32_t, uint32_t> getNumberOfCacheFilesNeeded() const override;
|
||||
|
||||
@@ -32,13 +32,14 @@
|
||||
namespace android::hardware::neuralnetworks::utils {
|
||||
|
||||
InvalidDevice::InvalidDevice(std::string name, std::string versionString, nn::Version featureLevel,
|
||||
nn::DeviceType type, std::vector<nn::Extension> extensions,
|
||||
nn::Capabilities capabilities,
|
||||
nn::DeviceType type, bool isUpdatable,
|
||||
std::vector<nn::Extension> extensions, nn::Capabilities capabilities,
|
||||
std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded)
|
||||
: kName(std::move(name)),
|
||||
kVersionString(std::move(versionString)),
|
||||
kFeatureLevel(featureLevel),
|
||||
kType(type),
|
||||
kIsUpdatable(isUpdatable),
|
||||
kExtensions(std::move(extensions)),
|
||||
kCapabilities(std::move(capabilities)),
|
||||
kNumberOfCacheFilesNeeded(numberOfCacheFilesNeeded) {}
|
||||
@@ -59,6 +60,10 @@ nn::DeviceType InvalidDevice::getType() const {
|
||||
return kType;
|
||||
}
|
||||
|
||||
bool InvalidDevice::isUpdatable() const {
|
||||
return kIsUpdatable;
|
||||
}
|
||||
|
||||
const std::vector<nn::Extension>& InvalidDevice::getSupportedExtensions() const {
|
||||
return kExtensions;
|
||||
}
|
||||
|
||||
@@ -122,12 +122,14 @@ nn::GeneralResult<nn::SharedDevice> ResilientDevice::recover(const nn::IDevice*
|
||||
};
|
||||
if (compare(&IDevice::getName) || compare(&IDevice::getVersionString) ||
|
||||
compare(&IDevice::getFeatureLevel) || compare(&IDevice::getType) ||
|
||||
compare(&IDevice::getSupportedExtensions) || compare(&IDevice::getCapabilities)) {
|
||||
compare(&IDevice::isUpdatable) || compare(&IDevice::getSupportedExtensions) ||
|
||||
compare(&IDevice::getCapabilities)) {
|
||||
LOG(ERROR) << "Recovered device has different metadata than what is cached. Marking "
|
||||
"IDevice object as invalid.";
|
||||
device = std::make_shared<const InvalidDevice>(
|
||||
kName, kVersionString, mDevice->getFeatureLevel(), mDevice->getType(), kExtensions,
|
||||
kCapabilities, mDevice->getNumberOfCacheFilesNeeded());
|
||||
kName, kVersionString, mDevice->getFeatureLevel(), mDevice->getType(),
|
||||
mDevice->isUpdatable(), kExtensions, kCapabilities,
|
||||
mDevice->getNumberOfCacheFilesNeeded());
|
||||
mIsValid = false;
|
||||
}
|
||||
|
||||
@@ -151,6 +153,10 @@ nn::DeviceType ResilientDevice::getType() const {
|
||||
return getDevice()->getType();
|
||||
}
|
||||
|
||||
bool ResilientDevice::isUpdatable() const {
|
||||
return getDevice()->isUpdatable();
|
||||
}
|
||||
|
||||
const std::vector<nn::Extension>& ResilientDevice::getSupportedExtensions() const {
|
||||
return kExtensions;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class MockDevice final : public IDevice {
|
||||
MOCK_METHOD(const std::string&, getVersionString, (), (const, override));
|
||||
MOCK_METHOD(Version, getFeatureLevel, (), (const, override));
|
||||
MOCK_METHOD(DeviceType, getType, (), (const, override));
|
||||
MOCK_METHOD(bool, isUpdatable, (), (const, override));
|
||||
MOCK_METHOD(const std::vector<Extension>&, getSupportedExtensions, (), (const, override));
|
||||
MOCK_METHOD(const Capabilities&, getCapabilities, (), (const, override));
|
||||
MOCK_METHOD((std::pair<uint32_t, uint32_t>), getNumberOfCacheFilesNeeded, (),
|
||||
|
||||
Reference in New Issue
Block a user