| 3265 | } |
| 3266 | |
| 3267 | static void Interpolate1DInferShapeCheck( |
| 3268 | const MetaTensor& x, |
| 3269 | const MetaTensor& out_size, |
| 3270 | const paddle::optional<std::vector<const MetaTensor*>>& size_tensor, |
| 3271 | const MetaTensor& scale_tensor, |
| 3272 | const std::string& data_layout_str, |
| 3273 | int out_d, |
| 3274 | int out_h, |
| 3275 | int out_w, |
| 3276 | const std::vector<double>& scale, |
| 3277 | const std::string& interp_method, |
| 3278 | bool align_corners, |
| 3279 | int align_mode, |
| 3280 | MetaTensor* output, |
| 3281 | MetaConfig config) { |
| 3282 | auto dim_x = x.dims(); |
| 3283 | |
| 3284 | PADDLE_ENFORCE_EQ("linear", |
| 3285 | interp_method, |
| 3286 | common::errors::InvalidArgument( |
| 3287 | "Interpolation method can only be \"linear\" when " |
| 3288 | "Input(X) dimension is 3, but got method = %s .", |
| 3289 | interp_method)); |
| 3290 | const DataLayout data_layout = StringToDataLayout(data_layout_str); |
| 3291 | for (int i = 2; i < dim_x.size(); ++i) { |
| 3292 | PADDLE_ENFORCE_NE(dim_x[i], |
| 3293 | 0, |
| 3294 | common::errors::InvalidArgument( |
| 3295 | "The shape of input(x) should be larger " |
| 3296 | "than 0, but received shape[%d] is %d ", |
| 3297 | i, |
| 3298 | dim_x[i])); |
| 3299 | } |
| 3300 | if (size_tensor && !size_tensor->empty()) { |
| 3301 | // top priority size |
| 3302 | auto inputs_name = size_tensor.get(); |
| 3303 | PADDLE_ENFORCE_EQ( |
| 3304 | inputs_name.size(), |
| 3305 | 1, |
| 3306 | common::errors::InvalidArgument( |
| 3307 | "Input(SizeTensor)'size of Op(interpolate) must be 1. " |
| 3308 | "Attr(out_shape)'s length must be 1 for 3-D input tensor, but got " |
| 3309 | "size = %d .", |
| 3310 | inputs_name.size())); |
| 3311 | DDim dim_out; |
| 3312 | if (data_layout == DataLayout::NCHW) { |
| 3313 | dim_out = {dim_x[0], dim_x[1], out_w}; |
| 3314 | } else { |
| 3315 | dim_out = {dim_x[0], out_w, dim_x[2]}; |
| 3316 | } |
| 3317 | output->set_dims(dim_out); |
| 3318 | output->set_dtype(x.dtype()); |
| 3319 | |
| 3320 | return; |
| 3321 | } |
| 3322 | |
| 3323 | int64_t out_w_tmp = 0; |
| 3324 | if (scale_tensor) { |
no test coverage detected