Files
openvino/model-optimizer/extensions/front/onnx/reshape_ext.py
T
Eugeny Volosenkov 6f512142b6 Re-implement onnx old-style extractors with extractor extensions (#3459)
* add class ConcatFrontExtractor for onnx

* add class ConcatFrontExtractor for onnx

* Delete concat from mo/front/onnx/extractor.py

* Add identity, reshape extractors classes for onnx

* import FrontExtractorOp

* Added BatchNormalizationExtractor

* Added extra line

* Fix import modules

* fix caffe bn.py and bn_test.py

* Fix BatchNormInference

* Modify convert_batch_norm

* Modify convert_batch_norm

* Modify bn_test.py

* Fix old comments BN->batchNormInference
2020-12-10 09:24:24 +03:00

36 lines
1.1 KiB
Python

"""
Copyright (C) 2018-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import numpy as np
from mo.front.extractor import FrontExtractorOp
from mo.front.onnx.extractors.utils import onnx_attr
from mo.ops.reshape import Reshape
class ReshapeFrontExtractor(FrontExtractorOp):
op = 'Reshape'
enabled = True
@classmethod
def extract(cls, node):
dim = onnx_attr(node, 'shape', 'ints', None)
if dim is not None:
dim = np.array(dim, dtype=np.int64)
Reshape.update_node_stat(node, {'dim': dim})
else:
Reshape.update_node_stat(node)
return cls.enabled