#ifndef __COCO_IR_BAG_H__
#define __COCO_IR_BAG_H__
-#include "coco/IR/BagInfo.forward.h"
-
#include "coco/IR/Entity.h"
#include "coco/IR/ObjectSet.h"
#include "coco/IR/DepSet.h"
friend class Output;
public:
- explicit Bag(std::unique_ptr<BagInfo> &&info);
+ explicit Bag(uint32_t size);
public:
~Bag();
void output(Output *o) { _output = o; }
private:
- std::unique_ptr<BagInfo> _info;
-
-private:
uint32_t _size;
/** @brief Links to dependent Object(s) */
+++ /dev/null
-#ifndef __COCO_IR_BAG_INFO_FORWARD_H__
-#define __COCO_IR_BAG_INFO_FORWARD_H__
-
-namespace coco
-{
-
-class BagInfo;
-
-} // namespace coco
-
-#endif // __COCO_IR_BAG_INFO_FORWARD_H__
+++ /dev/null
-#ifndef __COCO_IR_BAG_INFO_H__
-#define __COCO_IR_BAG_INFO_H__
-
-#include "coco/IR/Bag.h"
-#include "coco/IR/DepSet.h"
-#include "coco/IR/ReadSet.h"
-#include "coco/IR/UpdateSet.h"
-
-#include <set>
-
-#include <cstdint>
-
-namespace coco
-{
-
-class BagMask
-{
-public:
- enum Field
- {
- Input,
- Output,
- };
-
-public:
- // @brief Mask field F
- void set(const Field &f) { _masked.insert(f); }
- // @brief Unmask field F
- void unset(const Field &f) { _masked.erase(f); }
-
-public:
- // @brief Return true if field F is masked
- bool masked(const Field &f) { return _masked.find(f) != _masked.end(); }
-
-private:
- std::set<Field> _masked;
-};
-
-/***
- * @brief The internal state of Bag
- *
- * BagInfo is the internal state of Bag. IR elements such as Object can access BagInfo,
- * but users (who builds IR) can't access.
- */
-class BagInfo
-{
-public:
- BagInfo(uint32_t size) : _size{size}
- {
- // DO NOTHING
- }
-
-public:
- uint32_t size(void) const { return _size; }
-
-private:
- uint32_t const _size;
-
-public:
- BagMask *mask(void) { return &_mask; }
- const BagMask *mask(void) const { return &_mask; }
-
-private:
- BagMask _mask;
-};
-
-} // namespace coco
-
-#endif // __COCO_IR_BAG_INFO_H__
#define __COCO_IR_DEP_H__
#include "coco/IR/Bag.h"
-#include "coco/IR/BagInfo.forward.h"
#include "coco/IR/Object.forward.h"
#include "coco/ADT/PtrLink.h"
#include "coco/IR/Op.forward.h"
#include "coco/IR/Bag.h"
-#include "coco/IR/BagInfo.forward.h"
#include "coco/IR/Object.forward.h"
#include "coco/IR/ObjectInfo.forward.h"
#define __COCO_IR_READ_H__
#include "coco/IR/Bag.h"
-#include "coco/IR/BagInfo.forward.h"
#include "coco/ADT/PtrLink.h"
#define __COCO_IR_UPDATE_H__
#include "coco/IR/Bag.h"
-#include "coco/IR/BagInfo.forward.h"
#include "coco/ADT/PtrLink.h"
#include "coco/IR/Bag.h"
-#include "coco/IR/BagInfo.h"
#include "coco/IR/Object.h"
#include "coco/IR/Read.h"
namespace coco
{
-Bag::Bag(std::unique_ptr<BagInfo> &&info) : _info{std::move(info)} { _size = _info->size(); }
+Bag::Bag(uint32_t size) : _size{size}
+{
+ // DO NOTHING
+}
Bag::~Bag()
{
#include "coco/IR/Bag.h"
-#include "coco/IR/BagInfo.h"
-
-#include <nncc/foundation/Memory.h>
#include <gtest/gtest.h>
-using nncc::foundation::make_unique;
-
TEST(IR_BAG, ctor_should_set_size)
{
- coco::Bag b{make_unique<coco::BagInfo>(3)};
+ coco::Bag b{3};
ASSERT_EQ(b.size(), 3);
+++ /dev/null
-#include "coco/IR/BagInfo.h"
-
-#include <gtest/gtest.h>
-
-TEST(IR_BAG_INFO, constructor)
-{
- coco::BagInfo info{16};
-
- ASSERT_NE(info.mask(), nullptr);
- ASSERT_FALSE(info.mask()->masked(coco::BagMask::Input));
- ASSERT_FALSE(info.mask()->masked(coco::BagMask::Output));
-}
#include "coco/IR/BagManager.h"
-#include "coco/IR/BagInfo.h"
#include <nncc/foundation/Memory.h>
Bag *BagManager::create(uint32_t size)
{
- auto info = nncc::foundation::make_unique<BagInfo>(size);
- auto info_ptr = info.get();
-
- auto bag = nncc::foundation::make_unique<Bag>(std::move(info));
- auto bag_ptr = bag.get();
-
- modulize(bag_ptr);
-
+ auto bag = nncc::foundation::make_unique<Bag>(size);
+ modulize(bag.get());
return take(std::move(bag));
}
#include "coco/IR/BagManager.h"
-#include "coco/IR/BagInfo.h"
#include <gtest/gtest.h>
#include "coco/IR/Dep.h"
-#include "coco/IR/BagInfo.h"
#include "coco/IR/Object.h"
#include <cassert>
#include "coco/IR/Dep.h"
-#include "coco/IR/BagInfo.h"
#include "coco/IR/BagManager.h"
#include "coco/IR/ObjectInfo.h"
#include "coco/IR/Input.h"
-#include "coco/IR/BagInfo.h"
#include <cassert>
#include "coco/IR/Input.h"
#include "coco/IR/BagManager.h"
-#include "coco/IR/BagInfo.h"
#include <nncc/core/ADT/tensor/IndexEnumerator.h>
#include "coco/IR/Object.h"
-#include "coco/IR/BagInfo.h"
#include "coco/IR/ObjectInfo.h"
#include "coco/IR/Def.h"
#include "coco/IR/Object.h"
#include "coco/IR/ObjectInfo.h"
#include "coco/IR/BagManager.h"
-#include "coco/IR/BagInfo.h"
#include <nncc/foundation/Memory.h>
#include "coco/IR/Output.h"
-#include "coco/IR/BagInfo.h"
namespace coco
{
#include "coco/IR/Output.h"
#include "coco/IR/BagManager.h"
-#include "coco/IR/BagInfo.h"
#include <nncc/core/ADT/tensor/IndexEnumerator.h>
#include "coco/IR/Read.h"
-#include "coco/IR/BagInfo.h"
#include <cassert>
#include "coco/IR/Read.h"
-#include "coco/IR/BagInfo.h"
#include "coco/IR/BagManager.h"
#include "Reader.mock.h"
return ins;
}
-protected:
- coco::PtrLink<coco::Bag, coco::BagInfo> bag_link;
-
private:
std::vector<std::unique_ptr<coco::Instr>> _allocated;
};
#include "coco/IR/Update.h"
-#include "coco/IR/BagInfo.h"
#include <cassert>
#include "coco/IR/Update.h"
-#include "coco/IR/BagInfo.h"
#include "coco/IR/BagManager.h"
#include "Update.mock.h"