--input_shape

Description

Sets the shape of each input.

See Also

Use the --dynamic_batch_size (setting the batch size), --dynamic_image_size (setting the image size), or --dynamic_dims (setting a specified dimension profile) option to set the shape profile.

Argument

Argument:

  • Static shape. The --input_shape parameter is optional.
    • If the model has a single input, the shape information is "input_name:n,c,h,w".
    • If the model has multiple inputs, the shape information is "input_name1:n1,c1,h1,w1;input_name2:n2,c2,h2,w2".
  • Dynamic shape. The --input_shape parameter must be configured.
    If dimension values of the input data in the original model are not fixed, the model can be converted by setting the shape profile or shape range:
    • Setting the shape profile: The shape profiles include the batch size, image size, and specified dimension profiles.

      When setting --input_shape, set the corresponding dimension value to -1 and use the --dynamic_batch_size (setting the batch size), --dynamic_image_size (setting the image size), or --dynamic_dims (setting a specified dimension profile) option together.

    • Setting the shape range (dynamic shape). The shape range cannot be set for the Atlas 200/300/500 Inference Product

      When setting --input_shape, you can define the corresponding dimension with a range of valid values, for example, 1~10.

      If you do not want to specify the dimension range or value, set this option to -1, indicating that the dimension can use any value greater than or equal to 0.

  • Scalar shape:
    • Non-dynamic profile scenario:

      Shape is a scalar input, which is optional. For example, if the model has two inputs — input_name1 is a scalar with shape in the "[]" format, and input_name2 has the shape of [n2,c2,h2,w2], then the shape information of the model is "input_name1:;input_name2:n2,c2,h2,w2". If the scalar input needs to be configured, leave it empty.

    • Dynamic profile scenario:

      If the model input has both scalar shape and dynamic-profile shape, the scalar input must be configured. For example, if a model has three inputs: A:[-1,c1,h1,w1], B:[], and C:[n2,c2,h2,w2], the shape information is "A:-1,c1,h1,w1;B:;C:n2,c2,h2,w2". Scalar input B must be configured.

Restrictions:

  • If the model has multiple inputs, the specified nodes must be enclosed in double quotation marks ("") and different inputs are separated by semicolons (;). input_name must be the name of a node in the network model before conversion.
  • If a dimension value of the input data for the original model is not fixed, for example, input_name1:? ,h,w,c, input the following information after the model is opened using visualization software such as Netron.

    In this scenario, --input_shape must be configured. You can perform the following operations:
    • Static shape. Set the dimension to a fixed value. For example, input_name1:1,h,w,c is used to convert an original model with a variable dimension in the input data into an offline model with a fixed dimension.
    • Set the shape profile, for example, -1. This is used together with the --dynamic_batch_size option.
  • If the shape range is set to -1, this dimension can take any value greater than or equal to 0. In this scenario, the upper limit of the value is within the expression range of the int64 data type, but is limited by the physical memory size of the host and device. You can increase the memory to support it.
  • If this option is used and the AIPP function is configured by using --insert_op_conf, the width and height of the AIPP output image must be within the range configured in this option.

Suggestions and Benefits

None

Example

  • Static shape. --input_shape is optional.
    For example, if the input shape information of a network consists of two inputs (input_0_0 [16,32,208,208] and input_1_0 [16,64,208,208]), the configuration information of --input_shape is as follows:
    --input_shape="input_0_0:16,32,208,208;input_1_0:16,64,208,208"
  • Dynamic shape. --input_shape must be configured.
    • For details about how to set the batch size, see --dynamic_batch_size.
    • For details about how to set the image size, see --dynamic_image_size.
    • For details about how to set profiles for a specified dimension, see --dynamic_dims.
    • The following is an example of setting the shape range:
      --input_shape="input_0_0:1~10,32,208,208;input_1_0:16,64,100~208,100~208"
  • Scalar shape:
    • Non-dynamic profile scenario:

      Shape is a scalar input, which is optional. For example, if the model has two inputs — input_name1 is a scalar and input_name2 has the shape of [16,32,208,208], the configuration example is as follows:

      --input_shape="input_name1:;input_name2:16,32,208,208"

      In the preceding example, input_name1 is optional.

    • Dynamic profile scenario:

      Shape is a scalar input, which is required. For example, if the model has three inputs and the shape information is A:[-1,32,208,208], B:[], and C:[16,64,208,208], the configuration example is as follows (A is the dynamic profile input, and the batch size profile is used as an example):

      --input_shape="A:-1,32,208,208;B:;C:16,64,208,208"  --dynamic_batch_size="1,2,4"

Applicability

Atlas 200/300/500 Inference Product

Atlas Training Series Product

Dependencies and Restrictions

  • Option Usage:
    • If the dynamic shape range is configured using --input_shape and dynamic AIPP is configured using --insert_op_conf, the width and height of the AIPP output must be within the range specified by --input_shape.
    • If the dynamic shape range is configured using --input_shape and static AIPP is configured using --insert_op_conf:

      If the model has only one input, this scenario is not supported. If the model has multiple inputs, you must configure different input nodes accordingly, such as setting one input node with static AIPP and another node with a dynamic shape.

  • API Usage:

    If this option is used to set the shape range during model conversion, you need to call the aclmdlSetDatasetTensorDesc API to set the actual input tensor description (input shape range) before aclmdlExecute during model inference using an application project. After model execution, call the aclmdlGetDatasetTensorDesc API to obtain the tensor description information dynamically output by the model. Then call the operation API under aclTensorDesc to obtain the memory size occupied by the output tensor data, tensor format, and tensor dimensions.