static std::unique_ptr<BCHW> create(const nncc::core::ADT::feature::Shape &shape);
};
+/**
+ * @brief BHWC Feature Layout
+ */
+class BHWC : public coco::FeatureLayout
+{
+private:
+ BHWC(uint32_t batch, const nncc::core::ADT::feature::Shape &shape) : _batch{batch}, _shape{shape}
+ {
+ // DO NOTHING
+ }
+
+public:
+ uint32_t batch(void) const override { return _batch; }
+ const nncc::core::ADT::feature::Shape &shape(void) const override { return _shape; }
+
+ coco::ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const override;
+
+private:
+ uint32_t _batch;
+ nncc::core::ADT::feature::Shape _shape;
+
+public:
+ static std::unique_ptr<BHWC> create(const nncc::core::ADT::feature::Shape &shape);
+};
+
} // namespace FeatureLayouts
} // namespace coco
#include "coco/IR/FeatureLayouts.h"
#include <nncc/core/ADT/feature/CHWLayout.h>
+#include <nncc/core/ADT/feature/HWCLayout.h>
using namespace nncc::core::ADT::feature;
} // namespace FeatureLayouts
} // namespace coco
+
+//
+// BHWC Layout
+//
+namespace coco
+{
+namespace FeatureLayouts
+{
+
+ElemID BHWC::at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const
+{
+ static HWCLayout l;
+
+ uint32_t offset = 0;
+ offset += b * num_elements(_shape);
+ offset += l.offset(_shape, ch, row, col);
+
+ return ElemID{offset};
+}
+
+std::unique_ptr<BHWC> BHWC::create(const nncc::core::ADT::feature::Shape &shape)
+{
+ // NOTE It is impossible to use make_unique here as the constructor is private
+ return std::unique_ptr<BHWC>{new BHWC{1, shape}};
+}
+
+} // namespace FeatureLayouts
+} // namespace coco