mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-26 19:52:38 +00:00
This PR adds below shape related fusions, which is helpful for some transformer models: - ShapeInputMerge is to merge all Shape nodes' input NodeArg to a single one (the 1st one on topo order) if they have the same shape value. This helps CSE fusion to merge more nodes. - CSE fusion to support scalar tensor as attribute value. This is mainly to support ConstantOfShape node.
23 lines
769 B
C++
23 lines
769 B
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
#include "core/optimizer/graph_transformer.h"
|
|
|
|
namespace onnxruntime {
|
|
|
|
/**
|
|
@Class ShapeInputMerge
|
|
Merge all shape inputs having same shape value to a single shape input.
|
|
This change will not affect the performance, but it open chances for CSE fusion to merge nodes.
|
|
*/
|
|
class ShapeInputMerge : public GraphTransformer {
|
|
public:
|
|
ShapeInputMerge(const InlinedHashSet<std::string_view>& compatible_execution_providers = {}) noexcept
|
|
: GraphTransformer("ShapeInputMerge", compatible_execution_providers) {}
|
|
|
|
Status ApplyImpl(Graph& graph, bool& modified, int graph_level, const logging::Logger& logger) const override;
|
|
};
|
|
|
|
} // namespace onnxruntime
|