diff --git a/neuralnetworks/1.1/IDevice.hal b/neuralnetworks/1.1/IDevice.hal index 9d3fc312a6..ca225554d5 100644 --- a/neuralnetworks/1.1/IDevice.hal +++ b/neuralnetworks/1.1/IDevice.hal @@ -24,6 +24,20 @@ import @1.0::IPreparedModelCallback; * This interface represents a device driver. */ interface IDevice extends @1.0::IDevice { + /** + * Gets the capabilities of a driver. + * + * Note that @1.1::Capabilities provides performance information + * on relaxed calculations, whereas @1.0::Capabilities does not. + * + * @return status Error status of the call, must be: + * - NONE if successful + * - DEVICE_UNAVAILABLE if driver is offline or busy + * - GENERAL_FAILURE if there is an unspecified error + * @return capabilities Capabilities of the driver. + */ + getCapabilities_1_1() generates (ErrorStatus status, Capabilities capabilities); + /** * Gets the supported operations in a model. * diff --git a/neuralnetworks/1.1/types.hal b/neuralnetworks/1.1/types.hal index fae5dd0caa..1d470d636f 100644 --- a/neuralnetworks/1.1/types.hal +++ b/neuralnetworks/1.1/types.hal @@ -18,6 +18,7 @@ package android.hardware.neuralnetworks@1.1; import @1.0::Operand; import @1.0::OperationType; +import @1.0::PerformanceInfo; /** * Operation types. @@ -258,6 +259,28 @@ enum OperationType : @1.0::OperationType { TRANSPOSE = 37, }; +/** + * The capabilities of a driver. + */ +struct Capabilities { + /** + * Driver performance when operating on float32 data. + */ + PerformanceInfo float32Performance; + + /** + * Driver performance when operating on asymmetric 8-bit quantized data. + */ + PerformanceInfo quantized8Performance; + + /** + * Driver performance when operating on float32 data but performing + * calculations with range and/or precision as low as that of the IEEE + * 754 16-bit floating-point format. + */ + PerformanceInfo relaxedFloat32toFloat16Performance; +}; + /** * Describes one operation of the model's graph. */ diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp index 51eff2a019..d2e99a7064 100644 --- a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp +++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp @@ -29,7 +29,6 @@ #include using ::android::hardware::neuralnetworks::V1_0::IPreparedModel; -using ::android::hardware::neuralnetworks::V1_0::Capabilities; using ::android::hardware::neuralnetworks::V1_0::DeviceStatus; using ::android::hardware::neuralnetworks::V1_0::ErrorStatus; using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc; @@ -37,6 +36,7 @@ using ::android::hardware::neuralnetworks::V1_0::Operand; using ::android::hardware::neuralnetworks::V1_0::OperandLifeTime; using ::android::hardware::neuralnetworks::V1_0::OperandType; using ::android::hardware::neuralnetworks::V1_0::Request; +using ::android::hardware::neuralnetworks::V1_1::Capabilities; using ::android::hardware::neuralnetworks::V1_1::IDevice; using ::android::hardware::neuralnetworks::V1_1::Model; using ::android::hardware::neuralnetworks::V1_1::Operation; @@ -95,12 +95,14 @@ TEST_F(NeuralnetworksHidlTest, StatusTest) { // initialization TEST_F(NeuralnetworksHidlTest, GetCapabilitiesTest) { Return ret = - device->getCapabilities([](ErrorStatus status, const Capabilities& capabilities) { + device->getCapabilities_1_1([](ErrorStatus status, const Capabilities& capabilities) { EXPECT_EQ(ErrorStatus::NONE, status); EXPECT_LT(0.0f, capabilities.float32Performance.execTime); EXPECT_LT(0.0f, capabilities.float32Performance.powerUsage); EXPECT_LT(0.0f, capabilities.quantized8Performance.execTime); EXPECT_LT(0.0f, capabilities.quantized8Performance.powerUsage); + EXPECT_LT(0.0f, capabilities.relaxedFloat32toFloat16Performance.execTime); + EXPECT_LT(0.0f, capabilities.relaxedFloat32toFloat16Performance.powerUsage); }); EXPECT_TRUE(ret.isOk()); }