This commit adds 'num_elements' for kernel shape similarly as
'num_elements' for tensor shape.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
uint32_t _width;
};
+inline uint64_t num_elements(const Shape &shape)
+{
+ return shape.count() * shape.depth() * shape.height() * shape.width();
+}
+
} // namespace kernel
} // namespace ADT
} // namespace core
ASSERT_EQ(shape.height(), H);
ASSERT_EQ(shape.width(), W);
}
+
+TEST(ADT_KERNEL_SHAPE, num_elements)
+{
+ const uint32_t N = 1;
+ const uint32_t C = 3;
+ const uint32_t H = 4;
+ const uint32_t W = 5;
+
+ using nncc::core::ADT::kernel::Shape;
+ using nncc::core::ADT::kernel::num_elements;
+
+ ASSERT_EQ(num_elements(Shape{N, C, H, W}), N * C * H * W);
+}