#include "coco/IR/ElemID.h"
#include <nncc/core/ADT/feature/Shape.h>
+#include <nncc/core/ADT/feature/Layout.h>
#include <vector>
ElemID &at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col);
ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const;
+ void reorder(const nncc::core::ADT::feature::Layout &l);
+
private:
uint32_t offset(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const;
return _layout->at(0, ch, row, col);
}
-void FeatureObject::reorder(const nncc::core::ADT::feature::Layout &l)
-{
- for (uint32_t ch = 0; ch < shape().depth(); ++ch)
- {
- for (uint32_t row = 0; row < shape().height(); ++row)
- {
- for (uint32_t col = 0; col < shape().width(); ++col)
- {
- at(ch, row, col) = ElemID{l.offset(shape(), ch, row, col)};
- }
- }
- }
-}
+void FeatureObject::reorder(const nncc::core::ADT::feature::Layout &l) { _layout->reorder(l); }
} // namespace coco
#include <nncc/core/ADT/feature/CHWLayout.h>
+#include <cassert>
+
using nncc::core::ADT::feature::num_elements;
namespace coco
return _content.at(offset(b, ch, row, col));
}
+void GenericFeatureLayout::reorder(const nncc::core::ADT::feature::Layout &l)
+{
+ assert(_batch == 1);
+
+ for (uint32_t ch = 0; ch < shape().depth(); ++ch)
+ {
+ for (uint32_t row = 0; row < shape().height(); ++row)
+ {
+ for (uint32_t col = 0; col < shape().width(); ++col)
+ {
+ at(0, ch, row, col) = ElemID{l.offset(shape(), ch, row, col)};
+ }
+ }
+ }
+}
+
} // namespace coco