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

Commit 71b59554 authored by Michael Butler's avatar Michael Butler Committed by Gerrit Code Review
Browse files

Merge "Make NNAPI Version more structured -- hal"

parents a4a390c0 34f0a8f4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@

namespace android::hardware::neuralnetworks::V1_0::utils {

constexpr auto kVersion = nn::Version::ANDROID_OC_MR1;
const auto kVersion = nn::Version::ANDROID_OC_MR1;

template <typename Type>
nn::Result<void> validate(const Type& halObject) {
@@ -51,7 +51,7 @@ bool valid(const Type& halObject) {
template <typename Type>
nn::Result<void> compliantVersion(const Type& canonical) {
    const auto version = NN_TRY(nn::validate(canonical));
    if (version > kVersion) {
    if (!nn::isCompliantVersion(version, kVersion)) {
        return NN_ERROR() << "Insufficient version: " << version << " vs required " << kVersion;
    }
    return {};
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
namespace android::hardware::neuralnetworks::V1_1::utils {

constexpr auto kDefaultExecutionPreference = ExecutionPreference::FAST_SINGLE_ANSWER;
constexpr auto kVersion = nn::Version::ANDROID_P;
const auto kVersion = nn::Version::ANDROID_P;

template <typename Type>
nn::Result<void> validate(const Type& halObject) {
@@ -53,7 +53,7 @@ bool valid(const Type& halObject) {
template <typename Type>
nn::Result<void> compliantVersion(const Type& canonical) {
    const auto version = NN_TRY(nn::validate(canonical));
    if (version > kVersion) {
    if (!nn::isCompliantVersion(version, kVersion)) {
        return NN_ERROR() << "Insufficient version: " << version << " vs required " << kVersion;
    }
    return {};
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ using V1_1::utils::kDefaultExecutionPreference;
constexpr auto kDefaultMesaureTiming = MeasureTiming::NO;
constexpr auto kNoTiming = Timing{.timeOnDevice = std::numeric_limits<uint64_t>::max(),
                                  .timeInDriver = std::numeric_limits<uint64_t>::max()};
constexpr auto kVersion = nn::Version::ANDROID_Q;
const auto kVersion = nn::Version::ANDROID_Q;

template <typename Type>
nn::Result<void> validate(const Type& halObject) {
@@ -62,7 +62,7 @@ bool valid(const Type& halObject) {
template <typename Type>
nn::Result<void> compliantVersion(const Type& canonical) {
    const auto version = NN_TRY(nn::validate(canonical));
    if (version > kVersion) {
    if (!nn::isCompliantVersion(version, kVersion)) {
        return NN_ERROR() << "Insufficient version: " << version << " vs required " << kVersion;
    }
    return {};
+2 −2
Original line number Diff line number Diff line
@@ -315,7 +315,7 @@ nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> Burst::

    // if the request is valid but of a higher version than what's supported in burst execution,
    // fall back to another execution path
    if (const auto version = NN_TRY(nn::validate(request)); version > nn::Version::ANDROID_Q) {
    if (!compliantVersion(request).ok()) {
        // fallback to another execution path if the packet could not be sent
        return kPreparedModel->execute(request, measure, deadline, loopTimeoutDuration);
    }
@@ -359,7 +359,7 @@ nn::GeneralResult<nn::SharedExecution> Burst::createReusableExecution(

    // if the request is valid but of a higher version than what's supported in burst execution,
    // fall back to another execution path
    if (const auto version = NN_TRY(nn::validate(request)); version > nn::Version::ANDROID_Q) {
    if (!compliantVersion(request).ok()) {
        // fallback to another execution path if the packet could not be sent
        return kPreparedModel->createReusableExecution(request, measure, loopTimeoutDuration);
    }
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ using V1_2::utils::kDefaultMesaureTiming;
using V1_2::utils::kNoTiming;

constexpr auto kDefaultPriority = Priority::MEDIUM;
constexpr auto kVersion = nn::Version::ANDROID_R;
const auto kVersion = nn::Version::ANDROID_R;

template <typename Type>
nn::Result<void> validate(const Type& halObject) {
@@ -62,7 +62,7 @@ bool valid(const Type& halObject) {
template <typename Type>
nn::Result<void> compliantVersion(const Type& canonical) {
    const auto version = NN_TRY(nn::validate(canonical));
    if (version > kVersion) {
    if (!nn::isCompliantVersion(version, kVersion)) {
        return NN_ERROR() << "Insufficient version: " << version << " vs required " << kVersion;
    }
    return {};
Loading