MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / Interpolate3DInferShapeCheck

Function Interpolate3DInferShapeCheck

paddle/phi/infermeta/multiary.cc:3549–3707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3547}
3548
3549static void Interpolate3DInferShapeCheck(
3550 const MetaTensor& x,
3551 const MetaTensor& out_size,
3552 const paddle::optional<std::vector<const MetaTensor*>>& size_tensor,
3553 const MetaTensor& scale_tensor,
3554 const std::string& data_layout_str,
3555 int out_d,
3556 int out_h,
3557 int out_w,
3558 const std::vector<double>& scale,
3559 const std::string& interp_method,
3560 bool align_corners,
3561 int align_mode,
3562 MetaTensor* output,
3563 MetaConfig config) {
3564 auto dim_x = x.dims();
3565
3566 PADDLE_ENFORCE_EQ(
3567 ("nearest" == interp_method || "trilinear" == interp_method),
3568 true,
3569 common::errors::InvalidArgument(
3570 "Interpolation method can only be \"trilinear\" or "
3571 "\"nearest\" when Input(X) "
3572 "dimension is 5, but got method = %s .",
3573 interp_method));
3574 const DataLayout data_layout = StringToDataLayout(data_layout_str);
3575
3576 for (int i = 2; i < dim_x.size(); ++i) {
3577 PADDLE_ENFORCE_NE(dim_x[i],
3578 0,
3579 common::errors::InvalidArgument(
3580 "The shape of input(x) should be larger "
3581 "than 0, but received shape[%d] is %d ",
3582 i,
3583 dim_x[i]));
3584 }
3585
3586 if (size_tensor && !size_tensor->empty()) {
3587 // top priority size
3588 auto inputs_name = size_tensor.get();
3589 PADDLE_ENFORCE_EQ(
3590 inputs_name.size(),
3591 3,
3592 common::errors::InvalidArgument(
3593 "Input(SizeTensor)'s size of Op(interpolate) must be 3. "
3594 "Attr(out_shape)'s length must be 3 for 5-D input "
3595 "tensor, but got size = %d .",
3596 inputs_name.size()));
3597 DDim dim_out;
3598 if (data_layout == DataLayout::NCHW) {
3599 dim_out = {dim_x[0], dim_x[1], out_d, out_h, out_w};
3600 } else {
3601 dim_out = {dim_x[0], out_d, out_h, out_w, dim_x[4]};
3602 }
3603 output->set_dims(dim_out);
3604 output->set_dtype(x.dtype());
3605 return;
3606 }

Callers 1

InterpolateInferMetaFunction · 0.85

Calls 9

StringToDataLayoutFunction · 0.85
dimsMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
set_dimsMethod · 0.45
set_dtypeMethod · 0.45
dtypeMethod · 0.45
share_lodMethod · 0.45

Tested by

no test coverage detected