#include "mir/ops/DepthwiseConv2DOp.h"
#include "mir/ops/MaxPool2DOp.h"
#include "mir/ops/MulOp.h"
-#include "mir/ops/PoolOp.h"
#include "mir/ops/ReluOp.h"
#include "mir/ops/ReshapeOp.h"
#include "mir/ops/SoftmaxOp.h"
_mir2loco_map.emplace(&op, push_node);
}
-void Transformer::visit(mir::ops::PoolOp &op)
-{
- loco::Node *pool_node;
- // Get Input
- auto loco_it = _mir2loco_map.find(op.getInput(0)->getProducer()->getNode());
- assert(loco_it != _mir2loco_map.end()); // can't find the input
- // FeatureEncode
- auto encode_node = createNHWCFeatureEncode(_loco_graph.get());
- encode_node->input(loco_it->second);
-
- switch (op.getPoolingType())
- {
- case mir::ops::PoolOp::PoolingType::AVG:
- {
- auto avg_pool_node = _loco_graph->nodes()->create<loco::AvgPool2D>();
- // Set Input
- avg_pool_node->ifm(encode_node);
- // Set convention (like tensorflow)
- avg_pool_node->convention(loco::AvgPool2D::Convention::Valid);
-
- setupWindow(op.getWindowShape(), avg_pool_node->window());
- setupStride(op.getStrides(), avg_pool_node->stride());
- setupPad(op.getPaddingBefore(), op.getPaddingAfter(), avg_pool_node->pad());
-
- pool_node = avg_pool_node;
- break;
- }
- case mir::ops::PoolOp::PoolingType::MAX:
- {
- auto max_pool_node = _loco_graph->nodes()->create<loco::MaxPool2D>();
- // Set Input
- max_pool_node->ifm(encode_node);
-
- setupWindow(op.getWindowShape(), max_pool_node->window());
- setupStride(op.getStrides(), max_pool_node->stride());
- setupPad(op.getPaddingBefore(), op.getPaddingAfter(), max_pool_node->pad());
-
- pool_node = max_pool_node;
- break;
- }
- case mir::ops::PoolOp::PoolingType::MIN:
- throw std::runtime_error("Min pooling not supported!");
- default:
- assert(false && "Unknown pooling type!");
- }
- // FeatureDecode
- auto decode_node = createNHWCFeatureDecode(_loco_graph.get());
- // Set Input
- decode_node->input(pool_node);
- // Not set Shape
- // Add to map
- _mir2loco_map.emplace(&op, decode_node);
-}
-
void Transformer::visit(mir::ops::ReluOp &op)
{
auto relu_node = _loco_graph->nodes()->create<loco::ReLU>();