---
title: 函数：set_dynamic_hw_size
description: "动态分辨率场景下，在模型执行前调用本接口设置模型推理时输入图片的高和宽。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/aclpythondevg_01_0152.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/aclpythondevg_01_0152.html
indexId: 3d80acfb65abf87b2abef32788011450adfdc6e56a8201a3f5fc0d9ea2f8ca1a75
---
# 函数：set_dynamic_hw_size

#### 功能说明

动态分辨率场景下，在模型执行前调用本接口设置模型推理时输入图片的高和宽。


#### 函数原型

- C函数原型
  1 aclError aclmdlSetDynamicHWSize(uint32_t modelId, aclmdlDataset *dataset, size_t index, uint64_t height, uint64_t width)

- python函数
  1 ret = acl.mdl.set_dynamic_hw_size(model_id, dataset, index, height, width)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| model\_id | int，模型ID。 可在以下接口成功加载模型后获取到模型ID。 acl.mdl.load\_from\_file acl.mdl.load\_from\_mem acl.mdl.load\_from\_file\_with\_mem acl.mdl.load\_from\_mem\_with\_mem |
| dataset | int，表示模型的输入数据。 使用aclmdlDataset类型的数据描述模型推理时的输入数据，输入的内存地址、内存大小用aclDataBuffer类型的数据来描述，具体请参见aclmdlDataset。 |
| index | int，标识动态Batch输入的输入index，需调用acl.mdl.get\_input\_index\_by\_name接口获取，动态Batch和动态分辨率输入的名称固定为“ascend\_mbatch\_shape\_data”，动态AIPP输入的名称固定为“ascend\_dynamic\_aipp\_data”。 |
| height | int，需设置的H值。 |
| width | int，需设置的W值。 此处设置的分辨率（“height”与“width”）只能为模型构建时设置的分辨率档位中的其中一档，也可以调用acl.mdl.get\_dynamic\_hw接口获取指定模型支持的分辨率档位数以及每一档中的宽、高。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 资源参考

接口调用流程与示例，参见动态Batch/动态分辨率/动态维度（设置多档维度值）(https://www.hiascend.comdocument/detail/zh/canncommercial/900/programug/acldevg/aclpythondevg_0046.html)。
