--- /dev/null
+#ifndef __COCO_IR_CONV2D_H__
+#define __COCO_IR_CONV2D_H__
+
+#include "coco/IR/Op.h"
+#include "coco/IR/KernelObject.h"
+#include "coco/IR/Padding2D.h"
+#include "coco/IR/UseSlot.h"
+
+namespace coco
+{
+
+/**
+ * @brief 2D Convolution over 3D Feature Map with 4D kernel
+ *
+ * NOTE IFM and OFM are implicit. Only 4D kernel is explicit in this class
+ * TODO Decide source code layout policy and extract this class if necessary
+ */
+class Conv2D : public Op, public Object::Use
+{
+public:
+ explicit Conv2D(const PtrLink<Op, Instr> *, const PtrLink<Object, ObjectInfo> *);
+
+public:
+ std::set<Object *> uses(void) const override;
+
+public:
+ Conv2D *asConv2D(void) override { return this; }
+ const Conv2D *asConv2D(void) const override { return this; }
+
+public:
+ Instr *loc(void) override { return parent(); }
+
+private:
+ UseSlot<KernelObject> _ker;
+
+public:
+ KernelObject *ker(void) const { return _ker.value(); }
+ void ker(KernelObject *ker);
+
+public:
+ Padding2D *pad(void) { return &_pad; }
+ const Padding2D *pad(void) const { return &_pad; }
+
+private:
+ const PtrLink<Op, Instr> *const _op_link;
+
+private:
+ void get(const PtrLink<Op, Instr> **out) const override { *out = _op_link; }
+
+private:
+ Padding2D _pad;
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_CONV2D_H__
} // namespace coco
-#include "coco/IR/KernelObject.h"
-#include "coco/IR/Padding2D.h"
-#include "coco/IR/UseSlot.h"
-
-namespace coco
-{
-
-/**
- * @brief 2D Convolution over 3D Feature Map with 4D kernel
- *
- * NOTE IFM and OFM are implicit. Only 4D kernel is explicit in this class
- * TODO Decide source code layout policy and extract this class if necessary
- */
-class Conv2D : public Op, public Object::Use
-{
-public:
- explicit Conv2D(const PtrLink<Op, Instr> *, const PtrLink<Object, ObjectInfo> *);
-
-public:
- std::set<Object *> uses(void) const override;
-
-public:
- Conv2D *asConv2D(void) override { return this; }
- const Conv2D *asConv2D(void) const override { return this; }
-
-public:
- Instr *loc(void) override { return parent(); }
-
-private:
- UseSlot<KernelObject> _ker;
-
-public:
- KernelObject *ker(void) const { return _ker.value(); }
- void ker(KernelObject *ker);
-
-public:
- Padding2D *pad(void) { return &_pad; }
- const Padding2D *pad(void) const { return &_pad; }
-
-private:
- const PtrLink<Op, Instr> *const _op_link;
-
-private:
- void get(const PtrLink<Op, Instr> **out) const override { *out = _op_link; }
-
-private:
- Padding2D _pad;
-};
-
-} // namespace coco
-
#endif // __COCO_IR_OP_H__
#define __COCO_IR_OP_MANAGER_H__
#include "coco/IR/Op.h"
+#include "coco/IR/Conv2D.h"
#include "coco/IR/Instr.forward.h"
#include "coco/IR/Object.forward.h"
--- /dev/null
+#include "coco/IR/Conv2D.h"
+
+namespace coco
+{
+
+Conv2D::Conv2D(const PtrLink<Op, Instr> *op_link, const PtrLink<Object, ObjectInfo> *obj_link)
+ : _op_link{op_link}, _ker{obj_link, this}
+{
+ // DO NOTHING
+}
+
+std::set<Object *> Conv2D::uses(void) const
+{
+ std::set<Object *> res;
+
+ if (ker())
+ {
+ res.insert(ker());
+ }
+
+ return res;
+}
+
+void Conv2D::ker(KernelObject *ker) { _ker.value(ker); }
+
+} // namespace coco
-#include "coco/IR/Op.h"
+#include "coco/IR/Conv2D.h"
#include "coco/IR/ObjectManager.h"
#include <vector>
ASSERT_EQ(mutable_base->asConv2D(), immutable_base->asConv2D());
}
-//
-// Conv2D
-//
namespace
{
struct IsConv2D : public coco::Op::DefaultVisitor<bool>
#include "coco/IR/Op.h"
-//
-// Op
-//
#include <cassert>
namespace coco
return op_link->find(this);
}
} // namespace coco
-//
-// Conv2D
-//
-namespace coco
-{
-
-Conv2D::Conv2D(const PtrLink<Op, Instr> *op_link, const PtrLink<Object, ObjectInfo> *obj_link)
- : _op_link{op_link}, _ker{obj_link, this}
-{
- // DO NOTHING
-}
-
-std::set<Object *> Conv2D::uses(void) const
-{
- std::set<Object *> res;
-
- if (ker())
- {
- res.insert(ker());
- }
-
- return res;
-}
-
-void Conv2D::ker(KernelObject *ker) { _ker.value(ker); }
-
-} // namespace coco