mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:23:37 +00:00
Create first version of NNAPI AIDL interface am: bfd12c66e4 am: 6d928349cf
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1556224 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I0389067a1cee50d434783428a79284c75a27c21d
This commit is contained in:
@@ -378,6 +378,13 @@
|
||||
<regex-instance>.*</regex-instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.neuralnetworks</name>
|
||||
<interface>
|
||||
<name>IDevice</name>
|
||||
<regex-instance>.*</regex-instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl" optional="true">
|
||||
<name>android.hardware.nfc</name>
|
||||
<version>1.2</version>
|
||||
|
||||
19
neuralnetworks/aidl/Android.bp
Normal file
19
neuralnetworks/aidl/Android.bp
Normal file
@@ -0,0 +1,19 @@
|
||||
aidl_interface {
|
||||
name: "android.hardware.neuralnetworks",
|
||||
vendor_available: true,
|
||||
srcs: [
|
||||
"android/hardware/neuralnetworks/*.aidl",
|
||||
],
|
||||
stability: "vintf",
|
||||
imports: [
|
||||
"android.hardware.common",
|
||||
],
|
||||
backend: {
|
||||
java: {
|
||||
enabled: false,
|
||||
},
|
||||
cpp: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable BufferDesc {
|
||||
int[] dimensions;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable BufferRole {
|
||||
int modelIndex;
|
||||
int ioIndex;
|
||||
float frequency;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Capabilities {
|
||||
android.hardware.neuralnetworks.PerformanceInfo relaxedFloat32toFloat16PerformanceScalar;
|
||||
android.hardware.neuralnetworks.PerformanceInfo relaxedFloat32toFloat16PerformanceTensor;
|
||||
android.hardware.neuralnetworks.OperandPerformance[] operandPerformance;
|
||||
android.hardware.neuralnetworks.PerformanceInfo ifPerformance;
|
||||
android.hardware.neuralnetworks.PerformanceInfo whilePerformance;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable DataLocation {
|
||||
int poolIndex;
|
||||
long offset;
|
||||
long length;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable DeviceBuffer {
|
||||
android.hardware.neuralnetworks.IBuffer buffer;
|
||||
int token;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum DeviceType {
|
||||
OTHER = 1,
|
||||
CPU = 2,
|
||||
GPU = 3,
|
||||
ACCELERATOR = 4,
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum ErrorStatus {
|
||||
NONE = 0,
|
||||
DEVICE_UNAVAILABLE = 1,
|
||||
GENERAL_FAILURE = 2,
|
||||
OUTPUT_INSUFFICIENT_SIZE = 3,
|
||||
INVALID_ARGUMENT = 4,
|
||||
MISSED_DEADLINE_TRANSIENT = 5,
|
||||
MISSED_DEADLINE_PERSISTENT = 6,
|
||||
RESOURCE_EXHAUSTED_TRANSIENT = 7,
|
||||
RESOURCE_EXHAUSTED_PERSISTENT = 8,
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum ExecutionPreference {
|
||||
LOW_POWER = 0,
|
||||
FAST_SINGLE_ANSWER = 1,
|
||||
SUSTAINED_SPEED = 2,
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable ExecutionResult {
|
||||
boolean outputSufficientSize;
|
||||
android.hardware.neuralnetworks.OutputShape[] outputShapes;
|
||||
android.hardware.neuralnetworks.Timing timing;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Extension {
|
||||
String name;
|
||||
android.hardware.neuralnetworks.ExtensionOperandTypeInformation[] operandTypes;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable ExtensionNameAndPrefix {
|
||||
String name;
|
||||
char prefix;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable ExtensionOperandTypeInformation {
|
||||
char type;
|
||||
boolean isTensor;
|
||||
int byteSize;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum FusedActivationFunc {
|
||||
NONE = 0,
|
||||
RELU = 1,
|
||||
RELU1 = 2,
|
||||
RELU6 = 3,
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
interface IBuffer {
|
||||
void copyFrom(in android.hardware.neuralnetworks.Memory src, in int[] dimensions);
|
||||
void copyTo(in android.hardware.neuralnetworks.Memory dst);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
interface IDevice {
|
||||
android.hardware.neuralnetworks.DeviceBuffer allocate(in android.hardware.neuralnetworks.BufferDesc desc, in android.hardware.neuralnetworks.IPreparedModelParcel[] preparedModels, in android.hardware.neuralnetworks.BufferRole[] inputRoles, in android.hardware.neuralnetworks.BufferRole[] outputRoles);
|
||||
android.hardware.neuralnetworks.Capabilities getCapabilities();
|
||||
android.hardware.neuralnetworks.NumberOfCacheFiles getNumberOfCacheFilesNeeded();
|
||||
android.hardware.neuralnetworks.Extension[] getSupportedExtensions();
|
||||
boolean[] getSupportedOperations(in android.hardware.neuralnetworks.Model model);
|
||||
android.hardware.neuralnetworks.DeviceType getType();
|
||||
String getVersionString();
|
||||
void prepareModel(in android.hardware.neuralnetworks.Model model, in android.hardware.neuralnetworks.ExecutionPreference preference, in android.hardware.neuralnetworks.Priority priority, in long deadline, in ParcelFileDescriptor[] modelCache, in ParcelFileDescriptor[] dataCache, in byte[] token, in android.hardware.neuralnetworks.IPreparedModelCallback callback);
|
||||
void prepareModelFromCache(in long deadline, in ParcelFileDescriptor[] modelCache, in ParcelFileDescriptor[] dataCache, in byte[] token, in android.hardware.neuralnetworks.IPreparedModelCallback callback);
|
||||
const int BYTE_SIZE_OF_CACHE_TOKEN = 32;
|
||||
const int MAX_NUMBER_OF_CACHE_FILES = 32;
|
||||
const int EXTENSION_TYPE_HIGH_BITS_PREFIX = 15;
|
||||
const int EXTENSION_TYPE_LOW_BITS_TYPE = 16;
|
||||
const int OPERAND_TYPE_BASE_MAX = 65535;
|
||||
const int OPERATION_TYPE_BASE_MAX = 65535;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
interface IFencedExecutionCallback {
|
||||
android.hardware.neuralnetworks.ErrorStatus getExecutionInfo(out android.hardware.neuralnetworks.Timing timingLaunched, out android.hardware.neuralnetworks.Timing timingFenced);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
interface IPreparedModel {
|
||||
android.hardware.neuralnetworks.ExecutionResult executeSynchronously(in android.hardware.neuralnetworks.Request request, in boolean measureTiming, in long deadline, in long loopTimeoutDuration);
|
||||
android.hardware.neuralnetworks.IFencedExecutionCallback executeFenced(in android.hardware.neuralnetworks.Request request, in ParcelFileDescriptor[] waitFor, in boolean measureTiming, in long deadline, in long loopTimeoutDuration, in long duration, out @nullable ParcelFileDescriptor syncFence);
|
||||
const long DEFAULT_LOOP_TIMEOUT_DURATION_NS = 2000000000;
|
||||
const long MAXIMUM_LOOP_TIMEOUT_DURATION_NS = 15000000000;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
interface IPreparedModelCallback {
|
||||
void notify(in android.hardware.neuralnetworks.ErrorStatus status, in android.hardware.neuralnetworks.IPreparedModel preparedModel);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable IPreparedModelParcel {
|
||||
android.hardware.neuralnetworks.IPreparedModel preparedModel;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Memory {
|
||||
android.hardware.common.NativeHandle handle;
|
||||
long size;
|
||||
String name;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Model {
|
||||
android.hardware.neuralnetworks.Subgraph main;
|
||||
android.hardware.neuralnetworks.Subgraph[] referenced;
|
||||
byte[] operandValues;
|
||||
android.hardware.neuralnetworks.Memory[] pools;
|
||||
boolean relaxComputationFloat32toFloat16;
|
||||
android.hardware.neuralnetworks.ExtensionNameAndPrefix[] extensionNameToPrefix;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable NumberOfCacheFiles {
|
||||
int numModelCache;
|
||||
int numDataCache;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Operand {
|
||||
android.hardware.neuralnetworks.OperandType type;
|
||||
int[] dimensions;
|
||||
float scale;
|
||||
int zeroPoint;
|
||||
android.hardware.neuralnetworks.OperandLifeTime lifetime;
|
||||
android.hardware.neuralnetworks.DataLocation location;
|
||||
@nullable android.hardware.neuralnetworks.OperandExtraParams extraParams;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
union OperandExtraParams {
|
||||
android.hardware.neuralnetworks.SymmPerChannelQuantParams channelQuant;
|
||||
byte[] extension;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum OperandLifeTime {
|
||||
TEMPORARY_VARIABLE = 0,
|
||||
SUBGRAPH_INPUT = 1,
|
||||
SUBGRAPH_OUTPUT = 2,
|
||||
CONSTANT_COPY = 3,
|
||||
CONSTANT_POOL = 4,
|
||||
NO_VALUE = 5,
|
||||
SUBGRAPH = 6,
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable OperandPerformance {
|
||||
android.hardware.neuralnetworks.OperandType type;
|
||||
android.hardware.neuralnetworks.PerformanceInfo info;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum OperandType {
|
||||
FLOAT32 = 0,
|
||||
INT32 = 1,
|
||||
UINT32 = 2,
|
||||
TENSOR_FLOAT32 = 3,
|
||||
TENSOR_INT32 = 4,
|
||||
TENSOR_QUANT8_ASYMM = 5,
|
||||
BOOL = 6,
|
||||
TENSOR_QUANT16_SYMM = 7,
|
||||
TENSOR_FLOAT16 = 8,
|
||||
TENSOR_BOOL8 = 9,
|
||||
FLOAT16 = 10,
|
||||
TENSOR_QUANT8_SYMM_PER_CHANNEL = 11,
|
||||
TENSOR_QUANT16_ASYMM = 12,
|
||||
TENSOR_QUANT8_SYMM = 13,
|
||||
TENSOR_QUANT8_ASYMM_SIGNED = 14,
|
||||
SUBGRAPH = 15,
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Operation {
|
||||
android.hardware.neuralnetworks.OperationType type;
|
||||
int[] inputs;
|
||||
int[] outputs;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum OperationType {
|
||||
ADD = 0,
|
||||
AVERAGE_POOL_2D = 1,
|
||||
CONCATENATION = 2,
|
||||
CONV_2D = 3,
|
||||
DEPTHWISE_CONV_2D = 4,
|
||||
DEPTH_TO_SPACE = 5,
|
||||
DEQUANTIZE = 6,
|
||||
EMBEDDING_LOOKUP = 7,
|
||||
FLOOR = 8,
|
||||
FULLY_CONNECTED = 9,
|
||||
HASHTABLE_LOOKUP = 10,
|
||||
L2_NORMALIZATION = 11,
|
||||
L2_POOL_2D = 12,
|
||||
LOCAL_RESPONSE_NORMALIZATION = 13,
|
||||
LOGISTIC = 14,
|
||||
LSH_PROJECTION = 15,
|
||||
LSTM = 16,
|
||||
MAX_POOL_2D = 17,
|
||||
MUL = 18,
|
||||
RELU = 19,
|
||||
RELU1 = 20,
|
||||
RELU6 = 21,
|
||||
RESHAPE = 22,
|
||||
RESIZE_BILINEAR = 23,
|
||||
RNN = 24,
|
||||
SOFTMAX = 25,
|
||||
SPACE_TO_DEPTH = 26,
|
||||
SVDF = 27,
|
||||
TANH = 28,
|
||||
BATCH_TO_SPACE_ND = 29,
|
||||
DIV = 30,
|
||||
MEAN = 31,
|
||||
PAD = 32,
|
||||
SPACE_TO_BATCH_ND = 33,
|
||||
SQUEEZE = 34,
|
||||
STRIDED_SLICE = 35,
|
||||
SUB = 36,
|
||||
TRANSPOSE = 37,
|
||||
ABS = 38,
|
||||
ARGMAX = 39,
|
||||
ARGMIN = 40,
|
||||
AXIS_ALIGNED_BBOX_TRANSFORM = 41,
|
||||
BIDIRECTIONAL_SEQUENCE_LSTM = 42,
|
||||
BIDIRECTIONAL_SEQUENCE_RNN = 43,
|
||||
BOX_WITH_NMS_LIMIT = 44,
|
||||
CAST = 45,
|
||||
CHANNEL_SHUFFLE = 46,
|
||||
DETECTION_POSTPROCESSING = 47,
|
||||
EQUAL = 48,
|
||||
EXP = 49,
|
||||
EXPAND_DIMS = 50,
|
||||
GATHER = 51,
|
||||
GENERATE_PROPOSALS = 52,
|
||||
GREATER = 53,
|
||||
GREATER_EQUAL = 54,
|
||||
GROUPED_CONV_2D = 55,
|
||||
HEATMAP_MAX_KEYPOINT = 56,
|
||||
INSTANCE_NORMALIZATION = 57,
|
||||
LESS = 58,
|
||||
LESS_EQUAL = 59,
|
||||
LOG = 60,
|
||||
LOGICAL_AND = 61,
|
||||
LOGICAL_NOT = 62,
|
||||
LOGICAL_OR = 63,
|
||||
LOG_SOFTMAX = 64,
|
||||
MAXIMUM = 65,
|
||||
MINIMUM = 66,
|
||||
NEG = 67,
|
||||
NOT_EQUAL = 68,
|
||||
PAD_V2 = 69,
|
||||
POW = 70,
|
||||
PRELU = 71,
|
||||
QUANTIZE = 72,
|
||||
QUANTIZED_16BIT_LSTM = 73,
|
||||
RANDOM_MULTINOMIAL = 74,
|
||||
REDUCE_ALL = 75,
|
||||
REDUCE_ANY = 76,
|
||||
REDUCE_MAX = 77,
|
||||
REDUCE_MIN = 78,
|
||||
REDUCE_PROD = 79,
|
||||
REDUCE_SUM = 80,
|
||||
ROI_ALIGN = 81,
|
||||
ROI_POOLING = 82,
|
||||
RSQRT = 83,
|
||||
SELECT = 84,
|
||||
SIN = 85,
|
||||
SLICE = 86,
|
||||
SPLIT = 87,
|
||||
SQRT = 88,
|
||||
TILE = 89,
|
||||
TOPK_V2 = 90,
|
||||
TRANSPOSE_CONV_2D = 91,
|
||||
UNIDIRECTIONAL_SEQUENCE_LSTM = 92,
|
||||
UNIDIRECTIONAL_SEQUENCE_RNN = 93,
|
||||
RESIZE_NEAREST_NEIGHBOR = 94,
|
||||
QUANTIZED_LSTM = 95,
|
||||
IF = 96,
|
||||
WHILE = 97,
|
||||
ELU = 98,
|
||||
HARD_SWISH = 99,
|
||||
FILL = 100,
|
||||
RANK = 101,
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable OutputShape {
|
||||
int[] dimensions;
|
||||
boolean isSufficient;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable PerformanceInfo {
|
||||
float execTime;
|
||||
float powerUsage;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum Priority {
|
||||
LOW = 0,
|
||||
MEDIUM = 1,
|
||||
HIGH = 2,
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Request {
|
||||
android.hardware.neuralnetworks.RequestArgument[] inputs;
|
||||
android.hardware.neuralnetworks.RequestArgument[] outputs;
|
||||
android.hardware.neuralnetworks.RequestMemoryPool[] pools;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable RequestArgument {
|
||||
boolean hasNoValue;
|
||||
android.hardware.neuralnetworks.DataLocation location;
|
||||
int[] dimensions;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
union RequestMemoryPool {
|
||||
android.hardware.neuralnetworks.Memory pool;
|
||||
int token;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Subgraph {
|
||||
android.hardware.neuralnetworks.Operand[] operands;
|
||||
android.hardware.neuralnetworks.Operation[] operations;
|
||||
int[] inputIndexes;
|
||||
int[] outputIndexes;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable SymmPerChannelQuantParams {
|
||||
float[] scales;
|
||||
int channelDim;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
||||
// edit this file. It looks like you are doing that because you have modified
|
||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
||||
// from an interface or a field from a parcelable and it broke the build. That
|
||||
// breakage is intended.
|
||||
//
|
||||
// You must not make a backward incompatible changes to the AIDL files built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
@VintfStability
|
||||
parcelable Timing {
|
||||
long timeOnDevice;
|
||||
long timeInDriver;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* A buffer descriptor. Describes the properties of a buffer.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable BufferDesc {
|
||||
/**
|
||||
* Dimensions of the buffer. May have unknown dimensions or rank. A buffer with some number of
|
||||
* unspecified dimensions is represented by setting each unspecified dimension to 0. A buffer
|
||||
* with unspecified rank is represented by providing an empty dimensions vector.
|
||||
*/
|
||||
int[] dimensions;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Describes a role of an input or output to a prepared model.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable BufferRole {
|
||||
/**
|
||||
* The index of the IPreparedModel within the "preparedModel" argument passed in
|
||||
* IDevice::allocate.
|
||||
*/
|
||||
int modelIndex;
|
||||
/**
|
||||
* The index of the input or output operand.
|
||||
*/
|
||||
int ioIndex;
|
||||
/**
|
||||
* A floating-point value within the range (0.0, 1.0]. Describes how likely the buffer is to be
|
||||
* used in the specified role. This is provided as a hint to optimize the case when multiple
|
||||
* roles prefer different buffer locations or data layouts.
|
||||
*/
|
||||
float frequency;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.OperandPerformance;
|
||||
import android.hardware.neuralnetworks.PerformanceInfo;
|
||||
|
||||
/**
|
||||
* The capabilities of a driver.
|
||||
*
|
||||
* This represents performance of non-extension operations.
|
||||
*
|
||||
* Performance of an operation other than {@link OperationType::IF} and {@link OperationType::WHILE}
|
||||
* comes from the type of its first operand.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Capabilities {
|
||||
/**
|
||||
* 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 relaxedFloat32toFloat16PerformanceScalar;
|
||||
PerformanceInfo relaxedFloat32toFloat16PerformanceTensor;
|
||||
/**
|
||||
* Performance by operand type. Must be sorted by OperandType.
|
||||
*
|
||||
* If a particular {@link OperandType} is not present in operandPerformance, its performance is
|
||||
* treated as { .execTime = FLT_MAX, .powerUsage = FLT_MAX }.
|
||||
*
|
||||
* Performance does not apply to {@link OperandType::SUBGRAPH}, and a driver must not report
|
||||
* operand performance for {@link OperandType::SUBGRAPH}.
|
||||
*/
|
||||
OperandPerformance[] operandPerformance;
|
||||
/**
|
||||
* Performance of an {@link OperationType::IF} operation is the sum of
|
||||
* {@link Capabilities::ifPerformance} and the mean of performance for the two branch subgraphs,
|
||||
* where performance for a subgraph is the sum of the performance of all operations within the
|
||||
* subgraph.
|
||||
*/
|
||||
PerformanceInfo ifPerformance;
|
||||
/**
|
||||
* Performance of a {@link OperationType::WHILE} operation is the sum of
|
||||
* {@link Capabilities::whilePerformance}, performance for the condition subgraph and
|
||||
* performance for the body subgraph, where performance for a subgraph is the sum of the
|
||||
* performance of all operations within the subgraph.
|
||||
*/
|
||||
PerformanceInfo whilePerformance;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Describes the location of a data object.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable DataLocation {
|
||||
/**
|
||||
* The index of the memory pool where this location is found.
|
||||
*/
|
||||
int poolIndex;
|
||||
/**
|
||||
* Offset in bytes from the start of the pool.
|
||||
*/
|
||||
long offset;
|
||||
/**
|
||||
* The length of the data in bytes.
|
||||
*/
|
||||
long length;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.IBuffer;
|
||||
|
||||
/**
|
||||
* A type that is used to represent a driver allocated buffer and token that corresponds to it.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable DeviceBuffer {
|
||||
/**
|
||||
* An IBuffer object used to interact with the device allocated buffer.
|
||||
*/
|
||||
IBuffer buffer;
|
||||
/**
|
||||
* A positive token identifying the allocated buffer. The token is provided when referencing the
|
||||
* buffer as one of the memory pools in the request of an execution. The token must not collide
|
||||
* with the tokens of other IBuffer objects that are currently alive in the same driver service.
|
||||
*/
|
||||
int token;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Device types.
|
||||
*
|
||||
* The type of NNAPI device.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum DeviceType {
|
||||
/**
|
||||
* The device does not fall into any category below.
|
||||
*/
|
||||
OTHER = 1,
|
||||
/**
|
||||
* The device runs NNAPI models on single or multi-core CPU.
|
||||
*/
|
||||
CPU = 2,
|
||||
/**
|
||||
* The device can run NNAPI models and also accelerate graphics APIs such as OpenGL ES and
|
||||
* Vulkan.
|
||||
*/
|
||||
GPU = 3,
|
||||
/**
|
||||
* Dedicated accelerator for Machine Learning workloads.
|
||||
*/
|
||||
ACCELERATOR = 4,
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Calls to neural networks AIDL interfaces may return a ServiceSpecificException with the following
|
||||
* error codes.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum ErrorStatus {
|
||||
NONE,
|
||||
DEVICE_UNAVAILABLE,
|
||||
GENERAL_FAILURE,
|
||||
OUTPUT_INSUFFICIENT_SIZE,
|
||||
INVALID_ARGUMENT,
|
||||
/**
|
||||
* Failure because a deadline could not be met for a task, but future deadlines may still be met
|
||||
* for the same task after a short delay.
|
||||
*/
|
||||
MISSED_DEADLINE_TRANSIENT,
|
||||
/**
|
||||
* Failure because a deadline could not be met for a task, and future deadlines will likely also
|
||||
* not be met for the same task even after a short delay.
|
||||
*/
|
||||
MISSED_DEADLINE_PERSISTENT,
|
||||
/**
|
||||
* Failure because of a resource limitation within the driver, but future calls for the same
|
||||
* task may still succeed after a short delay.
|
||||
*/
|
||||
RESOURCE_EXHAUSTED_TRANSIENT,
|
||||
/**
|
||||
* Failure because of a resource limitation within the driver, and future calls for the same
|
||||
* task will likely also fail even after a short delay.
|
||||
*/
|
||||
RESOURCE_EXHAUSTED_PERSISTENT,
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Execution preferences.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum ExecutionPreference {
|
||||
/**
|
||||
* Prefer executing in a way that minimizes battery drain. This is desirable for compilations
|
||||
* that will be executed often.
|
||||
*/
|
||||
LOW_POWER,
|
||||
/**
|
||||
* Prefer returning a single answer as fast as possible, even if this causes more power
|
||||
* consumption.
|
||||
*/
|
||||
FAST_SINGLE_ANSWER,
|
||||
/**
|
||||
* Prefer maximizing the throughput of successive frames, for example when processing successive
|
||||
* frames coming from the camera.
|
||||
*/
|
||||
SUSTAINED_SPEED,
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.ErrorStatus;
|
||||
import android.hardware.neuralnetworks.OutputShape;
|
||||
import android.hardware.neuralnetworks.Timing;
|
||||
|
||||
/**
|
||||
* A result from running a synchronous execution of a prepared model.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable ExecutionResult {
|
||||
/**
|
||||
* A value of "true" indicates that the execution was successful. A value of "false" indicates
|
||||
* the execution failed because at least one output operand buffer was not large enough to store
|
||||
* the corresponding output.
|
||||
*/
|
||||
boolean outputSufficientSize;
|
||||
/**
|
||||
* A list of shape information of model output operands. The index in "outputShapes" corresponds
|
||||
* to the index of the output operand in the Request outputs vector.
|
||||
*/
|
||||
OutputShape[] outputShapes;
|
||||
/**
|
||||
* Duration of execution. Unless measure is true and the execution is successful, all times must
|
||||
* be reported as -1. A driver may choose to report any time as -1, indicating that measurement
|
||||
* is not available.
|
||||
*/
|
||||
Timing timing;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.ExtensionOperandTypeInformation;
|
||||
|
||||
/**
|
||||
* Information about an extension.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Extension {
|
||||
/**
|
||||
* The extension name.
|
||||
*
|
||||
* The name must consist of lowercase latin letters, numbers, periods, and underscore signs. The
|
||||
* name must contain at least one period.
|
||||
*
|
||||
* The name must start with the reverse domain name of the vendor.
|
||||
*
|
||||
* Example: com.google.test_extension
|
||||
*/
|
||||
String name;
|
||||
/**
|
||||
* Information about operand types defined by the extension.
|
||||
*/
|
||||
ExtensionOperandTypeInformation[] operandTypes;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* The mapping between extension names and prefixes of operand and operation type values.
|
||||
*
|
||||
* An operand or operation whose numeric type value is above {@link IDevice::OPERAND_TYPE_BASE_MAX}
|
||||
* or {@link IDevice::OPERATION_TYPE_BASE_MAX} respectively should be interpreted as an extension
|
||||
* operand/operation. The low {@link IDevice::EXTENSION_TYPE_LOW_BITS_TYPE} bits of the value
|
||||
* correspond to the type ID within the extension and the high
|
||||
* {@link IDevice::EXTENSION_TYPE_HIGH_BITS_PREFIX} bits encode the "prefix", which maps uniquely to
|
||||
* the extension name. The sign bit is always 0.
|
||||
*
|
||||
* For example, if a model contains an operation whose value is 0x7AAABBBB and extensionNameToPrefix
|
||||
* contains an entry with prefix=0x7AAA and name="vendor.test.test_extension", then the operation
|
||||
* should be interpreted as the operation 0xBBBB of the extension named vendor.test.test_extension.
|
||||
*
|
||||
* This is a one-to-one correspondence. That is, there must be at most one prefix corresponding to
|
||||
* each extension name and at most one extension name corresponding to each prefix.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable ExtensionNameAndPrefix {
|
||||
/**
|
||||
* The extension name.
|
||||
*
|
||||
* See {@link Extension::name} for the format specification.
|
||||
*/
|
||||
String name;
|
||||
/**
|
||||
* The extension prefix. Only the lowest 15 bits are used, so the value must be less than 32768.
|
||||
*/
|
||||
char prefix;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Information about an extension operand type.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable ExtensionOperandTypeInformation {
|
||||
/**
|
||||
* The extension operand type.
|
||||
*/
|
||||
char type;
|
||||
/**
|
||||
* Indicates whether the extension operand type represents a tensor or a scalar.
|
||||
*/
|
||||
boolean isTensor;
|
||||
/**
|
||||
* The byte size of the operand (if scalar) or of a single element (if tensor).
|
||||
*/
|
||||
int byteSize;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Fused activation function types.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum FusedActivationFunc {
|
||||
NONE,
|
||||
RELU,
|
||||
RELU1,
|
||||
RELU6,
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.Memory;
|
||||
|
||||
/**
|
||||
* This interface represents a device memory buffer.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IBuffer {
|
||||
/**
|
||||
* Sets the content of this buffer from a shared memory region.
|
||||
*
|
||||
* @param src The source shared memory region.
|
||||
* @param dimensions Updated dimensional information. If the dimensions of the IBuffer object
|
||||
* are not fully specified, then the dimensions must be fully specified here.
|
||||
* If the dimensions of the IBuffer object are fully specified, then the
|
||||
* dimensions may be empty here. If dimensions.size() > 0, then all dimensions
|
||||
* must be specified here, and any dimension that was specified in the IBuffer
|
||||
* object must have the same value here.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if provided memory is invalid, or if the dimensions is invalid
|
||||
*/
|
||||
void copyFrom(in Memory src, in int[] dimensions);
|
||||
|
||||
/**
|
||||
* Retrieves the content of this buffer to a shared memory region.
|
||||
*
|
||||
* The IBuffer object must have been initialized before the call to IBuffer::copyTo. For more
|
||||
* information on the state of the IBuffer object, refer to IDevice::allocate.
|
||||
*
|
||||
* @param dst The destination shared memory region.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if the IBuffer object is uninitialized, or there is an unspecified
|
||||
* error
|
||||
* - INVALID_ARGUMENT if provided memory is invalid
|
||||
*/
|
||||
void copyTo(in Memory dst);
|
||||
}
|
||||
431
neuralnetworks/aidl/android/hardware/neuralnetworks/IDevice.aidl
Normal file
431
neuralnetworks/aidl/android/hardware/neuralnetworks/IDevice.aidl
Normal file
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.BufferDesc;
|
||||
import android.hardware.neuralnetworks.BufferRole;
|
||||
import android.hardware.neuralnetworks.Capabilities;
|
||||
import android.hardware.neuralnetworks.DeviceBuffer;
|
||||
import android.hardware.neuralnetworks.DeviceType;
|
||||
import android.hardware.neuralnetworks.ExecutionPreference;
|
||||
import android.hardware.neuralnetworks.Extension;
|
||||
import android.hardware.neuralnetworks.IPreparedModel;
|
||||
import android.hardware.neuralnetworks.IPreparedModelCallback;
|
||||
import android.hardware.neuralnetworks.IPreparedModelParcel;
|
||||
import android.hardware.neuralnetworks.Model;
|
||||
import android.hardware.neuralnetworks.NumberOfCacheFiles;
|
||||
import android.hardware.neuralnetworks.Priority;
|
||||
|
||||
/**
|
||||
* This interface represents a device driver.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IDevice {
|
||||
/**
|
||||
* The byte size of the cache token.
|
||||
*/
|
||||
const int BYTE_SIZE_OF_CACHE_TOKEN = 32;
|
||||
/**
|
||||
* The maximum number of files for each type of cache in compilation caching.
|
||||
*/
|
||||
const int MAX_NUMBER_OF_CACHE_FILES = 32;
|
||||
|
||||
/**
|
||||
* Numeric values of extension operand and operation types have the following structure:
|
||||
* - The sign bit is always 0.
|
||||
* - 15 high bits represent the "prefix", which corresponds uniquely to the extension name.
|
||||
* - 16 low bits represent the type ID within the extension.
|
||||
*/
|
||||
const int EXTENSION_TYPE_HIGH_BITS_PREFIX = 15;
|
||||
const int EXTENSION_TYPE_LOW_BITS_TYPE = 16;
|
||||
/**
|
||||
* OperandType with any value above {@link IDevice::OPERAND_TYPE_BASE_MAX} must be interpreted
|
||||
* as an extension type according to {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
const int OPERAND_TYPE_BASE_MAX = 0xFFFF;
|
||||
/**
|
||||
* OperationType with any value above {@link IDevice::OPERATION_TYPE_BASE_MAX} must be
|
||||
* interpreted as an extension type according to {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
const int OPERATION_TYPE_BASE_MAX = 0xFFFF;
|
||||
|
||||
/**
|
||||
* Allocates a driver-managed buffer with the properties specified by the buffer descriptor as
|
||||
* well as the input and output roles.
|
||||
*
|
||||
* The allocate function must verify its inputs are correct. If there is an error, or if a
|
||||
* certain role or property is not supported by the driver, the allocate function must return a
|
||||
* service specific exception with an appropriate ErrorStatus. If the allocation is successful,
|
||||
* this method must return a DeviceBuffer object with the produced IBuffer and a positive token
|
||||
* identifying the allocated buffer. A successful allocation must accommodate all of the
|
||||
* specified roles and buffer properties.
|
||||
*
|
||||
* The buffer is allocated to an uninitialized state. An uninitialized buffer may only be used
|
||||
* in ways that are specified by outputRoles. A buffer is initialized after it is used as an
|
||||
* output in a successful execution, or after a successful invocation of IBuffer::copyFrom on
|
||||
* the buffer. An initialized buffer may be used according to all roles specified in inputRoles
|
||||
* and outputRoles. A buffer will return to the uninitialized state if it is used as an output
|
||||
* in a failed execution, or after a failed invocation of IBuffer::copyFrom on the buffer.
|
||||
*
|
||||
* The dimensions of the buffer can be deduced from the buffer descriptor as well as the
|
||||
* dimensions of the corresponding model operands of the input and output roles. The dimensions
|
||||
* or rank of the buffer may be unknown at this stage. As such, some driver services may only
|
||||
* create a placeholder and defer the actual allocation until execution time. Note that the same
|
||||
* buffer may be used for different shapes of outputs on different executions. When the buffer
|
||||
* is used as an input, the input shape must be the same as the output shape from the last
|
||||
* execution using this buffer as an output.
|
||||
*
|
||||
* The driver must apply proper validatation upon every usage of the buffer, and must fail the
|
||||
* execution immediately if the usage is illegal.
|
||||
*
|
||||
* @param desc A buffer descriptor specifying the properties of the buffer to allocate.
|
||||
* @param preparedModels A vector of IPreparedModel objects. Must only contain IPreparedModel
|
||||
* objects from the same IDevice as this method is being invoked on.
|
||||
* @param inputRoles A vector of roles with each specifying an input to a prepared model.
|
||||
* @param outputRoles A vector of roles with each specifying an output to a prepared model. Each
|
||||
* role specified in inputRoles and outputRoles must be unique. The
|
||||
* corresponding model operands of the roles must have the same OperandType,
|
||||
* scale, zero point, and ExtraParams. The dimensions of the operands and the
|
||||
* dimensions specified in the buffer descriptor must be compatible with each
|
||||
* other. Two dimensions are incompatible if there is at least one axis that
|
||||
* is fully specified in both but has different values.
|
||||
* @return DeviceBuffer object containing the allocated IBuffer object and a positive token that
|
||||
* can be used to reference the buffer as one of the memory pools.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if a certain buffer property or a certain role is not supported,
|
||||
* or if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if one of the input arguments is invalid
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
*/
|
||||
DeviceBuffer allocate(in BufferDesc desc, in IPreparedModelParcel[] preparedModels,
|
||||
in BufferRole[] inputRoles, in BufferRole[] outputRoles);
|
||||
|
||||
/**
|
||||
* Gets the capabilities of a driver.
|
||||
*
|
||||
* @return Capabilities of the driver.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
*/
|
||||
Capabilities getCapabilities();
|
||||
|
||||
/**
|
||||
* Gets the caching requirements of the driver implementation.
|
||||
*
|
||||
* There are two types of cache file descriptors provided to the driver: model cache and data
|
||||
* cache.
|
||||
*
|
||||
* The data cache is for caching constant data, possibly including preprocessed and transformed
|
||||
* tensor buffers. Any modification to the data cache should have no worse effect than
|
||||
* generating bad output values at execution time.
|
||||
*
|
||||
* The model cache is for caching security-sensitive data such as compiled executable machine
|
||||
* code in the device's native binary format. A modification to the model cache may affect the
|
||||
* driver's execution behavior, and a malicious client could make use of this to execute beyond
|
||||
* the granted permission. Thus, the driver must always check whether the model cache is
|
||||
* corrupted before preparing the model from cache.
|
||||
*
|
||||
* getNumberOfCacheFilesNeeded returns how many of each type of cache files the driver
|
||||
* implementation needs to cache a single prepared model. Returning 0 for both types indicates
|
||||
* compilation caching is not supported by this driver. The driver may still choose not to cache
|
||||
* certain compiled models even if it reports that caching is supported.
|
||||
*
|
||||
* If the device reports that caching is not supported, the user may avoid calling
|
||||
* IDevice::prepareModelFromCache or providing cache file descriptors to
|
||||
* IDevice::prepareModel.
|
||||
*
|
||||
* @return NumberOfCacheFiles structure indicating how many files for model and data cache the
|
||||
* driver needs to cache a single prepared model. It must be less than or equal to
|
||||
* MAX_NUMBER_OF_CACHE_FILES.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
*/
|
||||
NumberOfCacheFiles getNumberOfCacheFilesNeeded();
|
||||
|
||||
/**
|
||||
* Gets information about extensions supported by the driver implementation.
|
||||
*
|
||||
* All extension operations and operands must be fully supported for the extension to appear in
|
||||
* the list of supported extensions.
|
||||
*
|
||||
* @return A list of supported extensions.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
*/
|
||||
Extension[] getSupportedExtensions();
|
||||
|
||||
/**
|
||||
* Gets the supported operations in a model.
|
||||
*
|
||||
* getSupportedOperations indicates which operations of the top-level subgraph are fully
|
||||
* supported by the vendor driver. If an operation may not be supported for any reason,
|
||||
* getSupportedOperations must return false for that operation.
|
||||
*
|
||||
* The {@link OperationType::IF} and {@link OperationType::WHILE} operations may only be fully
|
||||
* supported if the vendor driver fully supports all operations in the referenced subgraphs.
|
||||
*
|
||||
* @param model A model whose operations -- and their corresponding operands -- are to be
|
||||
* verified by the driver.
|
||||
* @return A list of supported operations, where true indicates the operation is supported and
|
||||
* false indicates the operation is not supported. The index of "supported" corresponds with
|
||||
* the index of the operation it is describing in the main subgraph.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if provided model is invalid
|
||||
*/
|
||||
boolean[] getSupportedOperations(in Model model);
|
||||
|
||||
/**
|
||||
* Get the type of a given device.
|
||||
*
|
||||
* The device type can be used to help application developers to distribute Machine Learning
|
||||
* workloads and other workloads such as graphical rendering. E.g., for an app which renders AR
|
||||
* scenes based on real time object detection results, the developer could choose an ACCELERATOR
|
||||
* type device for ML workloads, and reserve GPU for graphical rendering.
|
||||
*
|
||||
* @return The DeviceType of the device. Please note, this is not a bitfield of DeviceTypes.
|
||||
* Each device must only be of a single DeviceType.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if the query resulted in an unspecified error
|
||||
*/
|
||||
DeviceType getType();
|
||||
|
||||
/**
|
||||
* Get the version string of the driver implementation.
|
||||
*
|
||||
* The version string must be a unique token among the set of version strings of drivers of a
|
||||
* specific device. The token identifies the device driver's implementation. The token must not
|
||||
* be confused with the feature level which is solely defined by the interface version. This API
|
||||
* is opaque to the Android framework, but the Android framework may use the information for
|
||||
* debugging or to pass on to NNAPI applications.
|
||||
*
|
||||
* Application developers sometimes have specific requirements to ensure good user experiences,
|
||||
* and they need more information to make intelligent decisions when the Android framework
|
||||
* cannot. For example, combined with the device name and other information, the token can help
|
||||
* NNAPI applications filter devices based on their needs:
|
||||
* - An application demands a certain level of performance, but a specific version of the
|
||||
* driver cannot meet that requirement because of a performance regression.
|
||||
* The application can disallow the driver based on the version provided.
|
||||
* - An application has a minimum precision requirement, but certain versions of
|
||||
* the driver cannot meet that requirement because of bugs or certain optimizations.
|
||||
* The application can filter out versions of these drivers.
|
||||
*
|
||||
* @return The version string of the device implementation. Must have nonzero length.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if the query resulted in an unspecified error
|
||||
*/
|
||||
String getVersionString();
|
||||
|
||||
/**
|
||||
* Asynchronously creates a prepared model for execution and optionally saves it into cache
|
||||
* files.
|
||||
*
|
||||
* prepareModel is used to make any necessary transformations to or alternative representations
|
||||
* to a model for execution, possibly including transformations on the constant data,
|
||||
* optimization on the model's graph, or compilation into the device's native binary format. The
|
||||
* model itself is not changed.
|
||||
*
|
||||
* Optionally, caching information may be provided for the driver to save the prepared model to
|
||||
* cache files for faster model compilation time when the same model preparation is requested in
|
||||
* the future. There are two types of cache file descriptors provided to the driver: model cache
|
||||
* and data cache. For more information on the two types of cache, refer to
|
||||
* getNumberOfCacheFilesNeeded.
|
||||
*
|
||||
* The file descriptors must be opened with read and write permission. A file may have any size,
|
||||
* and the corresponding file descriptor may have any offset. The driver must truncate a file to
|
||||
* zero size before writing to that file. The file descriptors may be closed by the client once
|
||||
* the asynchronous preparation has finished. The driver must dup a file descriptor if it wants
|
||||
* to get access to the cache file later.
|
||||
*
|
||||
* The model is prepared asynchronously with respect to the caller. The prepareModel function
|
||||
* must verify the inputs to the preparedModel function related to preparing the model (as
|
||||
* opposed to saving the prepared model to cache) are correct. If there is an error,
|
||||
* prepareModel must immediately invoke the callback with the appropriate ErrorStatus value and
|
||||
* nullptr for the IPreparedModel, then return a status with a service specific exception with
|
||||
* the same ErrorStatus. If the inputs to the prepareModel function that are related to
|
||||
* preparing the model are valid and there is no error, prepareModel must launch an asynchronous
|
||||
* task to prepare the model in the background, and immediately return from prepareModel. If the
|
||||
* asynchronous task fails to launch, prepareModel must immediately invoke the callback with
|
||||
* ErrorStatus::GENERAL_FAILURE and nullptr for the IPreparedModel, then return a service
|
||||
* specific exception with ErrorStatus::GENERAL_FAILURE.
|
||||
*
|
||||
* When the asynchronous task has finished preparing the model, it must immediately invoke the
|
||||
* callback function provided as an input to prepareModel. If the model was prepared
|
||||
* successfully, the callback object must be invoked with an error status of ErrorStatus::NONE
|
||||
* and the produced IPreparedModel object. If an error occurred preparing the model, the
|
||||
* callback object must be invoked with the appropriate ErrorStatus value and nullptr for the
|
||||
* IPreparedModel.
|
||||
*
|
||||
* The model is prepared with a priority. This priority is relative to other prepared models
|
||||
* owned by the same client. Higher priority executions may use more compute resources than
|
||||
* lower priority executions, and may preempt or starve lower priority executions.
|
||||
*
|
||||
* prepareModel can be called with an optional deadline. If the model is not able to be prepared
|
||||
* before the provided deadline, the model preparation may be aborted, and either
|
||||
* {@link ErrorStatus::MISSED_DEADLINE_TRANSIENT} or {@link
|
||||
* ErrorStatus::MISSED_DEADLINE_PERSISTENT} may be returned. The error due to an abort must be
|
||||
* sent the same way as other errors, described above.
|
||||
*
|
||||
* Optionally, the driver may save the prepared model to cache during the asynchronous
|
||||
* preparation. Any error that occurs when saving to cache must not affect the status of
|
||||
* preparing the model. Even if the input arguments related to the cache may be invalid, or the
|
||||
* driver may fail to save to cache, the prepareModel function must finish preparing the model.
|
||||
* The driver may choose not to save to cache even if the caching information is provided and
|
||||
* valid.
|
||||
*
|
||||
* The only information that may be unknown to the model at this stage is the shape of the
|
||||
* tensors, which may only be known at execution time. As such, some driver services may return
|
||||
* partially prepared models, where the prepared model may only be finished when it is paired
|
||||
* with a set of inputs to the model. Note that the same prepared model object may be used with
|
||||
* different shapes of inputs on different (possibly concurrent) executions.
|
||||
*
|
||||
* Multiple threads may call prepareModel on the same model concurrently.
|
||||
*
|
||||
* @param model The model to be prepared for execution.
|
||||
* @param preference Indicates the intended execution behavior of a prepared model.
|
||||
* @param priority The priority of the prepared model relative to other prepared models owned by
|
||||
* the client.
|
||||
* @param deadline The time by which the model is expected to be prepared. The time is measured
|
||||
* in nanoseconds since epoch of the steady clock (as from
|
||||
* std::chrono::steady_clock). If the model cannot be prepared by the deadline,
|
||||
* the preparation may be aborted. Passing -1 means the deadline is omitted.
|
||||
* Other negative values are invalid.
|
||||
* @param modelCache A vector of file descriptors for the security-sensitive cache. The length
|
||||
* of the vector must either be 0 indicating that caching information is not
|
||||
* provided, or match the numModelCache returned from
|
||||
* getNumberOfCacheFilesNeeded. The cache file descriptors will be provided in
|
||||
* the same order when retrieving the preparedModel from cache files with
|
||||
* prepareModelFromCache.
|
||||
* @param dataCache A vector of file descriptors for the constants' cache. The length of the
|
||||
* vector must either be 0 indicating that caching information is not provided,
|
||||
* or match the numDataCache returned from getNumberOfCacheFilesNeeded. The
|
||||
* cache file descriptors will be provided in the same order when retrieving
|
||||
* the preparedModel from cache files with prepareModelFromCache.
|
||||
* @param token A caching token of length BYTE_SIZE_OF_CACHE_TOKEN identifying the prepared
|
||||
* model. The same token will be provided when retrieving the prepared model from
|
||||
* the cache files with prepareModelFromCache. Tokens should be chosen to have a
|
||||
* low rate of collision for a particular application. The driver cannot detect a
|
||||
* collision; a collision will result in a failed execution or in a successful
|
||||
* execution that produces incorrect output values. If both modelCache and
|
||||
* dataCache are empty indicating that caching information is not provided, this
|
||||
* token must be ignored.
|
||||
* @param callback A callback object used to return the error status of preparing the model for
|
||||
* execution and the prepared model if successful, nullptr otherwise. The
|
||||
* callback object's notify function must be called exactly once, even if the
|
||||
* model could not be prepared.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if one of the input arguments related to preparing the model is
|
||||
* invalid
|
||||
* - MISSED_DEADLINE_* if the preparation is aborted because the model cannot be prepared by
|
||||
* the deadline
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
*/
|
||||
void prepareModel(in Model model, in ExecutionPreference preference, in Priority priority,
|
||||
in long deadline, in ParcelFileDescriptor[] modelCache, in ParcelFileDescriptor[] dataCache,
|
||||
in byte[] token, in IPreparedModelCallback callback);
|
||||
|
||||
/**
|
||||
* Creates a prepared model from cache files for execution.
|
||||
*
|
||||
* prepareModelFromCache is used to retrieve a prepared model directly from cache files to avoid
|
||||
* slow model compilation time. There are two types of cache file descriptors provided to the
|
||||
* driver: model cache and data cache. For more information on the two types of cache files,
|
||||
* refer to getNumberOfCacheFilesNeeded.
|
||||
*
|
||||
* The file descriptors must be opened with read and write permission. A file may have any size,
|
||||
* and the corresponding file descriptor may have any offset. The driver must truncate a file to
|
||||
* zero size before writing to that file. The file descriptors may be closed by the client once
|
||||
* the asynchronous preparation has finished. The driver must dup a file descriptor if it wants
|
||||
* to get access to the cache file later.
|
||||
*
|
||||
* The model is prepared asynchronously with respect to the caller. The prepareModelFromCache
|
||||
* function must verify the inputs to the prepareModelFromCache function are correct, and that
|
||||
* the security-sensitive cache has not been modified since it was last written by the driver.
|
||||
* If there is an error, or if compilation caching is not supported, or if the
|
||||
* security-sensitive cache has been modified, prepareModelFromCache must immediately invoke the
|
||||
* callback with the appropriate ErrorStatus value and nullptr for the IPreparedModel, then
|
||||
* return a status with a service specific exception with the same ErrorStatus. If the inputs to
|
||||
* the prepareModelFromCache function are valid, the security-sensitive cache is not modified,
|
||||
* and there is no error, prepareModelFromCache must launch an asynchronous task to prepare the
|
||||
* model in the background, and immediately return from prepareModelFromCache. If the
|
||||
* asynchronous task fails to launch, prepareModelFromCache must immediately invoke the callback
|
||||
* with ErrorStatus::GENERAL_FAILURE and nullptr for the IPreparedModel, then return a service
|
||||
* specific exception with ErrorStatus::GENERAL_FAILURE.
|
||||
*
|
||||
* When the asynchronous task has finished preparing the model, it must immediately invoke the
|
||||
* callback function provided as an input to prepareModelFromCache. If the model was prepared
|
||||
* successfully, the callback object must be invoked with an error status of ErrorStatus::NONE
|
||||
* and the produced IPreparedModel object. If an error occurred preparing the model, the
|
||||
* callback object must be invoked with the appropriate ErrorStatus value and nullptr for the
|
||||
* IPreparedModel.
|
||||
*
|
||||
* prepareModelFromCache can be called with an optional deadline. If the model is not able to
|
||||
* prepared before the provided deadline, the model preparation may be aborted, and either
|
||||
* {@link ErrorStatus::MISSED_DEADLINE_TRANSIENT} or
|
||||
* {@link ErrorStatus::MISSED_DEADLINE_PERSISTENT} may be returned. The error due to an abort
|
||||
* must be sent the same way as other errors, described above.
|
||||
*
|
||||
* The only information that may be unknown to the model at this stage is the shape of the
|
||||
* tensors, which may only be known at execution time. As such, some driver services may return
|
||||
* partially prepared models, where the prepared model may only be finished when it is paired
|
||||
* with a set of inputs to the model. Note that the same prepared model object may be used with
|
||||
* different shapes of inputs on different (possibly concurrent) executions.
|
||||
*
|
||||
* @param deadline The time by which the model is expected to be prepared. The time is measured
|
||||
* in nanoseconds since epoch of the steady clock (as from
|
||||
* std::chrono::steady_clock). If the model cannot be prepared by the deadline,
|
||||
* the preparation may be aborted. Passing -1 means the deadline is omitted.
|
||||
* Other negative values are invalid.
|
||||
* @param modelCache A vector of file descriptors for the security-sensitive cache. The length
|
||||
* of the vector must match the numModelCache returned from
|
||||
* getNumberOfCacheFilesNeeded. The cache file descriptors will be provided in
|
||||
* the same order as with prepareModel.
|
||||
* @param dataCache A vector of file descriptors for the constants' cache. The length of the
|
||||
* vector must match the numDataCache returned from
|
||||
* getNumberOfCacheFilesNeeded. The cache file descriptors will be provided in
|
||||
* the same order as with prepareModel.
|
||||
* @param token A caching token of length BYTE_SIZE_OF_CACHE_TOKEN identifying the prepared
|
||||
* model. It is the same token provided when saving the cache files with
|
||||
* prepareModel. Tokens should be chosen to have a low rate of collision for a
|
||||
* particular application. The driver cannot detect a collision; a collision will
|
||||
* result in a failed execution or in a successful execution that produces
|
||||
* incorrect output values.
|
||||
* @param callback A callback object used to return the error status of preparing the model for
|
||||
* execution and the prepared model if successful, nullptr otherwise. The
|
||||
* callback object's notify function must be called exactly once, even if the
|
||||
* model could not be prepared.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if caching is not supported or if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if one of the input arguments is invalid
|
||||
* - MISSED_DEADLINE_* if the preparation is aborted because the model cannot be prepared by
|
||||
* the deadline
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
*/
|
||||
void prepareModelFromCache(in long deadline, in ParcelFileDescriptor[] modelCache,
|
||||
in ParcelFileDescriptor[] dataCache, in byte[] token, in IPreparedModelCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.ErrorStatus;
|
||||
import android.hardware.neuralnetworks.Timing;
|
||||
|
||||
/**
|
||||
* IFencedExecutionCallback can be used to query the error status result and duration information
|
||||
* from an IPreparedModel::executeFenced call.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IFencedExecutionCallback {
|
||||
/**
|
||||
* The getExecutionInfo method is used by the clients to query error status result and duration
|
||||
* information. The method must only be called after the actual evaluation has finished or
|
||||
* resulted in an runtime error, as indicated by the status of the sync fence returned by the
|
||||
* IPreparedModel::executeFenced call, otherwise GENERAL_FAILURE must be returned.
|
||||
*
|
||||
* @param out timingLaunched The duration starts when executeFenced is called and ends when
|
||||
* executeFenced signals the returned syncFence. Unless measureTiming
|
||||
* was set to true when launching the execution and status is NONE,
|
||||
* all times must be reported as -1. A driver may choose to report any
|
||||
* time as -1, indicating that particular measurement is not
|
||||
* available.
|
||||
* @param out timingFenced The duration starts when all waitFor sync fences have been signaled
|
||||
* and ends when executeFenced signals the returned syncFence. Unless
|
||||
* measureTiming was set to true when launching the execution and status
|
||||
* is NONE, all times must be reported as -1. A driver may choose to
|
||||
* report any time as -1, indicating that particular measurement is not
|
||||
* available.
|
||||
* @return Error status returned from the asynchronously dispatched execution must be:
|
||||
* - NONE if the asynchronous execution was successful
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if the asynchronous task resulted in an unspecified error
|
||||
* - MISSED_DEADLINE_* if the execution is aborted because it cannot be completed by the
|
||||
* deadline
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
*/
|
||||
ErrorStatus getExecutionInfo(out Timing timingLaunched, out Timing timingFenced);
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.common.NativeHandle;
|
||||
import android.hardware.neuralnetworks.ErrorStatus;
|
||||
import android.hardware.neuralnetworks.ExecutionResult;
|
||||
import android.hardware.neuralnetworks.IFencedExecutionCallback;
|
||||
import android.hardware.neuralnetworks.Request;
|
||||
|
||||
/**
|
||||
* IPreparedModel describes a model that has been prepared for execution and is used to launch
|
||||
* executions.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IPreparedModel {
|
||||
/**
|
||||
* Each {@link OperationType::WHILE} operation in the model has an implicit execution timeout
|
||||
* duration associated with it ("loop timeout duration"). This duration is configurable on a
|
||||
* per-execution basis and must not exceed 15 seconds. The default value is 2 seconds. The units
|
||||
* are nanoseconds.
|
||||
*/
|
||||
const long DEFAULT_LOOP_TIMEOUT_DURATION_NS = 2000000000;
|
||||
const long MAXIMUM_LOOP_TIMEOUT_DURATION_NS = 15000000000;
|
||||
|
||||
/**
|
||||
* Performs a synchronous execution on a prepared model.
|
||||
*
|
||||
* The execution is performed synchronously with respect to the caller. executeSynchronously
|
||||
* must verify the inputs to the function are correct, and the usages of memory pools allocated
|
||||
* by IDevice::allocate are valid. If there is an error, executeSynchronously must immediately
|
||||
* return a service specific exception with the appropriate ErrorStatus value. If the inputs to
|
||||
* the function are valid and there is no error, executeSynchronously must perform the
|
||||
* execution, and must not return until the execution is complete.
|
||||
*
|
||||
* The caller must not change the content of any data object referenced by 'request' (described
|
||||
* by the {@link DataLocation} of a {@link RequestArgument}) until executeSynchronously returns.
|
||||
* executeSynchronously must not change the content of any of the data objects corresponding to
|
||||
* 'request' inputs.
|
||||
*
|
||||
* If the prepared model was prepared from a model wherein all tensor operands have fully
|
||||
* specified dimensions, and the inputs to the function are valid, and at execution time every
|
||||
* operation's input operands have legal values, then the execution should complete
|
||||
* successfully: there must be no failure unless the device itself is in a bad state.
|
||||
*
|
||||
* executeSynchronously may be called with an optional deadline. If the execution is not able to
|
||||
* be completed before the provided deadline, the execution may be aborted, and either
|
||||
* {@link ErrorStatus::MISSED_DEADLINE_TRANSIENT} or {@link
|
||||
* ErrorStatus::MISSED_DEADLINE_PERSISTENT} may be returned. The error due to an abort must be
|
||||
* sent the same way as other errors, described above.
|
||||
*
|
||||
* Any number of calls to the execute* functions, in any combination, may be made concurrently,
|
||||
* even on the same IPreparedModel object.
|
||||
*
|
||||
* @param request The input and output information on which the prepared model is to be
|
||||
* executed.
|
||||
* @param measure Specifies whether or not to measure duration of the execution. The duration
|
||||
* runs from the time the driver sees the call to the executeSynchronously
|
||||
* function to the time the driver returns from the function.
|
||||
* @param deadline The time by which the execution is expected to complete. The time is measured
|
||||
* in nanoseconds since epoch of the steady clock (as from
|
||||
* std::chrono::steady_clock). If the execution cannot be finished by the
|
||||
* deadline, the execution may be aborted. Passing -1 means the deadline is
|
||||
* omitted. Other negative values are invalid.
|
||||
* @param loopTimeoutDuration The maximum amount of time in nanoseconds that should be spent
|
||||
* executing a {@link OperationType::WHILE} operation. If a loop
|
||||
* condition model does not output false within this duration, the
|
||||
* execution must be aborted. If -1 is provided, the maximum amount
|
||||
* of time is {@link DEFAULT_LOOP_TIMEOUT_DURATION_NS}. Other
|
||||
* negative values are invalid. When provided, the duration must not
|
||||
* exceed {@link MAXIMUM_LOOP_TIMEOUT_DURATION_NS}.
|
||||
* @return ExecutionResult parcelable, containing the status of the execution, output shapes and
|
||||
* timing information.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if one of the input arguments is invalid
|
||||
* - MISSED_DEADLINE_* if the execution is aborted because it cannot be completed by the
|
||||
* deadline
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
*/
|
||||
ExecutionResult executeSynchronously(in Request request, in boolean measureTiming,
|
||||
in long deadline, in long loopTimeoutDuration);
|
||||
|
||||
/**
|
||||
* Launch a fenced asynchronous execution on a prepared model.
|
||||
*
|
||||
* The execution is performed asynchronously with respect to the caller. executeFenced must
|
||||
* verify the inputs to the function are correct, and the usages of memory pools allocated by
|
||||
* IDevice::allocate are valid. If there is an error, executeFenced must immediately return a
|
||||
* service specific exception with the corresponding ErrorStatus. If the inputs to the function
|
||||
* are valid and there is no error, executeFenced must dispatch an asynchronous task to perform
|
||||
* the execution in the background, assign a sync fence that will be signaled once the execution
|
||||
* is completed and immediately return a callback that can be used by the client to query the
|
||||
* duration and runtime error status. If the task has finished before the call returns,
|
||||
* syncFence file descriptor may be set to -1. The execution must wait for all the sync fences
|
||||
* (if any) in waitFor to be signaled before starting the actual execution.
|
||||
*
|
||||
* When the asynchronous task has finished its execution, it must immediately signal the
|
||||
* syncFence returned from the executeFenced call. After the syncFence is signaled, the task
|
||||
* must not modify the content of any data object referenced by 'request' (described by the
|
||||
* {@link DataLocation} of a {@link RequestArgument}).
|
||||
*
|
||||
* executeFenced may be called with an optional deadline and an optional duration. If the
|
||||
* execution is not able to be completed before the provided deadline or within the timeout
|
||||
* duration (measured from when all sync fences in waitFor are signaled), whichever comes
|
||||
* earlier, the execution may be aborted, and either
|
||||
* {@link ErrorStatus::MISSED_DEADLINE_TRANSIENT} or {@link
|
||||
* ErrorStatus::MISSED_DEADLINE_PERSISTENT} may be returned. The error due to an abort must be
|
||||
* sent the same way as other errors, described above.
|
||||
*
|
||||
* If any of the sync fences in waitFor changes to error status after the executeFenced call
|
||||
* succeeds, or the execution is aborted because it cannot finish before the deadline has been
|
||||
* reached or the duration has elapsed, the driver must immediately set the returned syncFence
|
||||
* to error status.
|
||||
*
|
||||
* Any number of calls to the execute* functions, in any combination, may be made concurrently,
|
||||
* even on the same IPreparedModel object.
|
||||
*
|
||||
* @param request The input and output information on which the prepared model is to be
|
||||
* executed. The outputs in the request must have fully specified dimensions.
|
||||
* @param waitFor A vector of sync fence file descriptors. Execution must not start until all
|
||||
* sync fences have been signaled.
|
||||
* @param measure Specifies whether or not to measure duration of the execution.
|
||||
* @param deadline The time by which the execution is expected to complete. The time is measured
|
||||
* in nanoseconds since epoch of the steady clock (as from
|
||||
* std::chrono::steady_clock).If the execution cannot be finished by the
|
||||
* deadline, the execution may be aborted. Passing -1 means the deadline is
|
||||
* omitted. Other negative values are invalid.
|
||||
* @param loopTimeoutDuration The maximum amount of time in nanoseconds that should be spent
|
||||
* executing a {@link OperationType::WHILE} operation. If a loop
|
||||
* condition model does not output false within this duration, the
|
||||
* execution must be aborted. If -1 is provided, the maximum amount
|
||||
* of time is {@link DEFAULT_LOOP_TIMEOUT_DURATION_NS}. Other
|
||||
* negative values are invalid. When provided, the duration must not
|
||||
* exceed {@link MAXIMUM_LOOP_TIMEOUT_DURATION_NS}.
|
||||
* @param duration The length of time in nanoseconds within which the execution is expected to
|
||||
* complete after all sync fences in waitFor are signaled. If the execution
|
||||
* cannot be finished within the duration, the execution may be aborted. Passing
|
||||
* -1 means the duration is omitted. Other negative values are invalid.
|
||||
* @param out syncFence The sync fence that will be signaled when the task is completed. The
|
||||
* sync fence will be set to error if a critical error, e.g. hardware
|
||||
* failure or kernel panic, occurs when doing execution.
|
||||
* @return The IFencedExecutionCallback can be used to query information like duration and error
|
||||
* status when the execution is completed.
|
||||
* @throws ServiceSpecificException with one of the following ErrorStatus values:
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if there is an unspecified error
|
||||
* - INVALID_ARGUMENT if one of the input arguments is invalid, including fences in error
|
||||
* states.
|
||||
* - MISSED_DEADLINE_* if the execution is aborted because it cannot be completed by the
|
||||
* deadline
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
*/
|
||||
IFencedExecutionCallback executeFenced(in Request request, in ParcelFileDescriptor[] waitFor,
|
||||
in boolean measureTiming, in long deadline, in long loopTimeoutDuration, in long duration,
|
||||
out @nullable ParcelFileDescriptor syncFence);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.ErrorStatus;
|
||||
import android.hardware.neuralnetworks.IPreparedModel;
|
||||
|
||||
/**
|
||||
* IPreparedModelCallback must be used to return a prepared model produced by an asynchronous task
|
||||
* launched from IDevice::prepareModel*.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IPreparedModelCallback {
|
||||
/**
|
||||
* Notify must be invoked immediately after the asynchronous task holding this callback has
|
||||
* finished preparing the model. If the model was successfully prepared, the method must be
|
||||
* invoked with ErrorStatus::NONE and the prepared model. If the model was not able to be
|
||||
* successfully prepared, the method must be invoked with the appropriate ErrorStatus and
|
||||
* nullptr as the IPreparedModel. If the asynchronous task holding this callback fails to launch
|
||||
* or if the model provided to IDevice::prepareModel is invalid, notify method must be invoked
|
||||
* with the appropriate error as well as nullptr for the IPreparedModel.
|
||||
*
|
||||
* @param status Error status returned from the asynchronous model preparation task; must be:
|
||||
* - NONE if the asynchronous task successfully prepared the model
|
||||
* - DEVICE_UNAVAILABLE if driver is offline or busy
|
||||
* - GENERAL_FAILURE if the asynchronous task resulted in an unspecified error
|
||||
* - INVALID_ARGUMENT if one of the input arguments to prepareModel is invalid
|
||||
* - MISSED_DEADLINE_* if the preparation is aborted because the model cannot be
|
||||
* prepared by the deadline
|
||||
* - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
|
||||
* @param preparedModel A model that has been asynchronously prepared for execution. If the
|
||||
* model was unable to be prepared due to an error, nullptr must be passed
|
||||
* in place of the IPreparedModel object.
|
||||
*/
|
||||
void notify(in ErrorStatus status, in IPreparedModel preparedModel);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.IPreparedModel;
|
||||
|
||||
/**
|
||||
* A parcelable for passing a vector of IPreparedModel objects.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable IPreparedModelParcel {
|
||||
IPreparedModel preparedModel;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
import android.hardware.common.NativeHandle;
|
||||
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
/**
|
||||
* A type that is used to pass pieces of shared memory between processes.
|
||||
* The type structure mimics hidl_memory type from HIDL.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Memory {
|
||||
NativeHandle handle;
|
||||
long size;
|
||||
String name;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.ExtensionNameAndPrefix;
|
||||
import android.hardware.neuralnetworks.Subgraph;
|
||||
import android.hardware.neuralnetworks.Memory;
|
||||
|
||||
/**
|
||||
* A Neural Network Model.
|
||||
*
|
||||
* This includes not only the execution graph, but also constant data such as weights or scalars
|
||||
* added at construction time. The only information that may not be known is the shape of the input
|
||||
* tensors.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Model {
|
||||
/**
|
||||
* The top-level subgraph.
|
||||
*/
|
||||
Subgraph main;
|
||||
/**
|
||||
* Referenced subgraphs.
|
||||
*
|
||||
* Each subgraph is referenced by the main subgraph or at least one other referenced subgraph.
|
||||
*
|
||||
* There must be no reference cycles.
|
||||
*/
|
||||
Subgraph[] referenced;
|
||||
/**
|
||||
* A byte buffer containing operand data that were copied into the model.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime equals
|
||||
* OperandLifeTime::CONSTANT_COPY.
|
||||
*/
|
||||
byte[] operandValues;
|
||||
/**
|
||||
* A collection of shared memory pools containing operand values.
|
||||
*
|
||||
* An operand's value must be located here if and only if Operand::lifetime equals
|
||||
* OperandLifeTime::CONSTANT_POOL.
|
||||
*/
|
||||
Memory[] pools;
|
||||
/**
|
||||
* 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or precision as low as that
|
||||
* of the IEEE 754 16-bit floating-point format.
|
||||
* 'false' indicates TENSOR_FLOAT32 must be calculated using at least the range and precision of
|
||||
* the IEEE 754 32-bit floating-point format.
|
||||
*/
|
||||
boolean relaxComputationFloat32toFloat16;
|
||||
/**
|
||||
* The mapping between extension names and prefixes of operand and operation type values.
|
||||
*/
|
||||
ExtensionNameAndPrefix[] extensionNameToPrefix;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Structure indicating how many files for model and numDataCache cache the driver needs to cache a
|
||||
* single prepared model.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable NumberOfCacheFiles {
|
||||
int numModelCache;
|
||||
int numDataCache;
|
||||
}
|
||||
113
neuralnetworks/aidl/android/hardware/neuralnetworks/Operand.aidl
Normal file
113
neuralnetworks/aidl/android/hardware/neuralnetworks/Operand.aidl
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.DataLocation;
|
||||
import android.hardware.neuralnetworks.OperandExtraParams;
|
||||
import android.hardware.neuralnetworks.OperandLifeTime;
|
||||
import android.hardware.neuralnetworks.OperandType;
|
||||
|
||||
/**
|
||||
* Describes one operand of the model's graph.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Operand {
|
||||
/**
|
||||
* The data type.
|
||||
*
|
||||
* Besides the values listed in {@link OperandType}, any value above
|
||||
* {@link IDevice::OPERAND_TYPE_BASE_MAX} is possible and should be interpreted as an extension
|
||||
* type according to {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
OperandType type;
|
||||
/**
|
||||
* Dimensions of the operand.
|
||||
*
|
||||
* For a scalar operand, dimensions.size() must be 0.
|
||||
*
|
||||
* A tensor operand with all dimensions specified has "fully specified" dimensions. Whenever
|
||||
* possible (i.e., whenever the dimensions are known at model construction time), a tensor
|
||||
* operand should have (but is not required to have) fully specified dimensions, in order to
|
||||
* enable the best possible performance.
|
||||
*
|
||||
* If a tensor operand's dimensions are not fully specified, the dimensions of the operand are
|
||||
* deduced from the operand dimensions and values of the operation for which that operand is an
|
||||
* output or from the corresponding {@link OperationType::IF} or {@link OperationType::WHILE}
|
||||
* operation input operand dimensions in the case of referenced subgraph input operands.
|
||||
*
|
||||
* In the following situations, a tensor operand's dimensions must be fully specified:
|
||||
*
|
||||
* . The operand has lifetime CONSTANT_COPY or CONSTANT_POOL.
|
||||
*
|
||||
* . The operand has lifetime SUBGRAPH_INPUT and belongs to the main subgraph. Fully
|
||||
* specified dimensions must either be present in the Operand or they must be provided in
|
||||
* the corresponding RequestArgument.
|
||||
* EXCEPTION: If the input is optional and omitted (by setting the hasNoValue field of the
|
||||
* corresponding RequestArgument to true) then it need not have fully specified
|
||||
* dimensions.
|
||||
*
|
||||
* A tensor operand with some number of unspecified dimensions is represented by setting each
|
||||
* unspecified dimension to 0.
|
||||
*
|
||||
* A tensor operand with unspecified rank is represented by providing an empty dimensions
|
||||
* vector.
|
||||
*/
|
||||
int[] dimensions;
|
||||
/**
|
||||
* Quantized scale of the operand.
|
||||
*
|
||||
* Must be 0 when not applicable to an operand type.
|
||||
*
|
||||
* See {@link OperandType}.
|
||||
*/
|
||||
float scale;
|
||||
/**
|
||||
* Quantized zero-point offset of the operand.
|
||||
*
|
||||
* Must be 0 when not applicable to an operand type.
|
||||
*
|
||||
* See {@link OperandType}.
|
||||
*/
|
||||
int zeroPoint;
|
||||
/**
|
||||
* How the operand is used.
|
||||
*/
|
||||
OperandLifeTime lifetime;
|
||||
/**
|
||||
* Where to find the data for this operand.
|
||||
* If the lifetime is TEMPORARY_VARIABLE, SUBGRAPH_INPUT, SUBGRAPH_OUTPUT, or NO_VALUE:
|
||||
* - All the fields must be 0.
|
||||
* If the lifetime is CONSTANT_COPY:
|
||||
* - location.poolIndex is 0.
|
||||
* - location.offset is the offset in bytes into Model.operandValues.
|
||||
* - location.length is set.
|
||||
* If the lifetime is CONSTANT_POOL:
|
||||
* - location.poolIndex is set.
|
||||
* - location.offset is the offset in bytes into the specified pool.
|
||||
* - location.length is set.
|
||||
* If the lifetime is SUBGRAPH:
|
||||
* - location.poolIndex is 0.
|
||||
* - location.offset is the index of the referenced subgraph in {@link Model::referenced}.
|
||||
* - location.length is 0.
|
||||
*/
|
||||
DataLocation location;
|
||||
/**
|
||||
* Additional parameters specific to a particular operand type.
|
||||
*/
|
||||
@nullable OperandExtraParams extraParams;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.SymmPerChannelQuantParams;
|
||||
|
||||
/**
|
||||
* Parameters specific to a particular operand type.
|
||||
*/
|
||||
@VintfStability
|
||||
union OperandExtraParams {
|
||||
/**
|
||||
* Symmetric per-channel quantization parameters.
|
||||
*
|
||||
* Only applicable to operands of type TENSOR_QUANT8_SYMM_PER_CHANNEL.
|
||||
*/
|
||||
SymmPerChannelQuantParams channelQuant;
|
||||
/**
|
||||
* Extension operand parameters.
|
||||
*
|
||||
* The framework treats this as an opaque data blob.
|
||||
* The format is up to individual extensions.
|
||||
*/
|
||||
byte[] extension;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* How an operand is used.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum OperandLifeTime {
|
||||
/**
|
||||
* The operand is internal to the model. It's created by an operation and consumed by other
|
||||
* operations. It must be an output operand of exactly one operation.
|
||||
*/
|
||||
TEMPORARY_VARIABLE,
|
||||
/**
|
||||
* The operand is an input of a subgraph. It must not be an output operand of any operation.
|
||||
*
|
||||
* An operand can't be both input and output of a subgraph.
|
||||
*/
|
||||
SUBGRAPH_INPUT,
|
||||
/**
|
||||
* The operand is an output of a subgraph. It must be an output operand of exactly one
|
||||
* operation.
|
||||
*
|
||||
* An operand can't be both input and output of a subgraph.
|
||||
*/
|
||||
SUBGRAPH_OUTPUT,
|
||||
/**
|
||||
* The operand is a constant found in Model.operandValues. It must not be an output operand of
|
||||
* any operation.
|
||||
*/
|
||||
CONSTANT_COPY,
|
||||
/**
|
||||
* The operand is a constant that was specified via a Memory object. It must not be an output
|
||||
* operand of any operation.
|
||||
*/
|
||||
CONSTANT_POOL,
|
||||
/**
|
||||
* The operand does not have a value. This is valid only for optional arguments of operations.
|
||||
*/
|
||||
NO_VALUE,
|
||||
/**
|
||||
* The operand is a reference to a subgraph. It must be an input to one or more
|
||||
* {@link OperationType::IF} or {@link OperationType::WHILE} operations.
|
||||
*/
|
||||
SUBGRAPH,
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.OperandType;
|
||||
import android.hardware.neuralnetworks.PerformanceInfo;
|
||||
|
||||
/**
|
||||
* Driver performance when operating on a particular data type. In the case of float32 data, this is
|
||||
* used when the calculations are not relaxed.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable OperandPerformance {
|
||||
OperandType type;
|
||||
PerformanceInfo info;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Operand types.
|
||||
*
|
||||
* The type of an operand in a model.
|
||||
*
|
||||
* Types prefaced with TENSOR_* must be used for tensor data (i.e., tensors
|
||||
* with at least one dimension). Types not prefaced by TENSOR_* represent
|
||||
* scalar values and must have no dimensions.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum OperandType {
|
||||
/**
|
||||
* A 32 bit floating point scalar value.
|
||||
*/
|
||||
FLOAT32 = 0,
|
||||
/**
|
||||
* A signed 32 bit integer scalar value.
|
||||
*/
|
||||
INT32 = 1,
|
||||
/**
|
||||
* An unsigned 32 bit integer scalar value.
|
||||
*/
|
||||
UINT32 = 2,
|
||||
/**
|
||||
* A tensor of 32 bit floating point values.
|
||||
*/
|
||||
TENSOR_FLOAT32 = 3,
|
||||
/**
|
||||
* A tensor of 32 bit integer values.
|
||||
*/
|
||||
TENSOR_INT32 = 4,
|
||||
/**
|
||||
* A tensor of 8 bit unsigned integers that represent real numbers.
|
||||
*
|
||||
* Attached to this tensor are two numbers that can be used to convert the 8 bit integer to the
|
||||
* real value and vice versa. These two numbers are:
|
||||
* - scale: a 32 bit floating point value greater than zero.
|
||||
* - zeroPoint: a 32 bit integer, in range [0, 255].
|
||||
*
|
||||
* The formula is:
|
||||
* real_value = (integer_value - zeroPoint) * scale.
|
||||
*/
|
||||
TENSOR_QUANT8_ASYMM = 5,
|
||||
/**
|
||||
* An 8 bit boolean scalar value.
|
||||
*
|
||||
* Values of this operand type are either true or false. A zero value represents false; any
|
||||
* other value represents true.
|
||||
*/
|
||||
BOOL = 6,
|
||||
/**
|
||||
* A tensor of 16 bit signed integers that represent real numbers.
|
||||
*
|
||||
* Attached to this tensor is a number representing real value scale that is used to convert the
|
||||
* 16 bit number to a real value in the following way:
|
||||
* realValue = integerValue * scale.
|
||||
*
|
||||
* scale is a 32 bit floating point with value greater than zero.
|
||||
*/
|
||||
TENSOR_QUANT16_SYMM = 7,
|
||||
/**
|
||||
* A tensor of IEEE 754 16 bit floating point values.
|
||||
*/
|
||||
TENSOR_FLOAT16 = 8,
|
||||
/**
|
||||
* A tensor of 8 bit boolean values.
|
||||
*
|
||||
* Values of this operand type are either true or false. A zero value represents false; any
|
||||
* other value represents true.
|
||||
*/
|
||||
TENSOR_BOOL8 = 9,
|
||||
/**
|
||||
* An IEEE 754 16 bit floating point scalar value.
|
||||
*/
|
||||
FLOAT16 = 10,
|
||||
/**
|
||||
* A tensor of 8 bit signed integers that represent real numbers.
|
||||
*
|
||||
* This tensor is associated with additional fields that can be used to convert the 8 bit signed
|
||||
* integer to the real value and vice versa. These fields are:
|
||||
* - channelDim: a 32 bit unsigned integer indicating channel dimension.
|
||||
* - scales: an array of positive 32 bit floating point values.
|
||||
* The size of the scales array must be equal to dimensions[channelDim].
|
||||
*
|
||||
* {@link SymmPerChannelQuantParams} must hold the parameters for an Operand of this type.
|
||||
* The channel dimension of this tensor must not be unknown (dimensions[channelDim] != 0).
|
||||
*
|
||||
* The formula is:
|
||||
* realValue[..., C, ...] =
|
||||
* integerValue[..., C, ...] * scales[C]
|
||||
* where C is an index in the Channel dimension.
|
||||
*/
|
||||
TENSOR_QUANT8_SYMM_PER_CHANNEL = 11,
|
||||
/**
|
||||
* A tensor of 16 bit unsigned integers that represent real numbers.
|
||||
*
|
||||
* Attached to this tensor are two numbers that can be used to convert the 16 bit integer to the
|
||||
* real value and vice versa. These two numbers are:
|
||||
* - scale: a 32 bit floating point value greater than zero.
|
||||
* - zeroPoint: a 32 bit integer, in range [0, 65535].
|
||||
*
|
||||
* The formula is:
|
||||
* real_value = (integer_value - zeroPoint) * scale.
|
||||
*/
|
||||
TENSOR_QUANT16_ASYMM = 12,
|
||||
/**
|
||||
* A tensor of 8 bit signed integers that represent real numbers.
|
||||
*
|
||||
* Attached to this tensor is a number representing real value scale that is used to convert the
|
||||
* 8 bit number to a real value in the following way:
|
||||
* realValue = integerValue * scale.
|
||||
*
|
||||
* scale is a 32 bit floating point with value greater than zero.
|
||||
*/
|
||||
TENSOR_QUANT8_SYMM = 13,
|
||||
/**
|
||||
* A tensor of 8 bit signed integers that represent real numbers.
|
||||
*
|
||||
* Attached to this tensor are two numbers that can be used to convert the 8 bit integer to the
|
||||
* real value and vice versa. These two numbers are:
|
||||
* - scale: a 32 bit floating point value greater than zero.
|
||||
* - zeroPoint: a 32 bit integer, in range [-128, 127].
|
||||
*
|
||||
* The formula is:
|
||||
* real_value = (integer_value - zeroPoint) * scale.
|
||||
*/
|
||||
TENSOR_QUANT8_ASYMM_SIGNED = 14,
|
||||
/**
|
||||
* A reference to a subgraph.
|
||||
*
|
||||
* Must have the lifetime {@link OperandLifeTime::SUBGRAPH}.
|
||||
*/
|
||||
SUBGRAPH = 15,
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.OperationType;
|
||||
|
||||
/**
|
||||
* Describes one operation of the model's graph.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Operation {
|
||||
/**
|
||||
* The operation type.
|
||||
*
|
||||
* Besides the values listed in {@link OperationType}, any value above
|
||||
* {@link IDevice::OPERATION_TYPE_BASE_MAX} is possible and should be interpreted as an
|
||||
* extension type according to {@link Model::extensionNameToPrefix}.
|
||||
*/
|
||||
OperationType type;
|
||||
/**
|
||||
* Describes the table that contains the indexes of the inputs of the operation. The offset is
|
||||
* the index in the operandIndexes table.
|
||||
*/
|
||||
int[] inputs;
|
||||
/**
|
||||
* Describes the table that contains the indexes of the outputs of the operation. The offset is
|
||||
* the index in the operandIndexes table.
|
||||
*/
|
||||
int[] outputs;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Describes the shape information of an output operand after execution.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable OutputShape {
|
||||
/**
|
||||
* Dimensions of the operand.
|
||||
*/
|
||||
int[] dimensions;
|
||||
/**
|
||||
* Whether the provided buffer size is sufficient for the output.
|
||||
*/
|
||||
boolean isSufficient;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Performance information for the reference workload.
|
||||
*
|
||||
* Used by a driver to report its performance characteristics.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable PerformanceInfo {
|
||||
/**
|
||||
* Ratio of the time taken by the driver to execute the workload compared to the time the CPU
|
||||
* would take for the same workload. A lower number is better.
|
||||
*/
|
||||
float execTime;
|
||||
/**
|
||||
* Ratio of the energy used by the driver compared to what the CPU would use for doing the same
|
||||
* workload. A lower number is better.
|
||||
*/
|
||||
float powerUsage;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Priority given to a prepared model for execution.
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum Priority {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.RequestArgument;
|
||||
import android.hardware.neuralnetworks.RequestMemoryPool;
|
||||
|
||||
/**
|
||||
* Inputs to be sent to and outputs to be retrieved from a prepared model.
|
||||
*
|
||||
* A Request serves two primary tasks:
|
||||
* 1) Provides the input and output data to be used when executing the model.
|
||||
* 2) Specifies any updates to the input operand metadata that were left unspecified at model
|
||||
* preparation time.
|
||||
*
|
||||
* An output must not overlap with any other output, with an input, or with an operand of lifetime
|
||||
* CONSTANT_POOL.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Request {
|
||||
/**
|
||||
* Input data and information to be used in the execution of a prepared model.
|
||||
*
|
||||
* The index of the input corresponds to the index in Model.main.inputIndexes.
|
||||
* E.g., input[i] corresponds to Model.main.inputIndexes[i].
|
||||
*/
|
||||
RequestArgument[] inputs;
|
||||
/**
|
||||
* Output data and information to be used in the execution of a prepared model.
|
||||
*
|
||||
* The index of the output corresponds to the index in Model.main.outputIndexes.
|
||||
* E.g., output[i] corresponds to Model.main.outputIndexes[i].
|
||||
*/
|
||||
RequestArgument[] outputs;
|
||||
/**
|
||||
* A collection of memory pools containing operand data for both the inputs and the outputs to a
|
||||
* model.
|
||||
*/
|
||||
RequestMemoryPool[] pools;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.DataLocation;
|
||||
|
||||
/**
|
||||
* Metadata information specifying the location of the input or output data and any updates to the
|
||||
* input or output operand.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable RequestArgument {
|
||||
/**
|
||||
* If true, the argument does not have a value. This can be used for operations that take
|
||||
* optional arguments. If true, the fields of location are set to 0 and the dimensions vector is
|
||||
* left empty.
|
||||
*/
|
||||
boolean hasNoValue;
|
||||
/**
|
||||
* The location within one of the memory pools passed in the Request.
|
||||
*/
|
||||
DataLocation location;
|
||||
/**
|
||||
* Updated dimension information.
|
||||
*
|
||||
* If dimensions.size() > 0, dimension information was provided along with the argument. This
|
||||
* can be the case for models that accept inputs of varying size. This can't change the rank,
|
||||
* just the value of the dimensions that were unspecified in the model. If dimensions.size() >
|
||||
* 0, then all dimensions must be specified here; and any dimension that was specified in the
|
||||
* model must have the same value here.
|
||||
*
|
||||
* If the dimensions in the model are not fully specified, then they must be fully specified
|
||||
* here, unless hasNoValue is set to true. If the dimensions in the model are fully specified,
|
||||
* then either dimensions.size() may be 0, or the dimensions in the model must be identical to
|
||||
* the dimensions here.
|
||||
*/
|
||||
int[] dimensions;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.Memory;
|
||||
|
||||
/**
|
||||
* A memory pool.
|
||||
*/
|
||||
@VintfStability
|
||||
union RequestMemoryPool {
|
||||
/**
|
||||
* Specifies a client-managed shared memory pool.
|
||||
*/
|
||||
Memory pool;
|
||||
/**
|
||||
* Specifies a driver-managed buffer. It is the token returned from IDevice::allocate, and is
|
||||
* specific to the IDevice object.
|
||||
*/
|
||||
int token;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
import android.hardware.neuralnetworks.Operand;
|
||||
import android.hardware.neuralnetworks.Operation;
|
||||
|
||||
/**
|
||||
* An excerpt of the execution graph.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Subgraph {
|
||||
/**
|
||||
* All operands included in the subgraph.
|
||||
*/
|
||||
Operand[] operands;
|
||||
/**
|
||||
* All operations included in the subgraph.
|
||||
*
|
||||
* The operations are sorted into execution order. Every operand with lifetime SUBGRAPH_OUTPUT
|
||||
* or TEMPORARY_VARIABLE must be written before it is read.
|
||||
*/
|
||||
Operation[] operations;
|
||||
/**
|
||||
* Input indexes of the subgraph. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
int[] inputIndexes;
|
||||
/**
|
||||
* Output indexes of the subgraph. There must be at least one.
|
||||
*
|
||||
* Each value corresponds to the index of the operand in "operands".
|
||||
*/
|
||||
int[] outputIndexes;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Parameters for TENSOR_QUANT8_SYMM_PER_CHANNEL operand.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable SymmPerChannelQuantParams {
|
||||
/**
|
||||
* Array of scaling values for each channel. Each value must be greater than zero.
|
||||
*/
|
||||
float[] scales;
|
||||
/**
|
||||
* Index of the channel dimension
|
||||
*/
|
||||
int channelDim;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package android.hardware.neuralnetworks;
|
||||
|
||||
/**
|
||||
* Timing information measured during execution. Each time is a duration from the beginning of some
|
||||
* task to the end of that task, including time when that task is not active (for example, preempted
|
||||
* by some other task, or waiting for some resource to become available).
|
||||
*
|
||||
* Times are measured in nanoseconds. When a time is not available, it must be reported as -1.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Timing {
|
||||
/**
|
||||
* Execution time on device (not driver, which runs on host processor).
|
||||
*/
|
||||
long timeOnDevice;
|
||||
/**
|
||||
* Execution time in driver (including time on device).
|
||||
*/
|
||||
long timeInDriver;
|
||||
}
|
||||
Reference in New Issue
Block a user