--- /dev/null
+#ifndef __COCO_IR_FEATURE_LAYOUT_H__
+#define __COCO_IR_FEATURE_LAYOUT_H__
+
+#include "coco/IR/ElemID.h"
+
+#include <nncc/core/ADT/feature/Shape.h>
+
+namespace coco
+{
+
+/**
+ * @brief A FeatureLayout connects each feature index to a Bag element
+ *
+ * NOTE FeatureLayout is an immutable interface
+ */
+struct FeatureLayout
+{
+ virtual ~FeatureLayout() = default;
+
+ virtual uint32_t batch(void) const = 0;
+ virtual const nncc::core::ADT::feature::Shape &shape(void) const = 0;
+
+ virtual ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const = 0;
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_FEATURE_LAYOUT_H__
#include "coco/IR/Object.h"
#include "coco/IR/FeatureObjectInfo.h"
+#include "coco/IR/FeatureLayout.h"
#include "coco/IR/GenericFeatureLayout.h"
#include "coco/IR/ElemID.h"
ElemID at(uint32_t ch, uint32_t row, uint32_t col) const;
public:
- const GenericFeatureLayout *layout(void) const { return _layout.get(); }
- void layout(std::unique_ptr<GenericFeatureLayout> &&l) { _layout = std::move(l); }
+ const FeatureLayout *layout(void) const { return _layout.get(); }
+ void layout(std::unique_ptr<FeatureLayout> &&l) { _layout = std::move(l); }
private:
std::unique_ptr<FeatureObjectInfo> _info;
- std::unique_ptr<GenericFeatureLayout> _layout;
+ std::unique_ptr<FeatureLayout> _layout;
};
} // namespace coco
#ifndef __COCO_IR_GENERIC_FEATURE_LAYOUT_H__
#define __COCO_IR_GENERIC_FEATURE_LAYOUT_H__
-#include "coco/IR/ElemID.h"
+#include "coco/IR/FeatureLayout.h"
-#include <nncc/core/ADT/feature/Shape.h>
#include <nncc/core/ADT/feature/Layout.h>
#include <vector>
namespace coco
{
-class GenericFeatureLayout
+class GenericFeatureLayout final : public FeatureLayout
{
public:
GenericFeatureLayout(const nncc::core::ADT::feature::Shape &shape);
public:
- uint32_t batch(void) const { return _batch; }
- const nncc::core::ADT::feature::Shape &shape(void) const { return _shape; }
+ uint32_t batch(void) const override { return _batch; }
+ const nncc::core::ADT::feature::Shape &shape(void) const override { return _shape; }
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;
+ ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const override;
void reorder(const nncc::core::ADT::feature::Layout &l);