Publishing R3
[platform/upstream/dldt.git] / model-optimizer / mo / front / mxnet / extractors / broadcast_mul.py
1 """
2  Copyright (c) 2018 Intel Corporation
3
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 """
16
17 from mo.front.common.extractors.utils import layout_attrs
18 from mo.front.common.partial_infer.utils import mark_input_bins
19 from mo.graph.graph import Node
20
21
22 def broadcast_mul_infer(node: Node):
23     in_port = 0
24     if node.in_node(1).value is None:
25         in_port = 1
26     weights_port = 1 - in_port
27     node.out_node(0).shape = node.in_node(in_port).shape
28     mark_input_bins(node, ['weights'], weights_port)
29
30
31 def broadcast_mul_ext(attrs):
32     node_attrs = {
33         'type': 'ScaleShift',
34         'infer': broadcast_mul_infer
35     }
36     node_attrs.update(layout_attrs())
37     return node_attrs