#include <nncc/core/ADT/tensor/Shape.h>
+#include <map>
+
using namespace nncc::core::ADT;
namespace tflimport
}
/**
+ * @brief Extracts and holds operand(tensor) information such as name and shape
+ */
+class TensorContext
+{
+public:
+ void prepare(const tflite::SubGraph *graph)
+ {
+ for (uint32_t tensor_id = 0; tensor_id < graph->tensors()->size(); ++tensor_id)
+ {
+ auto const tensor_info = graph->tensors()->Get(tensor_id);
+ auto const tensor_name = tensor_info->name()->str();
+ auto const tensor_shape = as_tensor_shape(tensor_info->shape());
+
+ _name_ctx[tensor_id] = tensor_name;
+ _shape_ctx[tensor_id] = tensor_shape;
+ }
+ }
+
+ const std::string &name(uint32_t tensor_id) { return _name_ctx[tensor_id]; }
+ const tensor::Shape &shape(uint32_t tensor_id) { return _shape_ctx[tensor_id]; }
+
+private:
+ std::map<uint32_t, std::string> _name_ctx;
+ std::map<uint32_t, tensor::Shape> _shape_ctx;
+};
+
+/**
+ * @brief Pre-creates coco:Bags for each operands(tensors)
+ */
+class TensorBags
+{
+public:
+ void prepare(const tflite::SubGraph *graph, std::unique_ptr<coco::Module> &m)
+ {
+ for (uint32_t tensor_id = 0; tensor_id < graph->tensors()->size(); ++tensor_id)
+ {
+ auto const tensor_info = graph->tensors()->Get(tensor_id);
+ auto const tensor_shape = as_tensor_shape(tensor_info->shape());
+ auto const tensor_bag = m->entity()->bag()->create(num_elements(tensor_shape));
+
+ _bag_ctx[tensor_id] = tensor_bag;
+ }
+ }
+
+ coco::Bag *bag(int32_t tensor_id) { return _bag_ctx[tensor_id]; }
+
+private:
+ std::map<uint32_t, coco::Bag *> _bag_ctx;
+};
+
+/**
* @brief Class to store context to build IR from tflite
*/
class GraphBuilderContext