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 const tflite::Pool2DOptions *params = op->builtin_options_as_Pool2DOptions();
95 coco_maxpool2d->
window()->
height(params->filter_height());
96 coco_maxpool2d->
window()->
width(params->filter_width());
102 pool2D_padding(params, ifm_shape, params->filter_width(), params->filter_height());
104 coco_maxpool2d->
pad()->
top(padding.
top());
110 coco_maxpool2d->
arg(coco_load);
119 assert(params->fused_activation_function() ==
120 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)
Evaluate an Object from a given Op.
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
uint32_t vertical(void) const
uint32_t horizontal(void) const
Op * arg(uint32_t n) const final
Return N-th argument.
uint32_t height(void) const
uint32_t width(void) const
Class to store context to build IR from tflite.
bool validate(const tflite::Operator *op) const override
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)
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.
Base interface on all supported NN operations.