This commit introduces allocate method in PlaingWeightContext as the
first step toward Bag-level data management.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
virtual ~Data() = default;
// @brief Allocate blob space of 'size' bytes
+ //
+ // WARN Deprecated
virtual coco::BlobID allocate(uint32_t size) = 0;
virtual PlainWeightContext<float> *f32(void) = 0;
{
virtual ~PlainWeightContext() = default;
+ virtual void allocate(const KernelObject *) = 0;
+
// @brief Link pre-allocated blob space (denoted by BlobID) with coco::KernelObject
virtual void link(const BlobID &, const KernelObject *) = 0;
PlainWeightContextImpl(PlainWeightContextImpl &&) = delete;
public:
+ void allocate(const coco::KernelObject *obj)
+ {
+ assert(obj != nullptr);
+ auto bag = obj->bag();
+ assert(bag != nullptr);
+
+ auto id = _blob->allocate(sizeof(T) * bag->size());
+ link(id, obj);
+ }
+
+public:
void link(const coco::BlobID &id, const coco::KernelObject *o)
{
_link[o] = reinterpret_cast<T *>(_blob->at(id));