Partially fixed github issue 18274 (#19758)

This commit is contained in:
Ilya Lavrenov 2023-09-12 07:34:45 +04:00 committed by GitHub
parent 3be8b58d2a
commit 6a1d680f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 220 additions and 207 deletions

View File

@ -20,10 +20,20 @@ class FrontEndManager::Impl {
std::mutex m_loading_mutex;
std::vector<PluginInfo> m_plugins;
/// \brief map of shared object per frontend <frontend_name, frontend_so_ptr>
static std::unordered_map<std::string, std::shared_ptr<void>> m_shared_objects_map;
/// \brief Mutex to guard access the shared object map
static std::mutex m_shared_objects_map_mutex;
// Note, static methods below are required to create an order of initialization of static variables
// e.g. if users (not encouraged) created ov::Model globally, we need to ensure proper order of initialization
/// \return map of shared object per frontend <frontend_name, frontend_so_ptr>
static std::unordered_map<std::string, std::shared_ptr<void>>& get_shared_objects_map() {
static std::unordered_map<std::string, std::shared_ptr<void>> shared_objects_map;
return shared_objects_map;
}
/// \return Mutex to guard access the shared object map
static std::mutex& get_shared_objects_mutex() {
static std::mutex shared_objects_map_mutex;
return shared_objects_map_mutex;
}
public:
Impl() {
@ -37,8 +47,8 @@ public:
fe_obj->m_shared_object = std::make_shared<FrontEndSharedData>(plugin.get_so_pointer());
fe_obj->m_actual = plugin.get_creator().m_creator();
std::lock_guard<std::mutex> guard(m_shared_objects_map_mutex);
m_shared_objects_map.emplace(plugin.get_creator().m_name, fe_obj->m_shared_object);
std::lock_guard<std::mutex> guard(get_shared_objects_mutex());
get_shared_objects_map().emplace(plugin.get_creator().m_name, fe_obj->m_shared_object);
return fe_obj;
}
@ -128,8 +138,8 @@ public:
}
static void shutdown() {
std::lock_guard<std::mutex> guard(m_shared_objects_map_mutex);
m_shared_objects_map.clear();
std::lock_guard<std::mutex> guard(get_shared_objects_mutex());
get_shared_objects_map().clear();
}
private:
@ -224,9 +234,6 @@ private:
}
};
std::unordered_map<std::string, std::shared_ptr<void>> FrontEndManager::Impl::m_shared_objects_map{};
std::mutex FrontEndManager::Impl::m_shared_objects_map_mutex{};
FrontEndManager::FrontEndManager() : m_impl(new Impl()) {}
FrontEndManager::FrontEndManager(FrontEndManager&&) noexcept = default;

View File

