单算子Json文件配置
配置文件支持定义多组算子Json文件配置,一组配置包括算子类型、算子输入和输出信息、视算子情况决定是否包括属性信息,举例如下(用户请根据实际情况进行修改):
- format为ND:
[ { "op": "GEMM", "input_desc": [ { "format": "ND", "shape": [16, 16], "type": "float16" }, { "format": "ND", "shape": [16, 16], "type": "float16" }, { "format": "ND", "shape": [16, 16], "type": "float16" }, { "format": "ND", "shape": [], "type": "float16" }, { "format": "ND", "shape": [], "type": "float16" } ], "output_desc": [ { "format": "ND", "shape": [16, 16], "type": "float16" } ], "attr": [ { "name": "transpose_a", "type": "bool", "value": false }, { "name": "transpose_b", "type": "bool", "value": false } ] } ]
- format为NCHW:
[ { "op": "Conv2D", "input_desc": [ { "format": "NCHW", "shape": [1, 3, 16, 16], "type": "float16" }, { "format": "NCHW", "shape": [3, 3, 3, 3], "type": "float16" } ], "output_desc": [ { "format": "NCHW", "shape": [1, 3, 16, 16], "type": "float16" } ], "attr": [ { "name": "strides", "type": "list_int", "value": [1, 1, 1, 1] }, { "name": "pads", "type": "list_int", "value": [1, 1, 1, 1] }, { "name": "dilations", "type": "list_int", "value": [1, 1, 1, 1] } ] } ]
- 多组算子Json文件配置。如果Json文件配置了多组算子,则模型转换完成后,会生成多组算子对应的.om离线模型文件,分别以序号0_xx,1_xx,...形式呈现。如下配置文件只是样例,请根据实际情况进行修改。
[ { "op": "MatMul", "input_desc": [ { "format": "ND", "shape": [ 16, 16 ], "type": "float16" }, ... ], "output_desc": [ { "format": "ND", "shape": [ 16, 16 ], "type": "float16" } ], "attr": [ { "name": "alpha", "type": "float", "value": 1.0 }, ... ] }, { "op": "MatMul", "input_desc": [ { "format": "ND", "shape": [ 256, 256 ], "type": "float16" }, ... ], "output_desc": [ { "format": "ND", "shape": [ 256, 256 ], "type": "float16" } ], "attr": [ { "name": "alpha", "type": "float", "value": 1.0 }, ... ] } ]
Json文件由OpDesc的数组构成,参数解释如下:
属性名 |
类型 |
说明 |
是否必填 |
---|---|---|---|
op |
string |
算子类型。 |
是 |
input_desc |
TensorDesc数组 |
算子输入描述。 |
是 |
output_desc |
TensorDesc数组 |
算子输出描述。 |
是 |
attr |
Attr数组 |
算子属性。 |
否 |
属性名 |
类型 |
说明 |
是否必填 |
---|---|---|---|
format |
string |
Tensor的排布格式,配置为算子原始框架支持的format。 支持的format如下:
|
是 |
type |
string |
Tensor的数据格式,支持的type如下:
|
是 |
shape |
int数组 |
Tensor的shape,例如[1, 224, 224, 3]。 |
是 |
name |
string |
Tensor的名称。 如果算子的输入为动态输入,则需要设置该字段。如ConcatD算子在算子原型中,其动态输入定义为: DYNAMIC_INPUT(input_values, …),则此处需要设置为”input_values0”, “input_values1”,…。 |
否 |
属性名 |
类型 |
说明 |
是否必填 |
---|---|---|---|
name |
string |
属性名。 |
是 |
type |
string |
属性值的类型,支持的类型有:
|
是 |
value |
由type的取值决定 |
属性值,根据type不同,属性值不同:
|
是 |
