Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / mkldnn_plugin / nodes / mkldnn_batchnorm_node.h
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <ie_common.h>
8 #include <mkldnn_node.h>
9 #include <memory>
10 #include <string>
11 #include <vector>
12
13 namespace MKLDNNPlugin {
14
15 class MKLDNNBatchNormalizationNode : public MKLDNNNode {
16 public:
17     MKLDNNBatchNormalizationNode(const InferenceEngine::CNNLayerPtr& layer, const mkldnn::engine& eng);
18
19     ~MKLDNNBatchNormalizationNode() override = default;
20     void initSupportedPrimitiveDescriptors() override;
21     void initOptimalPrimitiveDescriptor() override;
22     void getSupportedDescriptors() override;
23     void createDescriptor(const std::vector<InferenceEngine::TensorDesc>& inputDesc,
24                           const std::vector<InferenceEngine::TensorDesc>& outputDesc) override;
25     void createPrimitive() override;
26     bool created() const override;
27     bool fusedWithScale() const {return fusedWith.size() == 1 && fusedWith[0]->getType() == Depthwise
28                                         && fusedWith[0]->getCnnLayer()->type == "ScaleShift";}
29
30     MKLDNNMemoryDesc getSrcMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx) override;
31     MKLDNNMemoryDesc getDstMemDesc(mkldnn::primitive_desc_iterator &primitive_desc_it, size_t idx) override;
32 private:
33     static Register<MKLDNNBatchNormalizationNode> reg;
34     float eps = 0.0f;
35     MKLDNNMemoryDesc GetVarianceDesc(const mkldnn::memory::primitive_desc& primitive_desc) const;
36     MKLDNNMemoryDesc GetMeanDesc(const mkldnn::memory::primitive_desc& primitive_desc) const;
37     MKLDNNMemoryDesc GetScaleShiftWeightsDesc(const mkldnn::memory::primitive_desc& primitive_desc) const;
38 };
39
40 }  // namespace MKLDNNPlugin
41