---
title: 动态Shape单算子描述文件配置
description: "动态Shape场景，单算子描述文件根据场景不同，内容也有差异，本章节就给出不同场景下的配置样例。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/atctool/atlasatc_16_0036.html
sourcePath: /source/zh/canncommercial/900/devaids/atctool/atlasatc_16_0036.html
indexId: 00f73c1a1e0e3096f9e8dc2884d300916128fc2c1805f433ea17b4cbf6846ff167
---
# 动态Shape单算子描述文件配置

动态Shape场景，单算子描述文件根据场景不同，内容也有差异，本章节就给出不同场景下的配置样例。

- 模型编译时不指定Shape，模型执行时根据输入静态Shape，能推导出具体输出Shape：
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [ { "op": "Add", "name": "add", "input_desc": [ { "format": "ND", "shape": [-1,16], "shape_range": [[0, 32]], "type": "int64" }, { "format": "ND", "shape": [-1,16], "shape_range": [[0, 32]], "type": "int64" } ], "output_desc": [ { "format": "ND", "shape": [-1,16], "shape_range": [[0,32]], "type": "int64" } ] } ]

- 模型编译时不指定Shape，模型执行时根据输入静态Shape和常量，能推导出具体输出Shape：
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 [ { "op": "TopK", "name": "topK", "input_desc": [ { "format": "ND", "shape": [-1], "shape_range": [[1,-1]], "type": "int32" }, { "format": "ND", "shape": [], #推理时会传入常量 "type": "int32" } ], "output_desc": [ { "format": "ND", "shape": [-1], "shape_range": [[1,-1]], "type": "int32" }, { "format": "ND", "shape": [-1], "shape_range": [[1,-1]], "type": "int32" }], "attr": [ { "name": "sorted", "type": "bool", "value": true } ] } ]

- 模型编译时不指定Shape，模型执行时根据输入静态Shape，无法得到算子的准确输出Shape，但可以得到输出Shape的范围。
  该场景下在输出参数output_desc中将算子输出TensorDesc中Shape为动态维度的维度值记为“-1”，并对其“-1”的维度给出shape_range取值范围： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [ { "op": "Where", "name": "where", "input_desc": [ { "format": "ND", "shape": [-1], "shape_range": [[1,-1]], "type": "int32" } ], "output_desc": [ { "format": "ND", "shape": [-1, 1], "shape_range": [[1,-1]], "type": "int64" } ] } ]
