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

Commit 199aa864 authored by Miao Wang's avatar Miao Wang
Browse files

Add FusedActivationFunc enum and renamed certain operations.

  - Add "_2D" to CONV, DEPTHWISE_CONV, AVG_POOL, MAX_POOL, and L2_POOL,
    since they are only supposed to do 2D computation.
  - Remove CAST, GATHER, SPLIT.
  - Also update the tests to reflect the changes.

Bug: 63905942
Test: mm
Test: NeuralNetworksTests pass for both CPU path and sample hidl driver.
Change-Id: I5bcf219c4c6cd4f866c1023d1f35cdc83ca69a85
parent e1b1788b
Loading
Loading
Loading
Loading
+37 −32
Original line number Diff line number Diff line
@@ -44,38 +44,43 @@ enum OperandType : uint32_t {
enum OperationType : uint32_t {
    OEM_OPERATION                = 0,
    ADD                          = 1,
    AVERAGE_POOL                 = 2,
    CAST                         = 3,
    CONCATENATION                = 4,
    CONV                         = 5,
    DEPTHWISE_CONV               = 6,
    DEPTH_TO_SPACE               = 7,
    DEQUANTIZE                   = 8,
    EMBEDDING_LOOKUP             = 9,
    FAKE_QUANT                   = 10,
    FLOOR                        = 11,
    FULLY_CONNECTED              = 12,
    GATHER                       = 13,
    HASHTABLE_LOOKUP             = 14,
    L2_NORMALIZATION             = 15,
    L2_POOL                      = 16,
    LOCAL_RESPONSE_NORMALIZATION = 17,
    LOGISTIC                     = 18,
    LSH_PROJECTION               = 19,
    LSTM                         = 20,
    MAX_POOL                     = 21,
    MUL                          = 22,
    RELU                         = 23,
    RELU1                        = 24,
    RELU6                        = 25,
    RESHAPE                      = 26,
    RESIZE_BILINEAR              = 27,
    RNN                          = 28,
    SOFTMAX                      = 29,
    SPACE_TO_DEPTH               = 30,
    SPLIT                        = 31,
    SVDF                         = 32,
    TANH                         = 33,
    AVERAGE_POOL_2D              = 2,
    CONCATENATION                = 3,
    CONV_2D                      = 4,
    DEPTHWISE_CONV_2D            = 5,
    DEPTH_TO_SPACE               = 6,
    DEQUANTIZE                   = 7,
    EMBEDDING_LOOKUP             = 8,
    FAKE_QUANT                   = 9,
    FLOOR                        = 10,
    FULLY_CONNECTED              = 11,
    HASHTABLE_LOOKUP             = 12,
    L2_NORMALIZATION             = 13,
    L2_POOL_2D                   = 14,
    LOCAL_RESPONSE_NORMALIZATION = 15,
    LOGISTIC                     = 16,
    LSH_PROJECTION               = 17,
    LSTM                         = 18,
    MAX_POOL_2D                  = 19,
    MUL                          = 20,
    RELU                         = 21,
    RELU1                        = 22,
    RELU6                        = 23,
    RESHAPE                      = 24,
    RESIZE_BILINEAR              = 25,
    RNN                          = 26,
    SOFTMAX                      = 27,
    SPACE_TO_DEPTH               = 28,
    SVDF                         = 29,
    TANH                         = 30,
};

// Fused activation functions
enum FusedActivationFunc : int32_t {
    NONE  = 0,
    RELU  = 1,
    RELU1 = 2,
    RELU6 = 3,
};

// Two special values that can be used instead of a regular poolIndex.
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ Model createTestModel() {
    std::vector<uint8_t> operandValues(
        reinterpret_cast<const uint8_t*>(operand2Data.data()),
        reinterpret_cast<const uint8_t*>(operand2Data.data()) + size);
    int32_t activation[1] = {0};
    int32_t activation[1] = {static_cast<int32_t>(FusedActivationFunc::NONE)};
    operandValues.insert(operandValues.end(), reinterpret_cast<const uint8_t*>(&activation[0]),
                         reinterpret_cast<const uint8_t*>(&activation[1]));

+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ using ::android::hardware::neuralnetworks::V1_0::IDevice;
using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
using ::android::hardware::neuralnetworks::V1_0::Capabilities;
using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
using ::android::hardware::neuralnetworks::V1_0::Model;
using ::android::hardware::neuralnetworks::V1_0::OperationType;
using ::android::hardware::neuralnetworks::V1_0::PerformanceInfo;