Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8805b2d6 authored by Xusong Wang's avatar Xusong Wang
Browse files

Address ANAPIC review comments -- hal.

- Document that IPreparedModel::execute*WithConfig are for single-time
  usages, and IPreparedModel::createReusableExecution is for reusable
  usages.
- Make PrepareModelConfig::cacheToken a fixed sized array.

Fixes: 215566186
Test: VtsHalNeuralnetworksTargetTest
Test: NNT_static
Change-Id: I9c5a49c46a3eac2828b9eb666f3d742038493121
parent e4061de7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ parcelable PrepareModelConfig {
  long deadlineNs;
  ParcelFileDescriptor[] modelCache;
  ParcelFileDescriptor[] dataCache;
  byte[] cacheToken;
  byte[32] cacheToken;
  android.hardware.neuralnetworks.TokenValuePair[] compilationHints;
  android.hardware.neuralnetworks.ExtensionNameAndPrefix[] extensionNameToPrefix;
  const int BYTE_SIZE_OF_CACHE_TOKEN = 32;
}
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ interface IDevice {
    /**
     * The byte size of the cache token.
     */
    const int BYTE_SIZE_OF_CACHE_TOKEN = 32;
    const int BYTE_SIZE_OF_CACHE_TOKEN = PrepareModelConfig.BYTE_SIZE_OF_CACHE_TOKEN;
    /**
     * The maximum number of files for each type of cache in compilation caching.
     */
+14 −0
Original line number Diff line number Diff line
@@ -204,6 +204,12 @@ interface IPreparedModel {
     * appropriate ErrorStatus value. If the inputs to the function are valid and there is no error,
     * createReusableExecution must construct a reusable execution.
     *
     * This method will be called when a client requests a reusable execution with consistent
     * request and execution config. For single-time execution,
     * {@link IPreparedModel::executeSynchronouslyWithConfig} or
     * {@link IPreparedModel::executeFencedWithConfig} is preferred, because the overhead of
     * setting up a reusable execution can be avoided.
     *
     * @param request The input and output information on which the prepared model is to be
     *                executed.
     * @param config Specifies the execution configuration parameters.
@@ -223,6 +229,10 @@ interface IPreparedModel {
     * ExecutionConfig} instead of a list of configuration parameters, and ExecutionConfig contains
     * more configuration parameters than are passed to executeSynchronously.
     *
     * This method is preferred when a client requests a single-time synchronous execution.
     * For reusable execution with consistent request and execution config,
     * {@link IPreparedModel::createReusableExecution} must be called.
     *
     * @param request The input and output information on which the prepared model is to be
     *                executed.
     * @param config Specifies the execution configuration parameters.
@@ -246,6 +256,10 @@ interface IPreparedModel {
     * ExecutionConfig} instead of a list of configuration parameters, and ExecutionConfig contains
     * more configuration parameters than are passed to executeFenced.
     *
     * This method is preferred when a client requests a single-time fenced execution.
     * For reusable execution with consistent request and execution config,
     * {@link IPreparedModel::createReusableExecution} must be called.
     *
     * @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
+7 −2
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@ import android.hardware.neuralnetworks.TokenValuePair;
 */
@VintfStability
parcelable PrepareModelConfig {
    /**
     * The byte size of the cache token.
     */
    const int BYTE_SIZE_OF_CACHE_TOKEN = 32;

    /**
     * Indicates the intended execution behavior of a prepared model.
     */
@@ -66,7 +71,7 @@ parcelable PrepareModelConfig {
     */
    ParcelFileDescriptor[] dataCache;
    /**
     * A caching token of length IDevice::BYTE_SIZE_OF_CACHE_TOKEN identifying
     * 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
     * IDevice::prepareModelFromCache.  Tokens should be chosen to have a low
@@ -77,7 +82,7 @@ parcelable PrepareModelConfig {
     * indicating that caching information is not provided, this
     * token must be ignored.
     */
    byte[] cacheToken;
    byte[BYTE_SIZE_OF_CACHE_TOKEN] cacheToken;
    /**
     * A vector of token / value pairs represent vendor specific
     * compilation hints or metadata. The provided TokenValuePairs must not
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <aidl/android/hardware/neuralnetworks/Extension.h>
#include <aidl/android/hardware/neuralnetworks/ExtensionNameAndPrefix.h>
#include <aidl/android/hardware/neuralnetworks/ExtensionOperandTypeInformation.h>
#include <aidl/android/hardware/neuralnetworks/IDevice.h>
#include <aidl/android/hardware/neuralnetworks/Memory.h>
#include <aidl/android/hardware/neuralnetworks/Model.h>
#include <aidl/android/hardware/neuralnetworks/Operand.h>
@@ -219,6 +220,7 @@ nn::GeneralResult<std::vector<TokenValuePair>> convert(
#endif  // NN_AIDL_V4_OR_ABOVE

nn::GeneralResult<std::vector<int32_t>> toSigned(const std::vector<uint32_t>& vec);
std::vector<uint8_t> toVec(const std::array<uint8_t, IDevice::BYTE_SIZE_OF_CACHE_TOKEN>& token);

}  // namespace aidl::android::hardware::neuralnetworks::utils

Loading