{
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 const PlainWeightContext<float> *f32(void) const = 0;
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;
-
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;
};
std::unique_ptr<BlobContext> _blob;
std::unique_ptr<PlainWeightContextImpl<float>> _fp32;
- coco::BlobID allocate(uint32_t size) override { return _blob->allocate(size); }
-
coco::PlainWeightContext<float> *f32(void) override { return _fp32.get(); }
const coco::PlainWeightContext<float> *f32(void) const override { return _fp32.get(); }
};
TEST(IR_DATA, allocate_and_link_kernel)
{
+ using nncc::core::ADT::kernel::num_elements;
+
// Create a kernel object
auto module = coco::Module::create();
const nncc::core::ADT::kernel::Shape shape{1, 1, 3, 3};
+ auto bag = module->entity()->bag()->create(9);
auto obj = module->entity()->object()->create(shape);
- auto data = coco::Data::create();
+ obj->bag(bag);
- using nncc::core::ADT::kernel::num_elements;
+ auto data = coco::Data::create();
// Create a blob and link it with kernel object
- auto blob = data->allocate(num_elements(shape) * sizeof(float));
- data->f32()->link(blob, obj);
-
+ data->f32()->allocate(obj);
auto reader = data->f32()->read(obj);
auto accessor = data->f32()->access(obj);