Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDuplensky committed Jan 29, 2025
1 parent 73956d3 commit 31120e1
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/plugins/intel_cpu/src/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model,
m_cfg{std::move(cfg)},
m_name{model->get_name()},
m_loaded_from_cache(loaded_from_cache),
m_sub_memory_manager(std::move(sub_memory_manager)),
m_networkMemoryControl(std::make_shared<NetworkMemoryControl>()) {
m_sub_memory_manager(std::move(sub_memory_manager)) {
m_mutex = std::make_shared<std::mutex>();
const auto& core = m_plugin->get_core();
if (!core) {
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/intel_cpu/src/compiled_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class CompiledModel : public ov::ICompiledModel {
return m_name;
}

std::shared_ptr<NetworkMemoryControl> get_network_memory_control() const {
return m_networkMemoryControl;
}

private:
std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override;
friend class CompiledModelHolder;
Expand Down Expand Up @@ -105,7 +101,6 @@ class CompiledModel : public ov::ICompiledModel {

std::vector<std::shared_ptr<CompiledModel>> m_sub_compiled_models;
std::shared_ptr<SubMemoryManager> m_sub_memory_manager = nullptr;
std::shared_ptr<NetworkMemoryControl> m_networkMemoryControl = nullptr;
bool m_has_sub_compiled_models = false;
};

Expand Down
22 changes: 14 additions & 8 deletions src/plugins/intel_cpu/src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "openvino/core/node.hpp"
#include "openvino/core/parallel.hpp"
#include "openvino/core/type/element_type.hpp"
#include "openvino/op/tensor_iterator.hpp"
#include "openvino/runtime/exception.hpp"
#include "openvino/runtime/threading/cpu_streams_executor.hpp"
#include "utils/debug_capabilities.h"
Expand Down Expand Up @@ -767,8 +766,9 @@ static size_t AllocateStringsAndConstants(EdgeClusters& clusters, const GraphCon
clusters.begin(),
clusters.end(),
[&allocateStringMemory, &allocateConstantEdge, &context](const EdgeCluster& cluster) {
if (cluster.empty())
if (cluster.empty()) {
return false;
}

auto baseEdgeIt = std::find_if(cluster.begin(), cluster.end(), [](const EdgePtr& edge) {
return one_of(edge->getStatus(), Edge::Status::Allocated, Edge::Status::NeedAllocation);
Expand Down Expand Up @@ -821,8 +821,9 @@ static void AllocateBaseEdges(const EdgeClusters& edgeClusters, const MemoryCont
// TODO: WA for some test (like strided_slice_test) which use tensors with
// shapes {0}. And it is implicitly converted into {1} tensor.
// Zeroing of input data allow pass tests.
if (edge->getParent()->getType() == Type::Input && edge->getMemory().getDesc().hasDefinedMaxSize())
if (edge->getParent()->getType() == Type::Input && edge->getMemory().getDesc().hasDefinedMaxSize()) {
edge->getMemoryPtr()->nullify();
}

count++;
}
Expand Down Expand Up @@ -933,13 +934,15 @@ int Graph::RegisterToAllocationContext(int offset, AllocationContext& context) {
}

static void InitEdgeStatus(const std::vector<EdgePtr>& edges) {
for (auto& edge : edges)
for (auto& edge : edges) {
edge->init();
}
}

static void ValidateEdgeStatus(const std::vector<EdgePtr>& edges) {
for (auto& edge : edges)
for (auto& edge : edges) {
edge->validate();
}
}

/**
Expand All @@ -955,8 +958,9 @@ static EdgeClusters FormEdgeClusters(const std::vector<EdgePtr>& graphEdges) {
EdgeClusterIdxMap edgeClusterIndices;

for (auto& edge : graphEdges) {
if (edgeClusterIndices.count(edge))
if (edgeClusterIndices.count(edge)) {
continue; // edge is visited
}

size_t clusterIdx = edgeClusters.size();
EdgePtr lastSharedEdge = nullptr;
Expand All @@ -972,15 +976,17 @@ static EdgeClusters FormEdgeClusters(const std::vector<EdgePtr>& graphEdges) {
}
}

if (clusterIdx == edgeClusters.size())
if (clusterIdx == edgeClusters.size()) {
edgeClusters.emplace_back(EdgeCluster{edge});
}

// use recursive approach to ensure that the base edge is placed as a first entry of a cluster
std::function<void(EdgePtr)> addToCluster;
addToCluster =
[&addToCluster, &edgeClusterIndices, &clusterIdx, &edgeClusters, &lastSharedEdge](const EdgePtr& edge) {
if (edge == lastSharedEdge)
if (edge == lastSharedEdge) {
return;
}

addToCluster(edge->getSharedEdge(std::nothrow));

Expand Down
6 changes: 2 additions & 4 deletions src/plugins/intel_cpu/src/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Graph {
* To enable layout propagation and global memory reuse
* two-stage creation should be used instead:
* - Init()
* - Allocate()
* - Activate()
*/
template <typename NET>
void CreateGraph(NET& model, const GraphContext::CPtr& context);
Expand All @@ -80,7 +80,7 @@ class Graph {
* To enable layout propagation and global memory reuse
* two-stage creation should be used instead:
* - Init()
* - Allocate()
* - Activate()
*/
void CreateGraph(const std::vector<NodePtr>& graphNodes,
const std::vector<EdgePtr>& graphEdges,
Expand Down Expand Up @@ -240,8 +240,6 @@ class Graph {
return graphHasDynamicInput;
}

const std::unordered_map<std::string, node::MemoryStateNode*>& getInternalStateNodes() const;

void Init(const std::vector<NodePtr>& graphNodes,
const std::vector<EdgePtr>& graphEdges,
const GraphContext::CPtr& context,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intel_cpu/src/nodes/conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,9 @@ void Convolution::selectOptimalPrimitiveDescriptor() {
}

int Convolution::registerToAllocationContext(int offset, AllocationContext& context) {
if (subgraph)
if (subgraph) {
return subgraph->RegisterToAllocationContext(offset, context);
}

return Node::registerToAllocationContext(offset, context);
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intel_cpu/src/nodes/if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ If::If(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr& context)
}

void If::initSupportedPrimitiveDescriptors() {
if (!supportedPrimitiveDescriptors.empty())
if (!supportedPrimitiveDescriptors.empty()) {
return;
}

auto ifOp = ov::as_type_ptr<ov::op::v8::If>(m_op);

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intel_cpu/src/nodes/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,9 @@ void Input::initSupportedPdFromMemDesc() {
}

void Input::resolveInPlaceEdges(Edge::LOOK look) {
if (!m_isInPlace)
if (!m_isInPlace) {
return Node::resolveInPlaceEdges(look);
}

if (look & Edge::LOOK_UP) {
auto edges = getChildEdgesAtPort(0);
Expand Down
9 changes: 4 additions & 5 deletions src/plugins/intel_cpu/src/nodes/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,10 @@ void MemoryInput::createPrimitive() {
CPU_NODE_ASSERT(getParentEdges().size() == subGraph->inputsNumber(),
"Number of node inputs must be equal the number of inner graph's inputs");

for (size_t i = 0; i < getParentEdges().size(); i++) {
auto srcEdgeMem = getSrcMemoryAtPort(i);
// create a separate input memory objects instead of share them. avoid data corruption.
auto mem = std::make_shared<Memory>(getEngine(), srcEdgeMem->getDescPtr(), srcEdgeMem->getMemoryBlock());
subgraphMemoryPtrs.push_back(mem);
for (size_t i = 0; i < subGraph->inputsNumber(); i++) {
auto subgraphInputNode = subGraph->getInputNodeByIndex(i);
auto subgraphInputMemory = subgraphInputNode->getDstMemoryAtPort(0);
subgraphMemoryPtrs.push_back(subgraphInputMemory);
}

subGraph->Activate();
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intel_cpu/src/nodes/tensoriterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,9 @@ void TensorIterator::initSupportedPrimitiveDescriptors() {

sub_graph.Init(subgraphOp->get_function(), context);

if (!supportedPrimitiveDescriptors.empty())
if (!supportedPrimitiveDescriptors.empty()) {
return;
}

supportedPrimitiveDescriptors.emplace_back(make_plain_config(ngraphOp), impl_desc_type::unknown);
}
Expand Down

0 comments on commit 31120e1

Please sign in to comment.