41{
42 assert(context != nullptr);
43
46 TensorContext &tensor_context = context->tensor();
47 TensorBags &bags = context->bags();
48
51
52
53
54
55
56 assert(opinputs.size() == 2);
57 assert(opoutputs.size() == 1);
58
59 tflite::ActivationFunctionType activation;
60 if (auto *options = op->builtin_options_as_DivOptions())
61 {
62 activation =
options->fused_activation_function();
63 }
64 else
65 {
66 activation = tflite::ActivationFunctionType_NONE;
67 }
68
69
70 assert(activation == tflite::ActivationFunctionType_NONE);
71
72 auto num_idx = opinputs.at(0);
73 auto denom_idx = opinputs.at(1);
74 auto out_idx = opoutputs.at(0);
75
76 const tensor::Shape &num_shape = tensor_context.shape(num_idx);
77 const tensor::Shape &denom_shape = tensor_context.shape(denom_idx);
78 const tensor::Shape &out_shape = tensor_context.shape(out_idx);
79
80
81
83 auto *num_bag = bags.
bag(num_idx);
84 num_obj->bag(num_bag);
86
88 auto *denom_bag = bags.
bag(denom_idx);
89 denom_obj->bag(denom_bag);
91
92
94 auto *out_bag = bags.
bag(out_idx);
95 out_obj->bag(out_bag);
97
98
101
102
103 auto coco_div =
m->entity()->op()->create<
coco::Div>();
104
105
106 coco_div->
left(coco_load_num);
107 coco_div->right(coco_load_denom);
108
109
111
112
114}
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 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)
Top-level element of coco IR which represents a neural network.
coco::Bag * bag(void) const
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.