Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Infer Symbolic Shape No.26][BUAA]dropout #67412

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,22 @@ bool CrossOpInferSymbolicShape(pir::Operation *op,
// return true;
// }

bool DropoutOpInferSymbolicShape(
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) {
const symbol::ShapeOrDataDimExprs &x_shape_or_data =
infer_context->GetShapeOrDataForValue(op->operand_source(0));

infer_context->SetShapeOrDataForValue(op->result(0), x_shape_or_data);

Comment on lines +374 to +376
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里虽然不会有data但是最好还是过滤掉,可以下个PR顺带改改

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我在下一个 PR 中修改掉。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我在下一个 PR 中修改掉。

留一下修改PR

if (op->result(1)) {
symbol::TensorShapeOrDataDimExprs mask_shape(x_shape_or_data.shape());
infer_context->SetShapeOrDataForValue(
op->result(1), symbol::ShapeOrDataDimExprs{mask_shape});
}

return true;
}

bool EmbeddingOpInferSymbolicShape(
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) {
const std::vector<symbol::DimExpr> &x_dims =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ OP_DECLARE_INFER_SYMBOLIC_SHAPE(Conv2d)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Conv3d)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Cross)
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(Dot)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Dropout)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Embedding)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(EqualAll)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(SparseWeightEmbedding)
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/ops/yaml/ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,7 @@
intermediate : mask
backward : dropout_grad
traits : pir::SideEffectTrait
interfaces : paddle::dialect::InferSymbolicShapeInterface

- op : edit_distance
args : (Tensor hyps, Tensor refs, Tensor hypslength, Tensor refslength, bool normalized = false)
Expand Down