#include <nncc/core/ADT/kernel/Accessor.h>
#include <nncc/core/ADT/kernel/Reader.h>
+#include <memory>
+
namespace coco
{
// @brief Link pre-allocated blob space (denoted by BlobID) with coco::KernelObject
virtual void link(const BlobID &, const KernelObject *) = 0;
- virtual nncc::core::ADT::kernel::Accessor<T> *access(const KernelObject *) = 0;
- virtual const nncc::core::ADT::kernel::Reader<T> *read(const KernelObject *) const = 0;
+ virtual std::unique_ptr<nncc::core::ADT::kernel::Accessor<T>> access(const KernelObject *) = 0;
+ virtual std::unique_ptr<nncc::core::ADT::kernel::Reader<T>> read(const KernelObject *) const = 0;
};
} // namespace coco
public:
void link(const coco::BlobID &id, const coco::KernelObject *o)
{
- using nncc::core::ADT::kernel::Overlay;
- using nncc::core::ADT::kernel::NCHWLayout;
-
- auto base = reinterpret_cast<T *>(_blob->at(id));
-
- _link[o] = make_unique<Overlay<T, T *>>(o->shape(), NCHWLayout{}, base);
+ _link[o] = reinterpret_cast<T *>(_blob->at(id));
}
public:
- kernel::Accessor<T> *access(const coco::KernelObject *o) override
+ std::unique_ptr<kernel::Accessor<T>> access(const coco::KernelObject *o) override
{
auto it = _link.find(o);
return nullptr;
}
- return it->second.get();
+ auto base = it->second;
+
+ using nncc::core::ADT::kernel::Overlay;
+ using nncc::core::ADT::kernel::NCHWLayout;
+
+ return make_unique<Overlay<T, T *>>(o->shape(), NCHWLayout{}, base);
}
public:
- const kernel::Reader<T> *read(const coco::KernelObject *o) const override
+ std::unique_ptr<kernel::Reader<T>> read(const coco::KernelObject *o) const override
{
auto it = _link.find(o);
return nullptr;
}
- return it->second.get();
+ auto base = it->second;
+
+ using nncc::core::ADT::kernel::Overlay;
+ using nncc::core::ADT::kernel::NCHWLayout;
+
+ return make_unique<Overlay<T, T *>>(o->shape(), NCHWLayout{}, base);
}
private:
BlobContext *const _blob;
private:
- std::map<const coco::KernelObject *, std::unique_ptr<kernel::Overlay<T, T *>>> _link;
+ std::map<const coco::KernelObject *, T *> _link;
};
} // namespace