---
title: Resize
description: "根据scales调整输入Tensor的大小。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/aolapi/atlasoxol_09_0131.html
sourcePath: /source/zh/canncommercial/900/API/aolapi/atlasoxol_09_0131.html
indexId: 68f1be7e8dd4fa7ec8247feb4df23f74d2b9c3fc1e92a1eeb17437c147d2c77763
---
# Resize

#### 功能

根据scales调整输入Tensor的大小。


#### 输入

- ONNX版本为Opset v10时

  - x：输入Tensor，数据类型：uint8、int8、int16、int32、int64、float16、float、double。
  - scales：与输入x的维度相等的数组。
- ONNX版本为Opset v11/v12/v14/v15/v16/v17时

  - x：输入Tensor，数据类型支持float16、float。
  - sizes：输出Tensor的size。


#### 输出

y：输出尺寸调整后的Tensor，其尺寸由输入的参数scales决定。


#### 属性

- ONNX版本为Opset v10时

  - mode：string，插值算法，取值包括nearest、linear，默认值为nearest。
- ONNX版本为Opset v11/v12/v14/v15/v16/v17时

  - coordinate_transformation_mode：string，定义缩放后图像与原图像的坐标转换，取值包括align_corners、asymmetric、tf_half_pixel_for_nn、tf_crop_and_resize、pytorch_half_pixel、half_pixel，默认值为half_pixel。
  - cubic_coeff_a：三次插值系数，数据类型为float，默认值为-0.75。
  - exclude_outside：超出tensor外的权重，数据类型为int，默认值为0。
  - mode：string，插值算法，取值包括nearest、linear、cubic，默认值为nearest。


#### 约束

- 目前仅支持nearest和linear插值方式来处理图片，并且需要修改模型将输入scales或sizes由placeholder改为const类型，可以使用onnxsimplifier简化模型。
- 当mode为nearest时，仅能采用round_prefer_ceil实现，不支持其余实现如round_prefer_floor。
- 输入是5维时

  - 当前仅支持线性插值模式，即mode=linear，不支持mode=nearest和mode=cubic。
  - 在线性插值模式下，当前仅支持coordinate_transformation_mode=align_corners或pytorch_half_pixel两种坐标模式，其余模式不支持。


#### 支持的ONNX版本

Opset v10/v11/v12/v14/v15/v16/v17/v18
