make_node(op_type,inputs,outputs,name=None,doc_string=None,**kwargs) op_type:节点的算子类型 [类型:字符串] 比如Conv、Relu、Add这类,详细可以参考onnx给出的算子列表,这个可以自己赋值,但最好与官网对应上,否则其他框架在跑onnx的时候会不知道这是什么。 inputs:存放节点输入的名字 [类型:字符串列表]...
onnx中的NodeProto 一般用来定义一个计算节点,比如conv,linear,input是repeated类型,意味着是数组,output是repeated类型,意味着是数组,attribute有一个自己的Proto,op_type需要严格根据onnx所提供的Operators写。 onnx中的AttributeProto 一般用来定义一个node的属性。比如说kernel size,比较常见的方式就是把(key, value...
if node.op_type == 'Debug': node.op_type = 'Identity' node.domain = 'ai.onnx' onnx.save(graph, 'debug_new.onnx') 显然,onnx提供了遍历结点并原地修改的功能,只需要将op_type改为Identity,将domain改为ai.onnx就可以被后端正常识别了,甚至你还可以onnxsim再次优化 ,就可以拔出这个Identity,并...
对应上层outputoutput:"/encoder/encoder/layer.11/output/LayerNorm/ReduceMean_1_output_0"#输出节点名,对应下层input,或者模型 outputname:"/encoder/encoder/layer.11/output/LayerNorm/ReduceMean_1"#当前节点名称op_type:"ReduceMean"#当前节点的op 操作attribute {#节点属性name:"axes"type: INTS...
ir_version:8graph{node{input:"a"input:"x"output:"c"op_type:"Mul"}node{input:"c"input:"b"output:"output"op_type:"Add"}name:"linear_func"input{name:"a"type{tensor_type{elem_type:1shape{dim{dim_value:10}dim{dim_value:10}}}input{name:"x"type{tensor_type{elem_type:1shape{dim{...
op_type == 'MatMul': for attr_name, attr_value in node.attribute.items(): if isinstance(attr_value, onnx.TensorProto): if attr_value.data_type == 10: # INT64 # 创建新的TensorProto对象,并将数据类型设置为FP32 new_tensor = onnx.TensorProto() new_tensor.CopyFrom(attr_value) new_...
op_type: "Mul" } node { input: "c" input: "b" output: "output" op_type: "Add" } name: "linear_func" input { name: "a" type { tensor_type { elem_type: 1 shape { dim {dim_value: 10} dim {dim_value: 10} } }
op_type: "Conv" attribute { name: "dilations" ints: 1 ints: 1 type: INTS } attribute { name: "group" i: 1 type: INT } attribute { name: "kernel_shape" ints: 3 ints: 3 type: INTS } attribute { name: "pads" ints: 0 ...
node中的op_type是节点类型,所有类型可以参考https://github.com/onnx/onnx/blob/f2daca5e9b9315a2034da61c662d2a7ac28a9488/docs/Operators.md。name是节点名称,它跟op_type是不同的。attribute是节点属性,在Conv_0中就是2D卷积的各种属性,比如"group"是分组卷积,"kernel_shape"是卷积核尺寸等等。initializer...
INFO: onnx_op_type: Gather onnx_op_name: /backbone/backbone.0/Gather INFO: input_name.1: /backbone/backbone.0/Resize_output_0 shape: [1, 1, 15, 15] dtype: float32 INFO: input_name.2: /Constant_output_0 shape: [] dtype: <class 'numpy.int64'> ...