2 Copyright (c) 2018-2019 Intel Corporation
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
19 from mo.front.common.replacement import FrontReplacementOp
20 from mo.graph.graph import Node, Graph
21 from mo.ops.lin_op import Add, Mul
22 from extensions.ops.mvn import MVN
25 class InstanceNormalization(FrontReplacementOp):
26 ''' Decompose InstanceNormalization to scale*MVN(x) + B
28 There are should be also reshapes added for each scale and B.
30 op = "InstanceNormalization"
33 def replace_op(self, graph: Graph, node: Node):
34 prefix = node.name + '/InstanceNormalization'
35 mvn = MVN(graph, dict(
39 mul = Mul(graph, dict(name=prefix + '/Mul', axis=1))
40 add = Add(graph, dict(name=prefix + '/Add', axis=1))
43 new_subgraph = add.create_node([
45 mvn.create_node([node.in_node(0)]),
51 return [new_subgraph.id]