Parameter | Type | Required | Description | Default value |
model | Multiple types | Yes | The model to be optimized. If the model to be optimized is a TensorFlow model, the following formats are supported: If the model to be optimized is a PyTorch model, the following formats are supported:
| N/A |
optimization_level | STRING | Yes | The optimization level. Valid values (not case-sensitive): | N/A |
device_type | STRING | Yes | The type of the device on which the model is run. Valid values (not case-sensitive): | N/A |
inputs | LIST[STRING] | No | The name of the input node. If you do not specify this parameter, the system automatically infers. | None |
outputs | LIST[STRING] | No | The name of the output node. If you do not specify this parameter, the system automatically infers. | None |
input_shapes | LIST[LIST[STRING]] | No | The possible shapes of input tensors. You can specify this parameter to improve the optimization effects in specific scenarios. The number of elements in an inner list must equal the number of input tensors in a model. Each element is a string that specifies an input shape. Example: '1*512' . If you want to specify multiple groups of possible shapes, you can add elements to the outer list. For example, you need to specify a group of possible shapes for one model and multiple groups of possible shapes for another model. The following sample code provides an example: [['1*512', '3*256']]
-
[
['1*512', '3*256'],
['5*512', '9*256'],
['10*512', '27*256']
]
| None |
input_ranges | LIST[LIST[STRING]] | No | The value ranges of input tensors. The number of elements in an inner list must equal the number of input tensors in a model. Each element is a string that specifies a value range. A value range can be specified by using brackets ([]), real numbers, and characters. Examples: '[1,2]', '[0.3,0.9]', and '[a,f]'. If you want to specify multiple groups of value ranges, you can add elements to the outer list. For example, you need to specify a group of value ranges for one model and multiple groups of value ranges for another model. The following sample code provides an example: [['[0.1,0.4]', '[a,f]']]
-
[
['[0.1,0.4]', '[a,f]'],
['[1.1,1.4]', '[h,l]'],
['[2.1,2.4]', '[n,z]']
]
| None |
test_data | Multiple types | No | The test data that is used to calibrate the run speed of the model. The data type of the test data varies based on the type of the model. The test data used for a TensorFlow model consists of multiple groups of feed_dict arguments. The corresponding data type is LIST[DICT[STRING, np.ndarray]]. The test data used for a PyTorch model consists of multiple tuples of input tensors. The corresponding data type is LIST[Tuple[torch.tensor, ]].
| [] |
calib_data | Multiple types | No | The calibration data that is used to quantize the model. This parameter is required if the optimization_level parameter is set to o2. The data type of the calibration data is the same as that of the test data. | [] |
custom_ops | LIST[STRING] | No | The path of the custom operator library. If the model relies on a custom operator library, you must add the path of the custom operator library to the list. | [] |
verbose | BOOL | No | Specifies whether to display more logs. Valid values: | False |
config | blade.Config | No | The advanced configurations. For more information, see the following table that describes the parameters of blade.Config. | N/A |