21#include "GraphBuilder.h"
30#include <schema_generated.h>
42 auto const options = op->builtin_options_as_Pool2DOptions();
44 if ((options->stride_h() == 0) || (options->stride_w() == 0))
54 assert(context !=
nullptr);
67 assert(opinputs.size() == 1);
68 assert(opoutputs.size() == 1);
70 int ifm_idx = opinputs.at(0);
71 int ofm_idx = opoutputs.at(0);
79 ifm_obj->
bag(ifm_bag);
85 ofm_obj->
bag(ofm_bag);
93 auto *params = op->builtin_options_as_Pool2DOptions();
98 coco_avgpool2d->window()->height(params->filter_height());
99 coco_avgpool2d->window()->width(params->filter_width());
101 coco_avgpool2d->stride()->vertical(params->stride_h());
102 coco_avgpool2d->stride()->horizontal(params->stride_w());
105 pool2D_padding(params, ifm_shape, params->filter_width(), params->filter_height());
107 coco_avgpool2d->pad()->top(padding.
top());
108 coco_avgpool2d->pad()->bottom(padding.
bottom());
109 coco_avgpool2d->pad()->left(padding.
left());
110 coco_avgpool2d->pad()->right(padding.
right());
113 coco_avgpool2d->arg(coco_load);
122 assert(params->fused_activation_function() ==
123 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.
Divisor divisor(void) const
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
uint32_t left(void) const
uint32_t right(void) const
uint32_t bottom(void) const
void build(const tflite::Operator *op, GraphBuilderContext *) const override
bool validate(const tflite::Operator *op) const override
Class to store context to build IR from tflite.
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)
nncc::core::ADT::feature::Shape as_feature_shape(const nncc::core::ADT::tensor::Shape &)
std::vector< int32_t > IndexVector
coco::Padding2D pool2D_padding(const tflite::Pool2DOptions *options, const tensor::Shape &ifm_shape, const int filter_w, const int filter_h)
IndexVector as_index_vector(const flatbuffers::Vector< int32_t > *array)
Converts flatbuffers::Vector to IndexVector.