1 // Copyright (C) 2018 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
12 #include <ie_common.h>
13 #include "pugixml.hpp"
14 #include "CPP/tensor.hpp"
16 namespace CLDNNPlugin {
18 using CLDNNCustomLayerPtr = std::shared_ptr<class CLDNNCustomLayer>;
19 using CLDNNCustomLayerMap = std::map<std::string, CLDNNCustomLayerPtr>;
20 class CLDNNCustomLayer{
22 static void LoadFromFile(
23 const std::string configFile,
24 CLDNNCustomLayerMap& customLayers,
25 bool can_be_missed = false);
33 KerenlParam() :type(Input), paramIndex(-1), portIndex(-1),
34 format(cldnn::format::any) {}
45 std::string default_value;
50 const std::string& Name()const { return m_layerName; }
51 const std::string& KernelSource()const { return m_kernelSource; }
52 const std::string& KernelEntry()const { return m_kernelEntry; }
53 const std::vector<KernelDefine>& Defines()const { return m_defines; }
54 const std::string& CompilerOptions()const { return m_compilerOptions; }
55 const std::vector<std::string>& GlobalSizeRules()const { return m_globalSizeRules; }
56 const std::vector<std::string>& LocalSizeRules()const { return m_localSizeRules; }
57 const std::vector<KerenlParam>& KernelParams()const { return m_kernelParams; }
58 const int InputDimSourceIndex() { return m_wgDimInputIdx; }
62 explicit CLDNNCustomLayer(const std::string dirname) : m_configDir(dirname) {}
64 bool Error() const { return m_ErrorMessage.length() > 0; }
65 void LoadSingleLayer(const pugi::xml_node& node);
66 void ProcessKernelNode(const pugi::xml_node& node);
67 void ProcessBuffersNode(const pugi::xml_node& node);
68 void ProcessCompilerOptionsNode(const pugi::xml_node& node);
69 void ProcessWorkSizesNode(const pugi::xml_node& node);
70 static bool IsLegalSizeRule(const std::string& rule);
71 static cldnn::format FormatFromString(const std::string& str);
73 std::string m_configDir;
74 std::string m_layerName;
75 std::string m_kernelSource;
76 std::string m_kernelEntry;
77 std::vector<KernelDefine> m_defines; // <name , take value from> <x,y> --> #define x value_of
78 std::string m_compilerOptions;
80 std::vector<std::string> m_globalSizeRules;
81 std::vector<std::string> m_localSizeRules;
82 std::vector<KerenlParam> m_kernelParams;
83 std::string m_ErrorMessage;
86 }; // namespace CLDNNPlugin