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

Commit 518b2d8f authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge changes from topics "aosp-nnapi-1.3-operations", "aosp-nnapi-async-cmdqueue" am: 1b4b30d0

Change-Id: I634a9e12c74a156745428568b3af585fb2bcf8a5
parents 7b0dfcb5 1b4b30d0
Loading
Loading
Loading
Loading
+21 −3
Original line number Original line Diff line number Diff line
@@ -603,7 +603,9 @@ void EvaluatePreparedModel(const sp<IDevice>& device, const sp<IPreparedModel>&
        }
        }
    }
    }


    if (testConfig.outputType != OutputType::FULLY_SPECIFIED &&
    // The driver is allowed to reject executeFenced, and if they do, we should skip.
    if ((testConfig.outputType != OutputType::FULLY_SPECIFIED ||
         testConfig.executor == Executor::FENCED) &&
        executionStatus == ErrorStatus::GENERAL_FAILURE) {
        executionStatus == ErrorStatus::GENERAL_FAILURE) {
        if (skipped != nullptr) {
        if (skipped != nullptr) {
            *skipped = true;
            *skipped = true;
@@ -674,7 +676,7 @@ void EvaluatePreparedModel(const sp<IDevice>& device, const sp<IPreparedModel>&
        case TestKind::GENERAL: {
        case TestKind::GENERAL: {
            outputTypesList = {OutputType::FULLY_SPECIFIED};
            outputTypesList = {OutputType::FULLY_SPECIFIED};
            measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
            measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
            executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST, Executor::FENCED};
            executorList = {Executor::ASYNC, Executor::SYNC, Executor::BURST};
        } break;
        } break;
        case TestKind::DYNAMIC_SHAPE: {
        case TestKind::DYNAMIC_SHAPE: {
            outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT};
            outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT};
@@ -687,6 +689,11 @@ void EvaluatePreparedModel(const sp<IDevice>& device, const sp<IPreparedModel>&
            executorList = {Executor::ASYNC, Executor::SYNC};
            executorList = {Executor::ASYNC, Executor::SYNC};
            memoryType = MemoryType::DEVICE;
            memoryType = MemoryType::DEVICE;
        } break;
        } break;
        case TestKind::FENCED_COMPUTE: {
            outputTypesList = {OutputType::FULLY_SPECIFIED};
            measureTimingList = {MeasureTiming::NO, MeasureTiming::YES};
            executorList = {Executor::FENCED};
        } break;
        case TestKind::QUANTIZATION_COUPLING: {
        case TestKind::QUANTIZATION_COUPLING: {
            LOG(FATAL) << "Wrong TestKind for EvaluatePreparedModel";
            LOG(FATAL) << "Wrong TestKind for EvaluatePreparedModel";
            return;
            return;
@@ -748,7 +755,8 @@ void Execute(const sp<IDevice>& device, const TestModel& testModel, TestKind tes
    switch (testKind) {
    switch (testKind) {
        case TestKind::GENERAL:
        case TestKind::GENERAL:
        case TestKind::DYNAMIC_SHAPE:
        case TestKind::DYNAMIC_SHAPE:
        case TestKind::MEMORY_DOMAIN: {
        case TestKind::MEMORY_DOMAIN:
        case TestKind::FENCED_COMPUTE: {
            createPreparedModel(device, model, &preparedModel);
            createPreparedModel(device, model, &preparedModel);
            if (preparedModel == nullptr) return;
            if (preparedModel == nullptr) return;
            EvaluatePreparedModel(device, preparedModel, testModel, testKind);
            EvaluatePreparedModel(device, preparedModel, testModel, testKind);
@@ -811,6 +819,9 @@ class DynamicOutputShapeTest : public GeneratedTest {};
// Tag for the memory domain tests
// Tag for the memory domain tests
class MemoryDomainTest : public GeneratedTest {};
class MemoryDomainTest : public GeneratedTest {};


// Tag for the fenced compute tests
class FencedComputeTest : public GeneratedTest {};

// Tag for the dynamic output shape tests
// Tag for the dynamic output shape tests
class QuantizationCouplingTest : public GeneratedTest {};
class QuantizationCouplingTest : public GeneratedTest {};


@@ -826,6 +837,10 @@ TEST_P(MemoryDomainTest, Test) {
    Execute(kDevice, kTestModel, /*testKind=*/TestKind::MEMORY_DOMAIN);
    Execute(kDevice, kTestModel, /*testKind=*/TestKind::MEMORY_DOMAIN);
}
}


TEST_P(FencedComputeTest, Test) {
    Execute(kDevice, kTestModel, /*testKind=*/TestKind::FENCED_COMPUTE);
}

TEST_P(QuantizationCouplingTest, Test) {
TEST_P(QuantizationCouplingTest, Test) {
    Execute(kDevice, kTestModel, /*testKind=*/TestKind::QUANTIZATION_COUPLING);
    Execute(kDevice, kTestModel, /*testKind=*/TestKind::QUANTIZATION_COUPLING);
}
}
@@ -840,6 +855,9 @@ INSTANTIATE_GENERATED_TEST(DynamicOutputShapeTest, [](const TestModel& testModel
INSTANTIATE_GENERATED_TEST(MemoryDomainTest,
INSTANTIATE_GENERATED_TEST(MemoryDomainTest,
                           [](const TestModel& testModel) { return !testModel.expectFailure; });
                           [](const TestModel& testModel) { return !testModel.expectFailure; });


INSTANTIATE_GENERATED_TEST(FencedComputeTest,
                           [](const TestModel& testModel) { return !testModel.expectFailure; });

INSTANTIATE_GENERATED_TEST(QuantizationCouplingTest, [](const TestModel& testModel) {
INSTANTIATE_GENERATED_TEST(QuantizationCouplingTest, [](const TestModel& testModel) {
    return testModel.hasQuant8CoupledOperands() && testModel.operations.size() == 1;
    return testModel.hasQuant8CoupledOperands() && testModel.operations.size() == 1;
});
});
+2 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,8 @@ enum class TestKind {
    DYNAMIC_SHAPE,
    DYNAMIC_SHAPE,
    // Same as GENERAL but use device memories for inputs and outputs
    // Same as GENERAL but use device memories for inputs and outputs
    MEMORY_DOMAIN,
    MEMORY_DOMAIN,
    // Same as GENERAL but use executeFenced for exeuction
    FENCED_COMPUTE,
    // Tests if quantized model with TENSOR_QUANT8_ASYMM produces the same result
    // Tests if quantized model with TENSOR_QUANT8_ASYMM produces the same result
    // (OK/SKIPPED/FAILED) as the model with all such tensors converted to
    // (OK/SKIPPED/FAILED) as the model with all such tensors converted to
    // TENSOR_QUANT8_ASYMM_SIGNED.
    // TENSOR_QUANT8_ASYMM_SIGNED.
+4 −16
Original line number Original line Diff line number Diff line
@@ -140,26 +140,14 @@ void validateExecuteFenced(const sp<IPreparedModel>& preparedModel, const Reques
            preparedModel->executeFenced(request, {hidl_handle(nullptr)}, V1_2::MeasureTiming::NO,
            preparedModel->executeFenced(request, {hidl_handle(nullptr)}, V1_2::MeasureTiming::NO,
                                         [](ErrorStatus error, const hidl_handle& handle,
                                         [](ErrorStatus error, const hidl_handle& handle,
                                            const sp<IFencedExecutionCallback>& callback) {
                                            const sp<IFencedExecutionCallback>& callback) {
                                             // TODO: fix this once sample driver impl is merged.
                                             if (error != ErrorStatus::DEVICE_UNAVAILABLE) {
                                                 ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, error);
                                                 ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, error);
                                             }
                                             ASSERT_EQ(handle.getNativeHandle(), nullptr);
                                             ASSERT_EQ(handle.getNativeHandle(), nullptr);
                                             ASSERT_EQ(callback, nullptr);
                                             ASSERT_EQ(callback, nullptr);
                                         });
                                         });
    ASSERT_TRUE(ret_null.isOk());
    ASSERT_TRUE(ret_null.isOk());

    native_handle_t* nativeHandle = native_handle_create(1, 0);
    ASSERT_NE(nullptr, nativeHandle);
    nativeHandle->data[0] = -1;
    hidl_handle hidlHandle;
    hidlHandle.setTo(nativeHandle, /*shouldOwn=*/true);
    Return<void> ret_invalid =
            preparedModel->executeFenced(request, {hidlHandle}, V1_2::MeasureTiming::NO,
                                         [](ErrorStatus error, const hidl_handle& handle,
                                            const sp<IFencedExecutionCallback>& callback) {
                                             ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, error);
                                             ASSERT_EQ(handle.getNativeHandle(), nullptr);
                                             ASSERT_EQ(callback, nullptr);
                                         });
    ASSERT_TRUE(ret_invalid.isOk());
}
}


void validateEverything(const sp<IDevice>& device, const Model& model, const Request& request,
void validateEverything(const sp<IDevice>& device, const Model& model, const Request& request,