---
title: BatchedMatMul算子prototxt修改
description: "本章节所有的代码样例都不能直接复制到网络模型中使用，需要用户根据使用的网络模型，自行调整相应参数，比如bottom、top中的参数要和具体网络模型中的bottom、top一一对应，并且bottom和top对应的参数顺序不能更改。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/atctool/atlasatc_16_0051.html
sourcePath: /source/zh/canncommercial/900/devaids/atctool/atlasatc_16_0051.html
indexId: 824859e80d23401ed05e87ca2ea5da97d114dcc8dd3b1b360ba3111dec35689d67
---
# BatchedMatMul算子prototxt修改

本章节所有的代码样例都不能直接复制到网络模型中使用，需要用户根据使用的网络模型，自行调整相应参数，比如bottom、top中的参数要和具体网络模型中的bottom、top一一对应，并且bottom和top对应的参数顺序不能更改。


该算子用于输出两个张量的乘积：y=x1*x2（x1和x2的张量相乘，x1和x2维度必须大于2而小于等于8）。如果网络模型使用该算子，则请参见该章节，修改相应prototxt后，再进行模型转换。

参见caffe.proto文件（该文件路径为${INSTALL_DIR}/include/proto），先在LayerParameter message中添加自定义层参数的声明（如下自定义层在caffe.proto中已经声明，用户无需再次添加）：

```
message LayerParameter {
optional BatchedMatMulParameter batched_matmul_param = 235;
}
```

参见caffe.proto文件，此算子的Type及属性定义如下：

```
message BatchedMatMulParameter{
optional bool adj_x1 = 1 [default = false];
optional bool adj_x2 = 2 [default = false];
}
```

参见支持Caffe算子清单(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/aolapi/operatorlist_00099.html)，BatchedMatMul算子有2个输入，1个输出，基于上述原则，构造的代码样例如下：

```
layer {
name: "batchmatmul"
type: "BatchedMatMul"
bottom: "matmul_data_1"
bottom: "matmul_data_2"
top: "batchmatmul_1"
batched_matmul_param {
adj_x1:false
adj_x2:true
}
}
```

参数解释请参见支持Caffe算子清单(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/aolapi/operatorlist_00099.html)。
