38 std::map<std::string, tensor::Shape> &shape_ctx = context->
shape_ctx();
39 std::map<std::string, coco::Bag *> &bag_ctx = context->
bag_ctx();
41 assert(layer.bottom().size() == 1);
42 assert(layer.top().size() == 1);
44 assert(layer.has_pooling_param());
45 const auto ¶m = layer.pooling_param();
49 const auto ifm_name = layer.bottom(0);
50 const auto ifm_shape = shape_ctx.at(ifm_name);
55 const auto ifm_name = layer.bottom(0);
56 const auto ifm_shape = shape_ctx.at(ifm_name);
57 auto ifm_bag = bag_ctx.at(ifm_name);
58 auto ifm_obj =
module->entity()->object()->create<coco::FeatureObject>();
60 ifm_obj->bag(ifm_bag);
64 const auto ofm_name = layer.top(0);
65 const auto ofm_shape = spec.ofm_shape();
66 auto ofm_bag =
module->entity()->bag()->create(num_elements(ofm_shape));
67 auto ofm_obj =
module->entity()->object()->create<coco::FeatureObject>();
69 ofm_obj->bag(ofm_bag);
74 std::map<PoolingMethod, PoolingOpBuilder> builders;
80 auto op =
module->entity()->op()->create<coco::MaxPool2D>();
84 op->window()->height(spec.window_height());
85 op->window()->width(spec.window_width());
87 op->stride()->vertical(spec.vertical_stride());
88 op->stride()->horizontal(spec.horizontal_stride());
90 op->pad()->top(spec.vertical_pad());
91 op->pad()->bottom(spec.vertical_pad());
92 op->pad()->left(spec.horizontal_pad());
93 op->pad()->right(spec.horizontal_pad());
102 auto op =
module->entity()->op()->create<coco::AvgPool2D>();
109 op->window()->height(spec.window_height());
110 op->window()->width(spec.window_width());
112 op->stride()->vertical(spec.vertical_stride());
113 op->stride()->horizontal(spec.horizontal_stride());
115 op->pad()->top(spec.vertical_pad());
116 op->pad()->bottom(spec.vertical_pad());
117 op->pad()->left(spec.horizontal_pad());
118 op->pad()->right(spec.horizontal_pad());
124 auto builder = builders.at(spec.method());
125 auto op = builder(module, spec);
131 blk->instr()->append(ins);
134 bag_ctx[ofm_name] = ofm_bag;
135 shape_ctx[ofm_name] = ofm_shape;
ShapeContext & shape_ctx()