namespace kernel {
namespace acl {
-// TODO move to separate file
-uint32_t getNumItems(const android::nn::Shape& shape)
-{
- uint32_t items = 1;
- for (uint32_t d = 0; d < shape.dimensions.size(); d++) {
- items *= android::nn::getSizeOfDimension(shape, d);
- }
- return items;
-}
-
-void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape)
-{
- uint32_t N = android::nn::getSizeOfDimension(shape, 0);
- uint32_t H = android::nn::getSizeOfDimension(shape, 1);
- uint32_t W = android::nn::getSizeOfDimension(shape, 2);
- uint32_t C = android::nn::getSizeOfDimension(shape, 3);
-
- for (uint32_t n = 0; n < N; n++) {
- for (uint32_t c = 0; c < C; c++) {
- for (uint32_t h = 0; h < H; h++) {
- for (uint32_t w = 0; w < W; w++) {
- uint32_t soffset = w + (h * W) + (c * W * H) + (n * W * H * C);
- uint32_t doffset = c + (w * C) + (h * C * W) + (n * C * W * H);
- *(nhwc + doffset) = *(nchw + soffset);
- }
- }
- }
- }
-}
-
class Flag
{
public:
// TODO: fix include path in CMakeFiles
#include "../util.h"
-namespace nnfw {
-namespace kernel {
-namespace acl {
-
-// TODO move to separate header
-void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape);
-
-} // namespace acl
-} // namespace kernel
-} // namespace nnfw
-
using namespace nnfw::kernel::acl;
TEST(KernelACL_TC, convFloat32_3x3to1x1)
73.0f, 115.0f, 127.0f, 139.0f, 97.0f
};
float expectData[30];
- NCHW2NHWC(expectNCHW, expectData, outputShape);
+ util::NCHW2NHWC(expectNCHW, expectData, outputShape);
bret = util::compareData(outputData, expectData, outputShape);
EXPECT_EQ(bret, true);
}
73.0f, 115.0f, 127.0f, 139.0f, 97.0f
};
float expectData[30];
- NCHW2NHWC(expectNCHW, expectData, outputShape);
+ util::NCHW2NHWC(expectNCHW, expectData, outputShape);
bret = util::compareData(outputData, expectData, outputShape);
EXPECT_EQ(bret, true);
}
return true;
}
+void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape)
+{
+ uint32_t N = android::nn::getSizeOfDimension(shape, 0);
+ uint32_t H = android::nn::getSizeOfDimension(shape, 1);
+ uint32_t W = android::nn::getSizeOfDimension(shape, 2);
+ uint32_t C = android::nn::getSizeOfDimension(shape, 3);
+
+ for (uint32_t n = 0; n < N; n++) {
+ for (uint32_t c = 0; c < C; c++) {
+ for (uint32_t h = 0; h < H; h++) {
+ for (uint32_t w = 0; w < W; w++) {
+ uint32_t soffset = w + (h * W) + (c * W * H) + (n * W * H * C);
+ uint32_t doffset = c + (w * C) + (h * C * W) + (n * C * W * H);
+ *(nhwc + doffset) = *(nchw + soffset);
+ }
+ }
+ }
+ }
+}
+
} // namespace util
} // namespace acl
} // namespace kernel
bool compareData(const float* result, const float* expected, const android::nn::Shape& shape);
void initData_Increasing(float* data, int num, float value);
+void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape);
+
} // namespace util
} // namespace acl
} // namespace kernel