diff options
Diffstat (limited to 'tests/nnapi/src/TestValidation.cpp')
-rw-r--r-- | tests/nnapi/src/TestValidation.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/tests/nnapi/src/TestValidation.cpp b/tests/nnapi/src/TestValidation.cpp index 2d605bb7e..19db43800 100644 --- a/tests/nnapi/src/TestValidation.cpp +++ b/tests/nnapi/src/TestValidation.cpp @@ -23,6 +23,9 @@ #include <sys/mman.h> #include <stdio.h> #include <stdlib.h> +// Note: neurun is allow to set activation operand constant only, +// so we change test to set operand #2 to constant. (ANEURALNETWORKS_FUSED_NONE) +// And model's input is changed: [0, 1, 2] -> [0, 1] // This file tests all the validations done by the Neural Networks API. namespace { @@ -84,6 +87,9 @@ class ValidationTestIdentify : public ValidationTestModel { ASSERT_EQ(ANeuralNetworksModel_addOperand(mModel, &tensorType), ANEURALNETWORKS_NO_ERROR); ASSERT_EQ(ANeuralNetworksModel_addOperand(mModel, &scalarType), ANEURALNETWORKS_NO_ERROR); ASSERT_EQ(ANeuralNetworksModel_addOperand(mModel, &tensorType), ANEURALNETWORKS_NO_ERROR); + // neurun is allow to set activation operand constant only + int32_t act = ANEURALNETWORKS_FUSED_NONE; + ASSERT_EQ(ANeuralNetworksModel_setOperandValue(mModel, 2, &act, sizeof(act)), ANEURALNETWORKS_NO_ERROR); uint32_t inList[3]{0, 1, 2}; uint32_t outList[1]{3}; ASSERT_EQ(ANeuralNetworksModel_addOperation(mModel, ANEURALNETWORKS_ADD, 3, inList, 1, @@ -112,12 +118,15 @@ protected: ASSERT_EQ(ANeuralNetworksModel_addOperand(mModel, &tensorType), ANEURALNETWORKS_NO_ERROR); ASSERT_EQ(ANeuralNetworksModel_addOperand(mModel, &scalarType), ANEURALNETWORKS_NO_ERROR); ASSERT_EQ(ANeuralNetworksModel_addOperand(mModel, &tensorType), ANEURALNETWORKS_NO_ERROR); + // neurun is allow to set activation operand constant only + int32_t act = ANEURALNETWORKS_FUSED_NONE; + ASSERT_EQ(ANeuralNetworksModel_setOperandValue(mModel, 2, &act, sizeof(act)), ANEURALNETWORKS_NO_ERROR); uint32_t inList[3]{0, 1, 2}; uint32_t outList[1]{3}; ASSERT_EQ(ANeuralNetworksModel_addOperation(mModel, ANEURALNETWORKS_ADD, 3, inList, 1, outList), ANEURALNETWORKS_NO_ERROR); - ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 3, inList, 1, outList), + ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 2, inList, 1, outList), ANEURALNETWORKS_NO_ERROR); ASSERT_EQ(ANeuralNetworksModel_finish(mModel), ANEURALNETWORKS_NO_ERROR); @@ -390,44 +399,44 @@ TEST_F(ValidationTestModel, CreateCompilation) { } TEST_F(ValidationTestIdentify, Ok) { - uint32_t inList[3]{0, 1, 2}; + uint32_t inList[2]{0, 1}; uint32_t outList[1]{3}; - ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 3, inList, 1, outList), + ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 2, inList, 1, outList), ANEURALNETWORKS_NO_ERROR); ASSERT_EQ(ANeuralNetworksModel_finish(mModel), ANEURALNETWORKS_NO_ERROR); } TEST_F(ValidationTestIdentify, InputIsOutput) { - uint32_t inList[3]{0, 1, 2}; + uint32_t inList[2]{0, 1}; uint32_t outList[2]{3, 0}; - ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 3, inList, 2, outList), + ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 2, inList, 2, outList), ANEURALNETWORKS_BAD_DATA); } TEST_F(ValidationTestIdentify, OutputIsInput) { - uint32_t inList[4]{0, 1, 2, 3}; + uint32_t inList[3]{0, 1, 3}; uint32_t outList[1]{3}; - ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 4, inList, 1, outList), + ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 3, inList, 1, outList), ANEURALNETWORKS_BAD_DATA); } TEST_F(ValidationTestIdentify, DuplicateInputs) { - uint32_t inList[4]{0, 1, 2, 0}; + uint32_t inList[3]{0, 1, 0}; uint32_t outList[1]{3}; - ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 4, inList, 1, outList), + ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 3, inList, 1, outList), ANEURALNETWORKS_BAD_DATA); } TEST_F(ValidationTestIdentify, DuplicateOutputs) { - uint32_t inList[3]{0, 1, 2}; + uint32_t inList[2]{0, 1}; uint32_t outList[2]{3, 3}; - ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 3, inList, 2, outList), + ASSERT_EQ(ANeuralNetworksModel_identifyInputsAndOutputs(mModel, 2, inList, 2, outList), ANEURALNETWORKS_BAD_DATA); } |