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

Commit 5379aaf9 authored by Slava Shklyaev's avatar Slava Shklyaev Committed by Android (Google) Code Review
Browse files

Merge "Refactor NNAPI VTS to remove unreasonable dependence between versions"

parents 4d2509f1 1d6b4659
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -15,21 +15,19 @@
//

cc_library_static {
    name: "VtsHalNeuralnetworksTest_utils",
    name: "VtsHalNeuralNetworksV1_0_utils",
    srcs: [
        "Callbacks.cpp",
        "GeneratedTestHarness.cpp",
        "Utils.cpp",
    ],
    defaults: ["VtsHalTargetTestDefaults"],
    export_include_dirs: ["."],
    export_include_dirs: ["include"],
    shared_libs: [
        "libfmq",
        "libnativewindow",
    ],
    static_libs: [
        "android.hardware.neuralnetworks@1.0",
        "android.hardware.neuralnetworks@1.1",
        "android.hardware.neuralnetworks@1.2",
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "libgmock",
@@ -44,12 +42,13 @@ cc_library_static {
}

cc_defaults {
    name: "VtsHalNeuralNetworksTargetTestDefaults",
    name: "VtsHalNeuralNetworksV1_0TargetTestDefaults",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
        "ValidateModel.cpp",
        "ValidateRequest.cpp",
        "VtsHalNeuralnetworks.cpp",
        "GeneratedTestHarness.cpp",
    ],
    shared_libs: [
        "libfmq",
@@ -57,14 +56,12 @@ cc_defaults {
    ],
    static_libs: [
        "android.hardware.neuralnetworks@1.0",
        "android.hardware.neuralnetworks@1.1",
        "android.hardware.neuralnetworks@1.2",
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "libgmock",
        "libhidlmemory",
        "libneuralnetworks_utils",
        "VtsHalNeuralnetworksTest_utils",
        "VtsHalNeuralNetworksV1_0_utils",
    ],
    header_libs: [
        "libneuralnetworks_headers",
@@ -76,19 +73,19 @@ cc_defaults {

cc_test {
    name: "VtsHalNeuralnetworksV1_0TargetTest",
    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
    defaults: ["VtsHalNeuralNetworksV1_0TargetTestDefaults"],
    srcs: [
        "BasicTests.cpp",
        "GeneratedTests.cpp",
        "GeneratedTestsV1_0.cpp",
    ],
}

cc_test {
    name: "PresubmitHalNeuralnetworksV1_0TargetTest",
    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
    defaults: ["VtsHalNeuralNetworksV1_0TargetTestDefaults"],
    srcs: [
        "BasicTests.cpp",
        "GeneratedTests.cpp",
        "GeneratedTestsV1_0.cpp",
    ],
    cflags: [
        "-DPRESUBMIT_NOT_VTS",
+3 −33
Original line number Diff line number Diff line
@@ -14,13 +14,13 @@
 * limitations under the License.
 */

#include "Callbacks.h"
#include "1.0/Callbacks.h"
#include <android-base/logging.h>

namespace android {
namespace hardware {
namespace neuralnetworks {
namespace V1_2 {
namespace V1_0 {
namespace implementation {

CallbackBase::CallbackBase() : mNotified(false) {}
@@ -111,14 +111,6 @@ Return<void> PreparedModelCallback::notify(ErrorStatus errorStatus,
    return Void();
}

Return<void> PreparedModelCallback::notify_1_2(ErrorStatus errorStatus,
                                               const sp<V1_2::IPreparedModel>& preparedModel) {
    mErrorStatus = errorStatus;
    mPreparedModel = preparedModel;
    CallbackBase::notify();
    return Void();
}

ErrorStatus PreparedModelCallback::getStatus() {
    wait();
    return mErrorStatus;
@@ -135,18 +127,6 @@ ExecutionCallback::~ExecutionCallback() {}

Return<void> ExecutionCallback::notify(ErrorStatus errorStatus) {
    mErrorStatus = errorStatus;
    mOutputShapes = {};
    mTiming = {.timeOnDevice = UINT64_MAX, .timeInDriver = UINT64_MAX};
    CallbackBase::notify();
    return Void();
}

Return<void> ExecutionCallback::notify_1_2(ErrorStatus errorStatus,
                                           const hidl_vec<OutputShape>& outputShapes,
                                           const Timing& timing) {
    mErrorStatus = errorStatus;
    mOutputShapes = outputShapes;
    mTiming = timing;
    CallbackBase::notify();
    return Void();
}
@@ -156,18 +136,8 @@ ErrorStatus ExecutionCallback::getStatus() {
    return mErrorStatus;
}

const std::vector<OutputShape>& ExecutionCallback::getOutputShapes() {
    wait();
    return mOutputShapes;
}

Timing ExecutionCallback::getTiming() {
    wait();
    return mTiming;
}

}  // namespace implementation
}  // namespace V1_2
}  // namespace V1_0
}  // namespace neuralnetworks
}  // namespace hardware
}  // namespace android
+48 −412

File changed.

Preview size limit exceeded, changes collapsed.

+4 −22
Original line number Diff line number Diff line
@@ -14,14 +14,11 @@
 * limitations under the License.
 */

#ifndef VTS_HAL_NEURALNETWORKS_GENERATED_TEST_HARNESS_H
#define VTS_HAL_NEURALNETWORKS_GENERATED_TEST_HARNESS_H

#include "TestHarness.h"
#ifndef ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H
#define ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H

#include <android/hardware/neuralnetworks/1.0/IDevice.h>
#include <android/hardware/neuralnetworks/1.1/IDevice.h>
#include <android/hardware/neuralnetworks/1.2/IDevice.h>
#include "TestHarness.h"

namespace android {
namespace hardware {
@@ -30,28 +27,13 @@ namespace neuralnetworks {
namespace generated_tests {
using ::test_helper::MixedTypedExample;

void PrepareModel(const sp<V1_2::IDevice>& device, const V1_2::Model& model,
                  sp<V1_2::IPreparedModel>* preparedModel);

void EvaluatePreparedModel(sp<V1_2::IPreparedModel>& preparedModel,
                           std::function<bool(int)> is_ignored,
                           const std::vector<MixedTypedExample>& examples,
                           bool hasRelaxedFloat32Model, bool testDynamicOutputShape);

void Execute(const sp<V1_0::IDevice>& device, std::function<V1_0::Model(void)> create_model,
             std::function<bool(int)> is_ignored, const std::vector<MixedTypedExample>& examples);

void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> create_model,
             std::function<bool(int)> is_ignored, const std::vector<MixedTypedExample>& examples);

void Execute(const sp<V1_2::IDevice>& device, std::function<V1_2::Model(void)> create_model,
             std::function<bool(int)> is_ignored, const std::vector<MixedTypedExample>& examples,
             bool testDynamicOutputShape = false);

}  // namespace generated_tests

}  // namespace neuralnetworks
}  // namespace hardware
}  // namespace android

#endif  // VTS_HAL_NEURALNETWORKS_GENERATED_TEST_HARNESS_H
#endif  // ANDROID_HARDWARE_NEURALNETWORKS_V1_0_GENERATED_TEST_HARNESS_H
+9 −9
Original line number Diff line number Diff line
@@ -16,17 +16,16 @@

#define LOG_TAG "neuralnetworks_hidl_hal_test"

#include "VtsHalNeuralnetworks.h"

#include "Callbacks.h"
#include "GeneratedTestHarness.h"
#include "TestHarness.h"
#include "Utils.h"

#include <android-base/logging.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>

#include "1.0/Callbacks.h"
#include "GeneratedTestHarness.h"
#include "MemoryUtils.h"
#include "TestHarness.h"
#include "VtsHalNeuralnetworks.h"

namespace android {
namespace hardware {
namespace neuralnetworks {
@@ -34,8 +33,9 @@ namespace V1_0 {
namespace vts {
namespace functional {

using ::android::hardware::neuralnetworks::V1_2::implementation::ExecutionCallback;
using ::android::hardware::neuralnetworks::V1_2::implementation::PreparedModelCallback;
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
using ::android::hidl::memory::V1_0::IMemory;
using ::android::nn::allocateSharedMemory;
using ::test_helper::MixedTypedExample;

Loading