From 5beb57edf190e9a15ea56f9a0cdff6f43150acc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guanghui=20Ren=28=E4=BB=BB=E5=B9=BF=E8=BE=89=29?= Date: Wed, 21 Oct 2020 17:46:29 +0800 Subject: [PATCH 1/2] Fix parse bug https://github.com/microsoft/MMdnn/issues/882 --- mmdnn/conversion/pytorch/pytorch_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmdnn/conversion/pytorch/pytorch_graph.py b/mmdnn/conversion/pytorch/pytorch_graph.py index 91136209..f5140d59 100644 --- a/mmdnn/conversion/pytorch/pytorch_graph.py +++ b/mmdnn/conversion/pytorch/pytorch_graph.py @@ -132,7 +132,7 @@ def build(self, shape): output_str = node.__str__().split('=')[0] output_shape_str = re.findall(r'[^()!]+', output_str) if len(output_shape_str) > 1: - output_shape = [int(x.replace('!', '')) for x in output_shape_str[1].split(',')] + output_shape = [int(x.replace('!', '').split(':')[0]) for x in output_shape_str[1].split(',')] else: output_shape = None self.shape_dict[node_name] = output_shape From 98cb1b3cfea2cac002951019d2400a2c761c059f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guanghui=20Ren=28=E4=BB=BB=E5=B9=BF=E8=BE=89=29?= Date: Thu, 22 Oct 2020 17:57:49 +0800 Subject: [PATCH 2/2] Update pytorch_graph.py --- mmdnn/conversion/pytorch/pytorch_graph.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mmdnn/conversion/pytorch/pytorch_graph.py b/mmdnn/conversion/pytorch/pytorch_graph.py index f5140d59..fe4de165 100644 --- a/mmdnn/conversion/pytorch/pytorch_graph.py +++ b/mmdnn/conversion/pytorch/pytorch_graph.py @@ -132,7 +132,10 @@ def build(self, shape): output_str = node.__str__().split('=')[0] output_shape_str = re.findall(r'[^()!]+', output_str) if len(output_shape_str) > 1: - output_shape = [int(x.replace('!', '').split(':')[0]) for x in output_shape_str[1].split(',')] + try: + output_shape = [int(x.replace('!', '').split(':')[0]) for x in output_shape_str[1].split(',')] + except: + output_shape = None else: output_shape = None self.shape_dict[node_name] = output_shape