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 BUAA No.164】Add psroi_pool op #67361

Merged
merged 21 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ca8d4d7
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
b77200d
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
8acd880
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
17252a9
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
475b75b
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
51cea55
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
5c5109d
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
9556fa9
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
6ae6851
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
db2d1a1
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
c9dadb1
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
dbb94fd
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
e03b31a
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
5642dc4
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 12, 2024
db95617
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 13, 2024
4ef4ded
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 13, 2024
f19b4b2
【Infer Symbolic Shape BUAA No.164】Add psroi_pool op
lwkhahaha Aug 13, 2024
22b63e6
Merge branch 'develop' into psroi_pool_1
lwkhahaha Aug 13, 2024
e7280e4
Update multiary_infer_sym.h
lwkhahaha Aug 15, 2024
66813c4
test
lwkhahaha Aug 15, 2024
61a7372
Merge branch 'develop' into psroi_pool_1
lwkhahaha Aug 16, 2024
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 @@ -1697,12 +1697,65 @@ bool MovingAverageAbsMaxScale_OpInferSymbolicShape(
// return true;
// }

// bool PsroiPoolOpInferSymbolicShape(pir::Operation *op,
// pir::InferSymbolicShapeContext
// *infer_context) {
// // pass
// return true;
// }
bool PsroiPoolOpInferSymbolicShape(
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) {
const auto &x_shape_or_data =
infer_context->GetShapeOrDataForValue(op->operand_source(0));
const std::vector<symbol::DimExpr> &input_dims = x_shape_or_data.shape();
const auto &rois_shape_or_data =
infer_context->GetShapeOrDataForValue(op->operand_source(1));
const std::vector<symbol::DimExpr> &rois_dims = rois_shape_or_data.shape();
PADDLE_ENFORCE_EQ(
input_dims.size(),
4,
phi::errors::InvalidArgument("The format of input tensor is NCHW"));
PADDLE_ENFORCE_EQ(rois_dims.size(),
2,
phi::errors::InvalidArgument(
"ROIs should be a 2-D LoDTensor of shape (num_rois, 4) "
"given as [(x1, y1, x2, y2), ...]"));
infer_context->AddEqualCstr(rois_dims[1], symbol::DimExpr(4));
if (op->operand_source(2)) {
auto &rois_num_shape_or_data =
infer_context->GetShapeOrDataForValue(op->operand_source(2));
const std::vector<symbol::DimExpr> &rois_num_dims =
rois_num_shape_or_data.shape();
PADDLE_ENFORCE_EQ(
rois_num_dims.size(),
1,
phi::errors::InvalidArgument("The second dimension of RoisNum should "
"be 1, but received dimension is %d",
rois_num_dims.size()));
}
int pooled_height =
op->attribute<pir::Int32Attribute>("pooled_height").data();
int pooled_width = op->attribute<pir::Int32Attribute>("pooled_width").data();
int output_channels =
op->attribute<pir::Int32Attribute>("output_channels").data();
auto divisor =
symbol::DimExpr(output_channels * pooled_height * pooled_width);
infer_context->AddEqualCstr(input_dims[1], divisor);
PADDLE_ENFORCE_GT(pooled_height,
0,
phi::errors::InvalidArgument(
"The pooled output height must be greater than 0"));
PADDLE_ENFORCE_GT(pooled_width,
0,
phi::errors::InvalidArgument(
"The pooled output width must be greater than 0"));
PADDLE_ENFORCE_GT(output_channels,
1,
phi::errors::InvalidArgument(
"The pooled output channels must greater than 1"));
std::vector<symbol::DimExpr> out_dims = {
rois_dims[0], output_channels, pooled_height, pooled_width};

infer_context->SetShapeOrDataForValue(
op->result(0),
symbol::ShapeOrDataDimExprs{symbol::TensorShapeOrDataDimExprs(out_dims)});

return true;
}

// bool PyramidHashOpInferSymbolicShape(pir::Operation *op,
// pir::InferSymbolicShapeContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ OP_DECLARE_INFER_SYMBOLIC_SHAPE(MovingAverageAbsMaxScale)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(MovingAverageAbsMaxScale_)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(NearestInterp)
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(Nce)
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(PsroiPool)
OP_DECLARE_INFER_SYMBOLIC_SHAPE(PsroiPool)
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(PyramidHash)
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(QuantizeLinear)
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(QuantizeLinear_)
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 @@ -3671,6 +3671,7 @@
data_type : x
optional : boxes_num
backward : psroi_pool_grad
interfaces : paddle::dialect::InferSymbolicShapeInterface

- op : put_along_axis
args : (Tensor arr, Tensor indices, Tensor values, int axis, str reduce = "assign", bool include_self = true)
Expand Down