mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-28 20:11:22 +00:00
### Description Introducing new L1 optimizer to fuse Pad to it's child node if the child node is Conv or MaxPool. Pad -> Conv = Conv Pad -> MaxPool = MaxPool Major Conditions: - It will only fuse for the `Constant` mode of padding. - Conv/MaxPool should not have optional `indices` output tensor - Padding value for non-spatial dimensions should be zero and for spatial dimensions padding values should be positive for `pad` operator. For other conditions please see `SatisfyCondition()` in `pad_fusion.cc`. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
27 lines
No EOL
795 B
C++
27 lines
No EOL
795 B
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
#include "core/optimizer/rewrite_rule.h"
|
|
|
|
namespace onnxruntime {
|
|
/*
|
|
* This fusion submerges a Pad operator to it's child
|
|
* Conv or MaxPool operator, if and only if PadFusion::SatisfyCondition()
|
|
* is true.
|
|
*/
|
|
class PadFusion : public RewriteRule {
|
|
public:
|
|
PadFusion() : RewriteRule("Pad_Fusion") {}
|
|
|
|
std::vector<std::string> TargetOpTypes() const noexcept override {
|
|
return {"Pad"};
|
|
}
|
|
|
|
private:
|
|
bool SatisfyCondition(const Graph& graph, const Node& node, const logging::Logger& logger) const override;
|
|
|
|
Status Apply(Graph& graph, Node& matmul_node, RewriteRuleEffect& rule_effect, const logging::Logger& logger) const override;
|
|
};
|
|
} // namespace onnxruntime
|