Merge "Add Capabilities::relaxedFloat32toFloat16Performance for 1.1."

This commit is contained in:
David Gross
2018-02-26 19:27:13 +00:00
committed by Android (Google) Code Review
3 changed files with 41 additions and 2 deletions

View File

@@ -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.
*

View File

@@ -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.
*/

View File

@@ -29,7 +29,6 @@
#include <hidlmemory/mapping.h>
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<void> 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());
}