mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-05 04:17:53 +00:00
1. Use the session logger if it is available. 2. Don't disable warning 4100 globally. We should fix the warnings instead of disabling it.
32 lines
939 B
C++
32 lines
939 B
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
#include "core/optimizer/rewrite_rule.h"
|
|
|
|
namespace onnxruntime {
|
|
|
|
/**
|
|
@Class ShapeToInitializer
|
|
|
|
When the input to a Shape operator is statically known (through shape inference), this rule replaces the Shape node
|
|
with an initializer to the downstream nodes.
|
|
|
|
It is attempted to be triggered only on nodes with op type "Shape".
|
|
*/
|
|
class ShapeToInitializer : public RewriteRule {
|
|
public:
|
|
ShapeToInitializer() noexcept : RewriteRule("ShapeToInitializer") {}
|
|
|
|
std::vector<std::string> TargetOpTypes() const noexcept override {
|
|
return {"Shape"};
|
|
}
|
|
|
|
private:
|
|
bool SatisfyCondition(const Graph& graph, const Node& node, const logging::Logger& logger) const override;
|
|
|
|
Status Apply(Graph& graph, Node& node, RewriteRuleEffect& rule_effect, const logging::Logger& logger) const override;
|
|
};
|
|
|
|
} // namespace onnxruntime
|