-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CPU] Refactor memory control and allocation #27259
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace ov { | ||
namespace intel_cpu { | ||
|
||
class Node; | ||
class Edge; | ||
|
||
using GlobalExecutionIndex = std::unordered_map<std::shared_ptr<Node>, std::pair<int, int>>; | ||
|
||
struct AllocationContext { | ||
std::vector<std::shared_ptr<Edge>> edges; | ||
GlobalExecutionIndex execIndex; | ||
std::vector<size_t> syncPoints; | ||
}; | ||
|
||
} // namespace intel_cpu | ||
} // namespace ov |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
@@ -19,6 +20,8 @@ | |
namespace ov { | ||
namespace intel_cpu { | ||
|
||
class NetworkMemoryControl; | ||
|
||
class CompiledModel : public ov::ICompiledModel { | ||
public: | ||
typedef std::shared_ptr<CompiledModel> Ptr; | ||
|
@@ -51,6 +54,10 @@ class CompiledModel : public ov::ICompiledModel { | |
|
||
void release_memory() override; | ||
|
||
std::shared_ptr<NetworkMemoryControl> get_network_memory_control() const { | ||
return m_networkMemoryControl; | ||
} | ||
Comment on lines
+57
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this method is not used. |
||
|
||
private: | ||
std::shared_ptr<ov::ISyncInferRequest> create_sync_infer_request() const override; | ||
friend class SyncInferRequest; | ||
|
@@ -91,6 +98,7 @@ 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; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,11 @@ class Edge { | |
int pr_port = 0, int ch_port = 0); | ||
|
||
enum class Status { | ||
Uninitialized, | ||
NeedAllocation, | ||
NotAllocated, | ||
Allocated, | ||
Validated | ||
Uninitialized, // base edge is unknown yet | ||
NeedAllocation, // edge is the base edge | ||
NotAllocated, // edge is a referencing edge | ||
Allocated, // edge memory is allocated | ||
Validated // edge is validated | ||
}; | ||
|
||
enum class ReorderStatus { | ||
|
@@ -82,6 +82,7 @@ class Edge { | |
} | ||
|
||
std::string name() const; | ||
const MemoryDesc& getDesc() const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I remember this, this method was hidden from the public domain on purpose.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR is not really ready for review. |
||
|
||
private: | ||
std::weak_ptr<Node> parent; | ||
|
@@ -99,7 +100,6 @@ class Edge { | |
PortDescBaseCPtr getInputPortDesc() const; | ||
PortDescBaseCPtr getOutputPortDesc() const; | ||
|
||
const MemoryDesc& getDesc() const; | ||
bool enforceReorder(); | ||
|
||
void collectConsumers(std::vector<std::shared_ptr<Node>>& result) const; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the
memoryControl
is derived fromm_networkMemoryControl
, may be it's just enough to pass onlym_networkMemoryControl
to the context?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current idea is that passing m_networkMemoryControl is now obsolete and should be dropped after all the nodes with inner graphs are updated according to the memory reuse changes. And all the nodes are supposed to use a particular memoryControl instance created by CompiledModel and not some random one from networkMemoryControl.