@ -9,204 +9,210 @@
namespace ov {
namespace intel_cpu {
const InferenceEngine::details::caseless_unordered_map<std::string, Type> type_to_name_tbl = {
{ "Constant", Type::Input },
{ "Parameter", Type::Input },
{ "Result", Type::Output },
{ "Eye", Type::Eye },
{ "Convolution", Type::Convolution },
{ "GroupConvolution", Type::Convolution },
{ "MatMul", Type::MatMul },
{ "FullyConnected", Type::FullyConnected },
{ "MaxPool", Type::Pooling },
{ "AvgPool", Type::Pooling },
{ "AdaptiveMaxPool", Type::AdaptivePooling},
{ "AdaptiveAvgPool", Type::AdaptivePooling},
{ "Add", Type::Eltwise },
{ "IsFinite", Type::Eltwise },
{ "IsInf", Type::Eltwise },
{ "IsNaN", Type::Eltwise },
{ "Subtract", Type::Eltwise },
{ "Multiply", Type::Eltwise },
{ "Divide", Type::Eltwise },
{ "SquaredDifference", Type::Eltwise },
{ "Maximum", Type::Eltwise },
{ "Minimum", Type::Eltwise },
{ "Mod", Type::Eltwise },
{ "FloorMod", Type::Eltwise },
{ "Power", Type::Eltwise },
{ "PowerStatic", Type::Eltwise },
{ "Equal", Type::Eltwise },
{ "NotEqual", Type::Eltwise },
{ "Greater", Type::Eltwise },
{ "GreaterEqual", Type::Eltwise },
{ "Less", Type::Eltwise },
{ "LessEqual", Type::Eltwise },
{ "LogicalAnd", Type::Eltwise },
{ "LogicalOr", Type::Eltwise },
{ "LogicalXor", Type::Eltwise },
{ "LogicalNot", Type::Eltwise },
{ "Relu", Type::Eltwise },
{ "LeakyRelu", Type::Eltwise },
{ "Gelu", Type::Eltwise },
{ "Elu", Type::Eltwise },
{ "Tanh", Type::Eltwise },
{ "Sigmoid", Type::Eltwise },
{ "Abs", Type::Eltwise },
{ "Sqrt", Type::Eltwise },
{ "Clamp", Type::Eltwise },
{ "Exp", Type::Eltwise },
{ "SwishCPU", Type::Eltwise },
{ "HSwish", Type::Eltwise },
{ "Mish", Type::Eltwise },
{ "HSigmoid", Type::Eltwise },
{ "Round", Type::Eltwise },
{ "PRelu", Type::Eltwise },
{ "Erf", Type::Eltwise },
{ "SoftPlus", Type::Eltwise },
{ "SoftSign", Type::Eltwise },
{ "Select", Type::Eltwise},
{ "Log", Type::Eltwise },
{ "Reshape", Type::Reshape },
{ "Squeeze", Type::Reshape },
{ "Unsqueeze", Type::Reshape },
{ "ShapeOf", Type::ShapeOf },
{ "NonZero", Type::NonZero },
{ "Softmax", Type::Softmax },
{ "Reorder", Type::Reorder },
{ "BatchToSpace", Type::BatchToSpace },
{ "SpaceToBatch", Type::SpaceToBatch },
{ "DepthToSpace", Type::DepthToSpace },
{ "SpaceToDepth", Type::SpaceToDepth },
{ "Roll", Type::Roll },
{ "LRN", Type::Lrn },
{ "Split", Type::Split },
{ "VariadicSplit", Type::Split },
{ "Concat", Type::Concatenation },
{ "ConvolutionBackpropData", Type::Deconvolution },
{ "GroupConvolutionBackpropData", Type::Deconvolution },
{ "StridedSlice", Type::StridedSlice },
{ "Slice", Type::StridedSlice },
{ "Tile", Type::Tile },
{ "ROIAlign", Type::ROIAlign },
{ "ROIPooling", Type::ROIPooling },
{ "PSROIPooling", Type::PSROIPooling },
{ "DeformablePSROIPooling", Type::PSROIPooling },
{ "Pad", Type::Pad },
{ "Transpose", Type::Transpose },
{ "LSTMCell", Type::RNNCell },
{ "GRUCell", Type::RNNCell },
{ "AUGRUCell", Type::RNNCell },
{ "RNNCell", Type::RNNCell },
{ "LSTMSequence", Type::RNNSeq },
{ "GRUSequence", Type::RNNSeq },
{ "AUGRUSequence", Type::RNNSeq },
{ "RNNSequence", Type::RNNSeq },
{ "FakeQuantize", Type::FakeQuantize },
{ "BinaryConvolution", Type::BinaryConvolution },
{ "DeformableConvolution", Type::DeformableConvolution },
{ "TensorIterator", Type::TensorIterator },
{ "Loop", Type::TensorIterator },
{ "ReadValue", Type::MemoryInput}, // for construction from name ctor, arbitrary name is used
{ "Assign", Type::MemoryOutput }, // for construction from layer ctor
{ "Convert", Type::Convert },
{ "NV12toRGB", Type::ColorConvert },
{ "NV12toBGR", Type::ColorConvert },
{ "I420toRGB", Type::ColorConvert },
{ "I420toBGR", Type::ColorConvert },
{ "MVN", Type::MVN},
{ "NormalizeL2", Type::NormalizeL2},
{ "ScatterUpdate", Type::ScatterUpdate},
{ "ScatterElementsUpdate", Type::ScatterElementsUpdate},
{ "ScatterNDUpdate", Type::ScatterNDUpdate},
{ "Interpolate", Type::Interpolate},
{ "ReduceL1", Type::Reduce},
{ "ReduceL2", Type::Reduce},
{ "ReduceLogicalAnd", Type::Reduce},
{ "ReduceLogicalOr", Type::Reduce},
{ "ReduceMax", Type::Reduce},
{ "ReduceMean", Type::Reduce},
{ "ReduceMin", Type::Reduce},
{ "ReduceProd", Type::Reduce},
{ "ReduceSum", Type::Reduce},
{ "ReduceLogSum", Type::Reduce},
{ "ReduceLogSumExp", Type::Reduce},
{ "ReduceSumSquare", Type::Reduce},
{ "Broadcast", Type::Broadcast},
{ "EmbeddingSegmentsSum", Type::EmbeddingSegmentsSum},
{ "EmbeddingBagPackedSum", Type::EmbeddingBagPackedSum},
{ "EmbeddingBagOffsetsSum", Type::EmbeddingBagOffsetsSum},
{ "Gather", Type::Gather},
{ "GatherElements", Type::GatherElements},
{ "GatherND", Type::GatherND},
{ "GridSample", Type::GridSample},
{ "OneHot", Type::OneHot},
{ "RegionYolo", Type::RegionYolo},
{ "ShuffleChannels", Type::ShuffleChannels},
{ "DFT", Type::DFT},
{ "IDFT", Type::DFT},
{ "RDFT", Type::RDFT},
{ "IRDFT", Type::RDFT},
{ "Abs", Type::Math},
{ "Acos", Type::Math},
{ "Acosh", Type::Math},
{ "Asin", Type::Math},
{ "Asinh", Type::Math},
{ "Atan", Type::Math},
{ "Atanh", Type::Math},
{ "Ceil", Type::Math},
{ "Ceiling", Type::Math},
{ "Cos", Type::Math},
{ "Cosh", Type::Math},
{ "Floor", Type::Math},
{ "HardSigmoid", Type::Math},
{ "If", Type::If},
{ "Neg", Type::Math},
{ "Reciprocal", Type::Math},
{ "Selu", Type::Math},
{ "Sign", Type::Math},
{ "Sin", Type::Math},
{ "Sinh", Type::Math},
{ "SoftPlus", Type::Math},
{ "Softsign", Type::Math},
{ "Tan", Type::Math},
{ "CTCLoss", Type::CTCLoss},
{ "Bucketize", Type::Bucketize},
{ "CTCGreedyDecoder", Type::CTCGreedyDecoder},
{ "CTCGreedyDecoderSeqLen", Type::CTCGreedyDecoderSeqLen},
{ "CumSum", Type::CumSum},
{ "DetectionOutput", Type::DetectionOutput},
{ "ExperimentalDetectronDetectionOutput", Type::ExperimentalDetectronDetectionOutput},
{ "LogSoftmax", Type::LogSoftmax},
{ "TopK", Type::TopK},
{ "GatherTree", Type::GatherTree},
{ "GRN", Type::GRN},
{ "Range", Type::Range},
{ "Proposal", Type::Proposal},
{ "ReorgYolo", Type::ReorgYolo},
{ "ReverseSequence", Type::ReverseSequence},
{ "ExperimentalDetectronTopKROIs", Type::ExperimentalDetectronTopKROIs},
{ "ExperimentalDetectronROIFeatureExtractor", Type::ExperimentalDetectronROIFeatureExtractor},
{ "ExperimentalDetectronPriorGridGenerator", Type::ExperimentalDetectronPriorGridGenerator},
{ "ExperimentalDetectronGenerateProposalsSingleImage", Type::ExperimentalDetectronGenerateProposalsSingleImage},
{ "GenerateProposals", Type::GenerateProposals},
{ "ExtractImagePatches", Type::ExtractImagePatches},
{ "NonMaxSuppression", Type::NonMaxSuppression},
{ "NonMaxSuppressionIEInternal", Type::NonMaxSuppression},
{ "MatrixNms", Type::MatrixNms},
{ "MulticlassNms", Type::MulticlassNms},
{ "MulticlassNmsIEInternal", Type::MulticlassNms},
{ "Reference", Type::Reference},
{ "Subgraph", Type::Subgraph},
{ "PriorBox", Type::PriorBox},
{ "PriorBoxClustered", Type::PriorBoxClustered},
{ "Interaction", Type::Interaction},
{ "MHA", Type::MHA},
{ "Unique", Type::Unique},
{ "Ngram", Type::Ngram}
};
using TypeToNameMap = InferenceEngine::details::caseless_unordered_map<std::string, Type>;
static const TypeToNameMap& get_type_to_name_tbl() {
static const TypeToNameMap type_to_name_tbl = {
{ "Constant", Type::Input },
{ "Parameter", Type::Input },
{ "Result", Type::Output },
{ "Eye", Type::Eye },
{ "Convolution", Type::Convolution },
{ "GroupConvolution", Type::Convolution },
{ "MatMul", Type::MatMul },
{ "FullyConnected", Type::FullyConnected },
{ "MaxPool", Type::Pooling },
{ "AvgPool", Type::Pooling },
{ "AdaptiveMaxPool", Type::AdaptivePooling},
{ "AdaptiveAvgPool", Type::AdaptivePooling},
{ "Add", Type::Eltwise },
{ "IsFinite", Type::Eltwise },
{ "IsInf", Type::Eltwise },
{ "IsNaN", Type::Eltwise },
{ "Subtract", Type::Eltwise },
{ "Multiply", Type::Eltwise },
{ "Divide", Type::Eltwise },
{ "SquaredDifference", Type::Eltwise },
{ "Maximum", Type::Eltwise },
{ "Minimum", Type::Eltwise },
{ "Mod", Type::Eltwise },
{ "FloorMod", Type::Eltwise },
{ "Power", Type::Eltwise },
{ "PowerStatic", Type::Eltwise },
{ "Equal", Type::Eltwise },
{ "NotEqual", Type::Eltwise },
{ "Greater", Type::Eltwise },
{ "GreaterEqual", Type::Eltwise },
{ "Less", Type::Eltwise },
{ "LessEqual", Type::Eltwise },
{ "LogicalAnd", Type::Eltwise },
{ "LogicalOr", Type::Eltwise },
{ "LogicalXor", Type::Eltwise },
{ "LogicalNot", Type::Eltwise },
{ "Relu", Type::Eltwise },
{ "LeakyRelu", Type::Eltwise },
{ "Gelu", Type::Eltwise },
{ "Elu", Type::Eltwise },
{ "Tanh", Type::Eltwise },
{ "Sigmoid", Type::Eltwise },
{ "Abs", Type::Eltwise },
{ "Sqrt", Type::Eltwise },
{ "Clamp", Type::Eltwise },
{ "Exp", Type::Eltwise },
{ "SwishCPU", Type::Eltwise },
{ "HSwish", Type::Eltwise },
{ "Mish", Type::Eltwise },
{ "HSigmoid", Type::Eltwise },
{ "Round", Type::Eltwise },
{ "PRelu", Type::Eltwise },
{ "Erf", Type::Eltwise },
{ "SoftPlus", Type::Eltwise },
{ "SoftSign", Type::Eltwise },
{ "Select", Type::Eltwise},
{ "Log", Type::Eltwise },
{ "Reshape", Type::Reshape },
{ "Squeeze", Type::Reshape },
{ "Unsqueeze", Type::Reshape },
{ "ShapeOf", Type::ShapeOf },
{ "NonZero", Type::NonZero },
{ "Softmax", Type::Softmax },
{ "Reorder", Type::Reorder },
{ "BatchToSpace", Type::BatchToSpace },
{ "SpaceToBatch", Type::SpaceToBatch },
{ "DepthToSpace", Type::DepthToSpace },
{ "SpaceToDepth", Type::SpaceToDepth },
{ "Roll", Type::Roll },
{ "LRN", Type::Lrn },
{ "Split", Type::Split },
{ "VariadicSplit", Type::Split },
{ "Concat", Type::Concatenation },
{ "ConvolutionBackpropData", Type::Deconvolution },
{ "GroupConvolutionBackpropData", Type::Deconvolution },
{ "StridedSlice", Type::StridedSlice },
{ "Slice", Type::StridedSlice },
{ "Tile", Type::Tile },
{ "ROIAlign", Type::ROIAlign },
{ "ROIPooling", Type::ROIPooling },
{ "PSROIPooling", Type::PSROIPooling },
{ "DeformablePSROIPooling", Type::PSROIPooling },
{ "Pad", Type::Pad },
{ "Transpose", Type::Transpose },
{ "LSTMCell", Type::RNNCell },
{ "GRUCell", Type::RNNCell },
{ "AUGRUCell", Type::RNNCell },
{ "RNNCell", Type::RNNCell },
{ "LSTMSequence", Type::RNNSeq },
{ "GRUSequence", Type::RNNSeq },
{ "AUGRUSequence", Type::RNNSeq },
{ "RNNSequence", Type::RNNSeq },
{ "FakeQuantize", Type::FakeQuantize },
{ "BinaryConvolution", Type::BinaryConvolution },
{ "DeformableConvolution", Type::DeformableConvolution },
{ "TensorIterator", Type::TensorIterator },
{ "Loop", Type::TensorIterator },
{ "ReadValue", Type::MemoryInput}, // for construction from name ctor, arbitrary name is used
{ "Assign", Type::MemoryOutput }, // for construction from layer ctor
{ "Convert", Type::Convert },
{ "NV12toRGB", Type::ColorConvert },
{ "NV12toBGR", Type::ColorConvert },
{ "I420toRGB", Type::ColorConvert },
{ "I420toBGR", Type::ColorConvert },
{ "MVN", Type::MVN},
{ "NormalizeL2", Type::NormalizeL2},
{ "ScatterUpdate", Type::ScatterUpdate},
{ "ScatterElementsUpdate", Type::ScatterElementsUpdate},
{ "ScatterNDUpdate", Type::ScatterNDUpdate},
{ "Interpolate", Type::Interpolate},
{ "ReduceL1", Type::Reduce},
{ "ReduceL2", Type::Reduce},
{ "ReduceLogicalAnd", Type::Reduce},
{ "ReduceLogicalOr", Type::Reduce},
{ "ReduceMax", Type::Reduce},
{ "ReduceMean", Type::Reduce},
{ "ReduceMin", Type::Reduce},
{ "ReduceProd", Type::Reduce},
{ "ReduceSum", Type::Reduce},
{ "ReduceLogSum", Type::Reduce},
{ "ReduceLogSumExp", Type::Reduce},
{ "ReduceSumSquare", Type::Reduce},
{ "Broadcast", Type::Broadcast},
{ "EmbeddingSegmentsSum", Type::EmbeddingSegmentsSum},
{ "EmbeddingBagPackedSum", Type::EmbeddingBagPackedSum},
{ "EmbeddingBagOffsetsSum", Type::EmbeddingBagOffsetsSum},
{ "Gather", Type::Gather},
{ "GatherElements", Type::GatherElements},
{ "GatherND", Type::GatherND},
{ "GridSample", Type::GridSample},
{ "OneHot", Type::OneHot},
{ "RegionYolo", Type::RegionYolo},
{ "ShuffleChannels", Type::ShuffleChannels},
{ "DFT", Type::DFT},
{ "IDFT", Type::DFT},
{ "RDFT", Type::RDFT},
{ "IRDFT", Type::RDFT},
{ "Abs", Type::Math},
{ "Acos", Type::Math},
{ "Acosh", Type::Math},
{ "Asin", Type::Math},
{ "Asinh", Type::Math},
{ "Atan", Type::Math},
{ "Atanh", Type::Math},
{ "Ceil", Type::Math},
{ "Ceiling", Type::Math},
{ "Cos", Type::Math},
{ "Cosh", Type::Math},
{ "Floor", Type::Math},
{ "HardSigmoid", Type::Math},
{ "If", Type::If},
{ "Neg", Type::Math},
{ "Reciprocal", Type::Math},
{ "Selu", Type::Math},
{ "Sign", Type::Math},
{ "Sin", Type::Math},
{ "Sinh", Type::Math},
{ "SoftPlus", Type::Math},
{ "Softsign", Type::Math},
{ "Tan", Type::Math},
{ "CTCLoss", Type::CTCLoss},
{ "Bucketize", Type::Bucketize},
{ "CTCGreedyDecoder", Type::CTCGreedyDecoder},
{ "CTCGreedyDecoderSeqLen", Type::CTCGreedyDecoderSeqLen},
{ "CumSum", Type::CumSum},
{ "DetectionOutput", Type::DetectionOutput},
{ "ExperimentalDetectronDetectionOutput", Type::ExperimentalDetectronDetectionOutput},
{ "LogSoftmax", Type::LogSoftmax},
{ "TopK", Type::TopK},
{ "GatherTree", Type::GatherTree},
{ "GRN", Type::GRN},
{ "Range", Type::Range},
{ "Proposal", Type::Proposal},
{ "ReorgYolo", Type::ReorgYolo},
{ "ReverseSequence", Type::ReverseSequence},
{ "ExperimentalDetectronTopKROIs", Type::ExperimentalDetectronTopKROIs},
{ "ExperimentalDetectronROIFeatureExtractor", Type::ExperimentalDetectronROIFeatureExtractor},
{ "ExperimentalDetectronPriorGridGenerator", Type::ExperimentalDetectronPriorGridGenerator},
{ "ExperimentalDetectronGenerateProposalsSingleImage", Type::ExperimentalDetectronGenerateProposalsSingleImage},
{ "GenerateProposals", Type::GenerateProposals},
{ "ExtractImagePatches", Type::ExtractImagePatches},
{ "NonMaxSuppression", Type::NonMaxSuppression},
{ "NonMaxSuppressionIEInternal", Type::NonMaxSuppression},
{ "MatrixNms", Type::MatrixNms},
{ "MulticlassNms", Type::MulticlassNms},
{ "MulticlassNmsIEInternal", Type::MulticlassNms},
{ "Reference", Type::Reference},
{ "Subgraph", Type::Subgraph},
{ "PriorBox", Type::PriorBox},
{ "PriorBoxClustered", Type::PriorBoxClustered},
{ "Interaction", Type::Interaction},
{ "MHA", Type::MHA},
{ "Unique", Type::Unique},
{ "Ngram", Type::Ngram}
};
return type_to_name_tbl;
}
Type TypeFromName(const std::string& type) {
const TypeToNameMap & type_to_name_tbl = get_type_to_name_tbl();
auto itType = type_to_name_tbl.find(type);
if (type_to_name_tbl.end() != itType) {
return itType->second;