Skip to content
Snippets Groups Projects
Commit f01d1116 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Producers should remain outside the micro-graph

parent 5accc679
No related branches found
No related tags found
1 merge request!11Removed padding from conv and pool and added Pad operator
Pipeline #32636 failed
...@@ -296,18 +296,16 @@ inline std::shared_ptr<Node> PaddedConv(DimSize_t in_channels, ...@@ -296,18 +296,16 @@ inline std::shared_ptr<Node> PaddedConv(DimSize_t in_channels,
const std::array<std::array<DimSize_t, 2>, DIM> &padding_dims = {0}, const std::array<std::array<DimSize_t, 2>, DIM> &padding_dims = {0},
const std::array<DimSize_t, DIM> &dilation_dims = create_array<DimSize_t,DIM>(1)) const std::array<DimSize_t, DIM> &dilation_dims = create_array<DimSize_t,DIM>(1))
{ {
auto pad = Pad<DIM>(padding_dims, (!name.empty()) ? name + "_pad" : ""); // Construct micro-graph
auto conv = Conv<DIM>(in_channels, out_channels, kernel_dims, (!name.empty()) ? name + "_conv" : "", stride_dims, dilation_dims); auto pad = std::make_shared<Node>(std::make_shared<Pad_Op<static_cast<DimIdx_t>(DIM)>>(padding_dims, PadBorderType::Constant, 0.0), (!name.empty()) ? name + "_pad" : "");
pad->addChild(conv); auto conv = std::make_shared<Node>(std::make_shared<Conv_Op<static_cast<DimIdx_t>(DIM)>>(in_channels, out_channels, kernel_dims, stride_dims, dilation_dims), (!name.empty()) ? name + "_conv" : "");
// Graph has to be created manually in order to exclude Producers from the graph
auto graph = std::make_shared<GraphView>();
graph->add(pad);
graph->add(conv, false); // exclude Producers, as they should be inputs of the meta-op
// Need to specify the ordered list of input operators // Need to specify the ordered list of input operators
const std::vector<NodePtr> orderedInputNodes = {pad, conv}; const std::vector<NodePtr> orderedInputNodes = {pad, conv};
return std::make_shared<Node>(std::make_shared<MetaOperator_Op>("PaddedConv", graph, orderedInputNodes), name);
auto metaOp = std::make_shared<Node>(std::make_shared<MetaOperator_Op>("PaddedConv", Sequential({pad, conv}), orderedInputNodes), name);
addProducer(metaOp, 1, append(out_channels, append(in_channels, kernel_dims)), "w");
addProducer(metaOp, 2, {out_channels}, "b");
return metaOp;
} }
template <DimSize_t DIM> template <DimSize_t DIM>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment