21#include "GraphBuilder.h"
29#include <schema_generated.h>
41 assert(context !=
nullptr);
55 assert(opinputs.size() == 2);
56 assert(opoutputs.size() == 1);
59 auto *params = op->builtin_options_as_SubOptions();
60 tflite::ActivationFunctionType activation = tflite::ActivationFunctionType_NONE;
62 if (
auto *params = op->builtin_options_as_SubOptions())
64 activation = params->fused_activation_function();
66 assert(activation == tflite::ActivationFunctionType_NONE);
69 std::vector<coco::FeatureObject *> input_objects;
71 for (
auto &input_index : opinputs)
77 input_obj->
bag(input_bag);
80 input_objects.emplace_back(input_obj);
84 int const output_index = opoutputs.
at(0);
88 output_obj->
bag(output_bag);
96 auto coco_sub =
m->entity()->op()->create<
coco::Sub>();
98 coco_sub->
left(left_load);
99 coco_sub->right(right_load);
108 assert(params->fused_activation_function() ==
109 tflite::ActivationFunctionType::ActivationFunctionType_NONE);
OpBuilder op_builder(coco::Module *m)
InstrBuilder instr_builder(coco::Module *m)
coco::Eval * eval(coco::Object *out, coco::Op *op) const
Create "Eval" instruction with a given "Object" and "Op".
OpBuilder & load(coco::Object *obj)
Create "Load" op and push it onto the internal stack.
coco::Op * pop(void)
Pop op from the internal stack.
A collection of (abstracted) elements of the same type.
A unit of (grouped) instructions.
void append(Child *child)
static std::unique_ptr< BHWC > create(const nncc::core::ADT::feature::Shape &shape)
FeatureMap values (used in CNN)
const FeatureLayout * layout(void) const
Top-level element of coco IR which represents a neural network.
coco::Bag * bag(void) const
Element-wise subtraction.
Class to store context to build IR from tflite.
void build(const tflite::Operator *op, GraphBuilderContext *) const override
Pre-creates coco:Bags for each operands(tensors)
coco::Bag * bag(int32_t tensor_id)
Extracts and holds operand(tensor) information such as name, shape, and type.
const tensor::Shape & shape(uint32_t tensor_id)
const luci_interpreter::RuntimeShape output_shape
nncc::core::ADT::feature::Shape as_feature_shape(const nncc::core::ADT::tensor::Shape &)
std::vector< int32_t > IndexVector
IndexVector as_index_vector(const flatbuffers::Vector< int32_t > *array)
Converts flatbuffers::Vector to IndexVector.
virtual ElemID at(uint32_t b, uint32_t ch, uint32_t row, uint32_t col) const =0