} // namespace coco
-//
-// UnitF
-//
-#include "coco/IR/Op.forward.h"
-
-namespace coco
-{
-
-/**
- * @brief Feature map-to-feature map step with single NN operation
- *
- * TODO Introduce 'FeatureOp' and use it
- */
-class UnitF final : public FeatureInstr
-{
-public:
- UnitF(PtrLink<Op, Instr> *op_link, const PtrLink<Instr, Block> *link,
- const PtrLink<Object, ObjectInfo> *obj_link)
- : FeatureInstr{obj_link}, _op_link{op_link}, _link{link}, _op{nullptr}
- {
- // DO NOTHING
- }
-
-public:
- UnitF *asUnitF(void) override { return this; }
- const UnitF *asUnitF(void) const override { return this; }
-
-public:
- std::set<Bag *> reads(void) const override;
- std::set<Bag *> updates(void) const override;
-
-public:
- Instr *loc(void) override { return this; }
-
-private:
- PtrLink<Op, Instr> *const _op_link;
- const PtrLink<Instr, Block> *const _link;
-
-private:
- void get(const PtrLink<Instr, Block> **out) const override { *out = _link; }
-
-private:
- Op *_op;
-
-public:
- Op *op(void) const { return _op; }
-
-public:
- void op(Op *op);
-};
-
-} // namespace coco
-
#endif // __COCO_IR_INSTR_H__
#define __COCO_IR_INSTR_MANAGER_H__
#include "coco/IR/Instr.h"
+#include "coco/IR/UnitF.h"
#include "coco/IR/Shuffle.h"
#include "coco/IR/Op.forward.h"
--- /dev/null
+#ifndef __COCO_IR_UNIT_F_H__
+#define __COCO_IR_UNIT_F_H__
+
+#include "coco/IR/Instr.h"
+#include "coco/IR/Op.forward.h"
+
+namespace coco
+{
+
+/**
+ * @brief Feature map-to-feature map step with single NN operation
+ *
+ * TODO Introduce 'FeatureOp' and use it
+ */
+class UnitF final : public FeatureInstr
+{
+public:
+ UnitF(PtrLink<Op, Instr> *op_link, const PtrLink<Instr, Block> *link,
+ const PtrLink<Object, ObjectInfo> *obj_link)
+ : FeatureInstr{obj_link}, _op_link{op_link}, _link{link}, _op{nullptr}
+ {
+ // DO NOTHING
+ }
+
+public:
+ UnitF *asUnitF(void) override { return this; }
+ const UnitF *asUnitF(void) const override { return this; }
+
+public:
+ std::set<Bag *> reads(void) const override;
+ std::set<Bag *> updates(void) const override;
+
+public:
+ Instr *loc(void) override { return this; }
+
+private:
+ PtrLink<Op, Instr> *const _op_link;
+ const PtrLink<Instr, Block> *const _link;
+
+private:
+ void get(const PtrLink<Instr, Block> **out) const override { *out = _link; }
+
+private:
+ Op *_op;
+
+public:
+ Op *op(void) const { return _op; }
+
+public:
+ void op(Op *op);
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_UNIT_F_H__
void FeatureInstr::ofm(FeatureObject *ofm) { _ofm.value(ofm); }
} // namespace coco
-
-//
-// UnitF
-//
-#include "coco/IR/Op.h"
-
-#include <cassert>
-
-namespace
-{
-std::set<coco::Bag *> &operator+=(std::set<coco::Bag *> &res, const coco::Object *o)
-{
- if (o != nullptr && o->bag() != nullptr)
- {
- res.insert(o->bag());
- }
- return res;
-}
-} // namespace
-
-namespace coco
-{
-
-std::set<Bag *> UnitF::reads(void) const
-{
- std::set<Bag *> res;
-
- res += ifm();
-
- if (op() != nullptr)
- {
- for (auto obj : op()->uses())
- {
- res += obj;
- }
- }
-
- return res;
-}
-
-std::set<Bag *> UnitF::updates(void) const
-{
- std::set<Bag *> res;
-
- res += ofm();
-
- return res;
-}
-
-void UnitF::op(Op *op)
-{
- if (_op != nullptr)
- {
- assert(_op_link->find(_op) == this);
- _op_link->unset(_op);
- _op = nullptr;
- }
-
- assert(_op == nullptr);
-
- if (op != nullptr)
- {
- assert(_op_link->find(op) == nullptr);
- _op = op;
- _op_link->set(_op, this);
- }
-}
-
-} // namespace coco
ASSERT_EQ(obj->def(), &ins);
}
+// TODO Move these tests into UnitF.test.cpp
+#include "coco/IR/UnitF.h"
#include "coco/IR/Op.h"
namespace
--- /dev/null
+#include "coco/IR/UnitF.h"
+#include "coco/IR/Op.h"
+
+#include <cassert>
+
+namespace
+{
+std::set<coco::Bag *> &operator+=(std::set<coco::Bag *> &res, const coco::Object *o)
+{
+ if (o != nullptr && o->bag() != nullptr)
+ {
+ res.insert(o->bag());
+ }
+ return res;
+}
+} // namespace
+
+namespace coco
+{
+
+std::set<Bag *> UnitF::reads(void) const
+{
+ std::set<Bag *> res;
+
+ res += ifm();
+
+ if (op() != nullptr)
+ {
+ for (auto obj : op()->uses())
+ {
+ res += obj;
+ }
+ }
+
+ return res;
+}
+
+std::set<Bag *> UnitF::updates(void) const
+{
+ std::set<Bag *> res;
+
+ res += ofm();
+
+ return res;
+}
+
+void UnitF::op(Op *op)
+{
+ if (_op != nullptr)
+ {
+ assert(_op_link->find(_op) == this);
+ _op_link->unset(_op);
+ _op = nullptr;
+ }
+
+ assert(_op == nullptr);
+
+ if (op != nullptr)
+ {
+ assert(_op_link->find(op) == nullptr);
+ _op = op;
+ _op_link->set(_op, this);
+ }
+}
+
+} // namespace coco