您好,对于“torch.einsum()算子不支持”,建议通过以小算子拼接方式实现。步骤如下:1.进入pytorch docker环境,在[代码]中添加einsum2. 编译catch:[代码]展开
ST-GCN中的torch.einsum()算子不支持,使用的matmul() + torch.sum()替换展开
您好,对于“torch.einsum()算子不支持”,建议通过以小算子拼接方式实现。步骤如下:
1.进入pytorch docker环境,在
/torch/src/catch/torch_mlu/tools/template/jit/mlu_supported_ops.h
中添加einsum
2. 编译catch:
cd /torch/src/catch #建议安装在catch目录下 virtualenv venv/pytorch -p /usr/bin/python3.6 source venv/pytorch/bin/activate #激活虚拟环境' cd catch/script export PYTORCH_HOME=your pytorch path #/torch/src/pytorch ./apply_patches_to_pytorch.sh cd /torch/src/pytorch pip install -r requirements.txt # 安装依赖包 pip install ninja python setup.py install cd catch pip install -r requirements.txt # 安装依赖包 python setup.py install
self.qconfig = {'iteration': 1, 'firstconv':False}self.quantized_model =mlu_quantize.quantize_dynamic_mlu(self.model, self.qconfig, dtype='int8',gen_quant=True)self.quantized_model = self.quantized_model.cpu().eval().float()展开
检查一下量化的模型和输入是否都在cpu上,量化时不应该调到torch_mlu::conv2d,用的是cpu上原生conv算子。量化流程可参考https://www.cambricon.com/docs/pytorch/pytorch_11_tools/Pytorch_tools.html#id4 生成量话模型章节
网络是双流图卷积(ST-GCN),输入模型是两个不同维度的tensor.
self.qconfig = {'iteration': 1, 'firstconv':False}
self.quantized_model =mlu_quantize.quantize_dynamic_mlu(self.model, self.qconfig, dtype='int8',gen_quant=True)
self.quantized_model = self.quantized_model.cpu().eval().float()
请登录后评论