Add new op CHANNEL_SHUFFLE.
Add reference CPU implementation for CHANNEL_SHUFFLE with NHWC data
layout and FP32/Quant8 input data type.
Create tests for the new op. Testcases are verified by execution on
Caffe2 lib with the same op. Generate cts/vts tests.
Bug: 113562591
Test: NeuralNetworksTest_static
Change-Id: I4792bab2c3336125e15bd7dae7cf6de022dbacd6
Merged-In: I4792bab2c3336125e15bd7dae7cf6de022dbacd6
(cherry picked from commit 451bee05b2fdcbc3ebc944ae7099f1a36ffa5834)
diff --git a/common/OperationsUtils.cpp b/common/OperationsUtils.cpp
index c6d4665..75bd97d 100644
--- a/common/OperationsUtils.cpp
+++ b/common/OperationsUtils.cpp
@@ -1056,5 +1056,18 @@
output->dimensions = {batches, outHeight, outWidth, channels_out};
return true;
}
+
+bool channelShufflePrepare(const Shape& input, int32_t numGroups, Shape* output) {
+ uint32_t numDimensions = getNumberOfDimensions(input);
+
+ NN_OPS_CHECK(numGroups > 0);
+ NN_OPS_CHECK(getSizeOfDimension(input, numDimensions - 1) % numGroups == 0);
+
+ output->type = input.type;
+ output->dimensions = input.dimensions;
+ output->offset = input.offset;
+ output->scale = input.scale;
+ return true;
+}
} // namespace nn
} // namespace android