Add PACK operation to NNAPI feature level 6.
Cherrypicked from Ic15d047b70c62437b4f0db6f2ca10127591ae07c
Bug: 206089870
Test: m -j NeuralNetworksTest_static
Test: VtsHalNeuralnetworksTargetTest
Change-Id: Ic15d047b70c62437b4f0db6f2ca10127591ae07c
Merged-In: Ic15d047b70c62437b4f0db6f2ca10127591ae07c
(cherry picked from commit 0af4ac2ec4bc4f0d95ad412480593710260af6e8)
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl
index 4259143..2eff11b 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl
@@ -137,4 +137,5 @@
FILL = 100,
RANK = 101,
BATCH_MATMUL = 102,
+ PACK = 103,
}
diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl
index 435cc76..3499fc1 100644
--- a/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl
+++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl
@@ -5165,4 +5165,53 @@
* c_o = r_y if adj_y else c_y
*/
BATCH_MATMUL = 102,
+
+ /**
+ * Packs N input tensors (N >= 1) of rank R into one output tensor of rank R+1.
+ * The tensors are packed along a given axis.
+ *
+ * The input tensors must have identical {@link OperandType} and dimensions.
+ *
+ * For example, suppose there are N input tensors of shape (A, B, C).
+ * If axis is 0, the output tensor will have shape (N, A, B, C).
+ * If axis is 1, the output tensor will have shape (A, N, B, C).
+ *
+ * All dimensions through the axis dimension determine the output tile count;
+ * the remaining dimensions determine the tile shape.
+ *
+ * Return to the example of N input tensors of shape (A, B, C).
+ * If axis is 0, there are N tiles in the output, each of shape (A, B, C).
+ * If axis is 1, there are A*N tiles in the output, each of shape (B, C).
+ *
+ * The coordinates of a tile within the output tensor are (t[0],...,t[axis]).
+ * The coordinates of a tile within an input tensor are (t[0],...,t[axis-1]).
+ * (If axis is 0, an input tensor consists of a single tile.)
+ * If we index input tensors starting with 0 (rather than by operand number),
+ * then output_tile[t[0],...,t[axis]] = input_tile[t[axis]][t[0],...,t[axis-1]].
+ * That is, all output tile coordinates except for the axis coordinate select
+ * the corresponding location within some input tensor; and the axis coordinate
+ * selects the input tensor.
+ *
+ * Supported tensor {@link OperandType}:
+ * * {@link OperandType::TENSOR_FLOAT16}
+ * * {@link OperandType::TENSOR_FLOAT32}
+ * * {@link OperandType::TENSOR_QUANT8_ASYMM}
+ * * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED}
+ * * {@link OperandType::TENSOR_INT32}
+ *
+ * Supported input tensor rank: from 1
+ *
+ * Inputs:
+ * * 0: A scalar of type {@link OperandType::INT32}, specifying
+ * the axis along which to pack. The valid range is [0, R+1).
+ * * 1 ~ N: Input tensors to be packed together.
+ * For {@link OperandType::TENSOR_QUANT8_ASYMM} and
+ * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensors,
+ * the scales and zeroPoint must be the same for all input tensors,
+ * and will be the same for the output tensor.
+ *
+ * Outputs:
+ * * 0: The packed tensor.
+ */
+ PACK = 103,
}