forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lowing shape_optimization_pass to paddle/pir/ directory (PaddlePaddle…
…#63572) * update * to trigger CI * fix paddle::dialect namespace * fix * change dir * fix
- Loading branch information
1 parent
7c6d7d7
commit b631ac7
Showing
17 changed files
with
98 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
paddle/pir/include/dialect/shape/interface/infer_symbolic_shape/infer_symbolic_shape.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include "paddle/pir/include/dialect/shape/utils/shape_analysis.h" | ||
|
||
// Type inference is currently modelled executionally for operation creation | ||
// using the `InferMetaInterface`. While `InferSymbolicShapeInterface` is used | ||
// to implement the shape and element type inference. The return type can often | ||
// be deduced from the deduced return shape and elemental type (queryable from | ||
// `InferSymbolicShapeInterface`) and so type inference for tensor types can be | ||
// implemented with `InferSymbolicShapeInterface`. | ||
|
||
namespace pir { | ||
|
||
class InferSymbolicShapeInterface | ||
: public pir::OpInterfaceBase<InferSymbolicShapeInterface> { | ||
public: | ||
/// Defined these methods with the interface. | ||
struct Concept { | ||
explicit Concept(bool (*infer_symbolic_shapes)( | ||
pir::Operation *op, pir::ShapeConstraintIRAnalysis *shape_analysis)) | ||
: infer_symbolic_shapes(infer_symbolic_shapes) {} | ||
bool (*infer_symbolic_shapes)( | ||
pir::Operation *op, pir::ShapeConstraintIRAnalysis *shape_analysis); | ||
}; | ||
|
||
template <class ConcreteOp> | ||
struct Model : public Concept { | ||
static inline bool InferSymbolicShape( | ||
pir::Operation *op, pir::ShapeConstraintIRAnalysis *shape_analysis) { | ||
return op->dyn_cast<ConcreteOp>().InferSymbolicShape(shape_analysis); | ||
} | ||
|
||
Model() : Concept(InferSymbolicShape) {} | ||
}; | ||
|
||
/// Constructor | ||
InferSymbolicShapeInterface(pir::Operation *op, Concept *impl) | ||
: pir::OpInterfaceBase<InferSymbolicShapeInterface>(op), impl_(impl) {} | ||
|
||
bool InferSymbolicShape(pir::ShapeConstraintIRAnalysis *shape_analysis); | ||
|
||
private: | ||
Concept *impl_; | ||
}; | ||
|
||
} // namespace pir | ||
|
||
IR_DECLARE_EXPLICIT_TYPE_ID(pir::InferSymbolicShapeInterface) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters