40{
41 assert(context != nullptr);
42
45 TensorContext &tensor_context = context->tensor();
46 TensorBags &bags = context->bags();
47
50
51
52
53
54
55 assert(opinputs.size() == 2);
56 assert(opoutputs.size() == 1);
57
58
59 auto *params = op->builtin_options_as_SubOptions();
60 tflite::ActivationFunctionType activation = tflite::ActivationFunctionType_NONE;
61
62 if (auto *params = op->builtin_options_as_SubOptions())
63 {
64 activation = params->fused_activation_function();
65 }
66 assert(activation == tflite::ActivationFunctionType_NONE);
67
68
69 std::vector<coco::FeatureObject *> input_objects;
70
71 for (auto &input_index : opinputs)
72 {
73
74 const tensor::Shape &input_shape = tensor_context.shape(input_index);
76 coco::Bag *input_bag = bags.bag(input_index);
77 input_obj->
bag(input_bag);
79
80 input_objects.emplace_back(input_obj);
81 }
82
83
84 int const output_index = opoutputs.
at(0);
87 coco::Bag *output_bag = bags.bag(output_index);
88 output_obj->
bag(output_bag);
90
91
94
95
96 auto coco_sub =
m->entity()->op()->create<
coco::Sub>();
97
98 coco_sub->
left(left_load);
99 coco_sub->right(right_load);
100
101
103
104
106
107
108 assert(params->fused_activation_function() ==
109 tflite::ActivationFunctionType::ActivationFunctionType_NONE);
110}
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.
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