GenericKernelLayout(const nncc::core::ADT::kernel::Shape &shape);
public:
+ static const KernelLayout::ID *uid(void);
+ const KernelLayout::ID *id(void) const override { return uid(); }
+
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);
*/
struct KernelLayout
{
+ struct ID
+ {
+ virtual ~ID() = default;
+ };
+
virtual ~KernelLayout() = default;
+ /**
+ * @brief Return the identifier of each layout
+ *
+ * REQUIRED
+ *
+ * Given l1 and l2 of KernelLayout * type,
+ * typeid(*l1) == typeif(*l2) SHOULD hold if l1->id() == l2->id() holds.
+ */
+ virtual const ID *id(void) const = 0;
+
virtual const nncc::core::ADT::kernel::Shape &shape(void) const = 0;
virtual ElemID at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const = 0;
}
public:
+ static const KernelLayout::ID *uid(void);
+ const KernelLayout::ID *id(void) const override { return uid(); }
+
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;
}
public:
+ static const KernelLayout::ID *uid(void);
+ const KernelLayout::ID *id(void) const override { return uid(); }
+
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;
_content.resize(num_elements(_shape));
}
+const KernelLayout::ID *GenericKernelLayout::uid(void)
+{
+ struct LayoutID final : public KernelLayout::ID
+ {
+ };
+ static LayoutID id;
+ return &id;
+}
+
ElemID &GenericKernelLayout::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col)
{
return _content.at(l.offset(_shape, n, ch, row, col));
namespace KernelLayouts
{
+const KernelLayout::ID *NCHW::uid(void)
+{
+ struct LayoutID final : public KernelLayout::ID
+ {
+ };
+ static LayoutID id;
+ return &id;
+}
+
ElemID NCHW::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const
{
static NCHWLayout l;
namespace KernelLayouts
{
+const KernelLayout::ID *NHWC::uid(void)
+{
+ struct LayoutID final : public KernelLayout::ID
+ {
+ };
+ static LayoutID id;
+ return &id;
+}
+
ElemID NHWC::at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const
{
static NHWCLayout l;