} // namespace coco
#include "coco/IR/KernelObject.h"
+#include "coco/IR/UseSlot.h"
namespace coco
{
* 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
+class Conv2D : public Op, public Object::Use
{
public:
struct Param
};
public:
- explicit Conv2D(const PtrLink<Op, Instr> *, const Param &);
+ explicit Conv2D(const PtrLink<Op, Instr> *, const PtrLink<Object, ObjectInfo> *, const Param &);
public:
std::set<Object *> uses(void) const override;
const Conv2D *asConv2D(void) const override { return this; }
private:
- KernelObject *_ker;
+ UseSlot<KernelObject> _ker;
public:
- KernelObject *ker(void) const { return _ker; }
+ KernelObject *ker(void) const { return _ker.value(); }
void ker(KernelObject *ker);
private:
namespace coco
{
-Conv2D::Conv2D(const PtrLink<Op, Instr> *op_link, const Param &) : _op_link{op_link}, _ker{nullptr}
+Conv2D::Conv2D(const PtrLink<Op, Instr> *op_link, const PtrLink<Object, ObjectInfo> *obj_link,
+ const Param &)
+ : _op_link{op_link}, _ker{obj_link, this}
{
// NOTE Currently, Param class is just a placeholder
}
{
std::set<Object *> res;
- if (_ker)
+ if (ker())
{
- res.insert(_ker);
+ res.insert(ker());
}
return res;
}
-void Conv2D::ker(KernelObject *ker) { _ker = ker; }
+void Conv2D::ker(KernelObject *ker) { _ker.value(ker); }
} // namespace coco
protected:
coco::Conv2D *allocate(const coco::Conv2D::Param ¶m)
{
- auto op = new coco::Conv2D{&op_link, param};
+ auto op = new coco::Conv2D{&op_link, &obj_link, param};
_allocated.emplace_back(op);
return op;
}
ASSERT_NE(uses.find(obj), uses.end());
}
+
+ // ker method should enlist op itself as a user of a given kernel object
+ ASSERT_EQ(obj->user()->size(), 1);
+ ASSERT_EQ(obj->user()->count(op), 1);
}
TEST_F(Conv2DTest, accept)
Conv2D *OpManager::create(const Conv2D::Param ¶m)
{
- return take(make_unique<Conv2D>(_op_link, param));
+ return take(make_unique<Conv2D>(_op_link, _obj_link, param));
}
} // namespace coco