static std::unique_ptr<NCHW> create(const nncc::core::ADT::kernel::Shape &shape);
};
+/**
+ * @brief NHWC Kernel Layout
+ */
+class NHWC final : public KernelLayout
+{
+private:
+ NHWC(const nncc::core::ADT::kernel::Shape &shape) : _shape{shape}
+ {
+ // DO NOTHING
+ }
+
+public:
+ const nncc::core::ADT::kernel::Shape &shape(void) const override { return _shape; }
+
+ ElemID at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const override;
+
+private:
+ nncc::core::ADT::kernel::Shape _shape;
+
+public:
+ static std::unique_ptr<NHWC> create(const nncc::core::ADT::kernel::Shape &shape);
+};
+
} // namespace KernelLayouts
} // namespace coco
#include "coco/IR/KernelLayouts.h"
#include <nncc/core/ADT/kernel/NCHWLayout.h>
+#include <nncc/core/ADT/kernel/NHWCLayout.h>
#include <cassert>
} // namespace KernelLayouts
} // namespace coco
+
+//
+// NHWC Layout
+//
+namespace coco
+{
+namespace KernelLayouts
+{
+
+ElemID NHWC::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const
+{
+ static NHWCLayout l;
+ return ElemID{l.offset(_shape, n, ch, row, col)};
+}
+
+std::unique_ptr<NHWC> NHWC::create(const nncc::core::ADT::kernel::Shape &shape)
+{
+ // NOTE It is impossible to use make_unique here as the constructor is private
+ return std::unique_ptr<NHWC>{new NHWC{shape}};
+}
+
+} // namespace KernelLayouts
+} // namespace coco