-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[GPU] Graph serialization for GPU #2 #13986
Changes from all commits
47bda85
da2428c
6c02916
e2b54ad
edfe913
5e91531
1b99643
2b29abb
c941190
7fe8edb
d489a15
fee6fbf
a9bb84c
c190318
d7d878f
8de74ae
094ae97
dd37c11
5e36324
4f805dc
fbca09f
b170557
43f71e9
8a4999f
30a0ea1
916123f
bcea37c
2797292
1fc6660
23d6dfd
183a1d8
a0dfa37
5d3ab0d
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 |
---|---|---|
|
@@ -12,6 +12,33 @@ | |
#include "intel_gpu/runtime/layout.hpp" | ||
|
||
namespace cldnn { | ||
template <typename BufferType> | ||
class Serializer<BufferType, ov::PartialShape, typename std::enable_if<std::is_base_of<OutputBuffer<BufferType>, BufferType>::value>::type> { | ||
public: | ||
static void save(BufferType& buffer, const ov::PartialShape& partial_shape) { | ||
std::vector<ov::Dimension> dimensions(partial_shape); | ||
buffer << dimensions.size(); | ||
for (const auto& dimension : dimensions) { | ||
buffer << dimension.get_interval().get_min_val(); | ||
buffer << dimension.get_interval().get_max_val(); | ||
} | ||
} | ||
}; | ||
|
||
template <typename BufferType> | ||
class Serializer<BufferType, ov::PartialShape, typename std::enable_if<std::is_base_of<InputBuffer<BufferType>, BufferType>::value>::type> { | ||
public: | ||
static void load(BufferType& buffer, ov::PartialShape& partial_shape) { | ||
size_t num_dimensions; | ||
buffer >> num_dimensions; | ||
for (size_t i = 0; i < num_dimensions; i++) { | ||
ov::Dimension::value_type min_val, max_val; | ||
buffer >> min_val >> max_val; | ||
partial_shape.push_back(ov::Dimension(min_val, max_val)); | ||
} | ||
} | ||
}; | ||
|
||
template <typename BufferType> | ||
class Serializer<BufferType, cldnn::layout, typename std::enable_if<std::is_base_of<OutputBuffer<BufferType>, BufferType>::value>::type> { | ||
public: | ||
|
@@ -21,15 +48,7 @@ class Serializer<BufferType, cldnn::layout, typename std::enable_if<std::is_base | |
buffer << _layout.data_padding.filling_value(); | ||
buffer << _layout.data_padding.lower_size().sizes(); | ||
buffer << _layout.data_padding.upper_size().sizes(); | ||
|
||
std::vector<cldnn::tensor::value_type> _sizes = _layout.get_tensor().sizes(_layout.format); | ||
// Temp WA for bs_x_bsv16 | ||
if (_layout.format == cldnn::format::bs_x_bsv16) { | ||
std::vector<cldnn::tensor::value_type> _tmp_sizes = _layout.get_tensor().sizes(); | ||
_sizes[0] = _tmp_sizes[0]; | ||
_sizes[1] = _tmp_sizes[1]; | ||
} | ||
buffer << _sizes; | ||
buffer << _layout.get_partial_shape(); | ||
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. #13801 (comment) |
||
} | ||
}; | ||
|
||
|
@@ -50,15 +69,9 @@ class Serializer<BufferType, cldnn::layout, typename std::enable_if<std::is_base | |
_layout.data_padding = cldnn::padding(_lower_size, _upper_size, _filling_value); | ||
} | ||
|
||
std::vector<cldnn::tensor::value_type> _sizes; | ||
buffer >> _sizes; | ||
|
||
// Temp WA for bs_x_bsv16 | ||
if (_layout.format == cldnn::format::bs_x_bsv16) { | ||
_layout.set_tensor(tensor(_sizes)); | ||
} else { | ||
_layout.set_tensor(tensor(_layout.format, _sizes)); | ||
} | ||
ov::PartialShape partial_shape; | ||
buffer >> partial_shape; | ||
_layout.set_partial_shape(partial_shape); | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ class CompiledModel : public InferenceEngine::ExecutableNetworkThreadSafeDefault | |
CompiledModel(std::istream& networkModel, std::shared_ptr<InferenceEngine::RemoteContext> context, Config config); | ||
|
||
void Export(std::ostream& networkModel) override; | ||
bool isSerializable(); | ||
std::shared_ptr<ngraph::Function> GetExecGraphInfo() override; | ||
InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override; | ||
InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, | ||
|
@@ -47,6 +46,9 @@ class CompiledModel : public InferenceEngine::ExecutableNetworkThreadSafeDefault | |
Config m_config; | ||
InferenceEngine::ITaskExecutor::Ptr m_taskExecutor; | ||
InferenceEngine::ITaskExecutor::Ptr m_waitExecutor; | ||
|
||
private: | ||
bool is_serializable(); | ||
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. #13801 (comment) |
||
}; | ||
|
||
} // namespace intel_gpu | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,6 +213,30 @@ struct primitive_info { | |
CLDNN_DEFINE_TYPE_ID(PType) \ | ||
CLDNN_DEFINE_TYPE_STRING(PType) | ||
|
||
#define GPU_DEFINE_PRIMITIVE_TYPE_ID(PType) \ | ||
primitive_type_id PType::type_id() { \ | ||
static primitive_type_base<PType> instance; \ | ||
return &instance; \ | ||
} \ | ||
bool _##PType##_added_ = prim_map_storage::instance().set_type_id(#PType, PType::type_id()); | ||
|
||
struct prim_map_storage { | ||
static prim_map_storage& instance() { | ||
static prim_map_storage instance; | ||
return instance; | ||
} | ||
|
||
const cldnn::primitive_type_id get_type_id(const std::string& type_string) const { | ||
return map.at(type_string); | ||
} | ||
|
||
bool set_type_id(const std::string& type_string, const cldnn::primitive_type_id type_id) { | ||
return map.insert({type_string, type_id}).second; | ||
} | ||
|
||
private: | ||
std::unordered_map<std::string, cldnn::primitive_type_id> map; | ||
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. Maybe we can make this map a static field of primitive_type and insert type_id in primitive_type_base c-tor? 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. If the point to insert type_id is moved to c-tor, primitives that have not yet been created will not exist in the map. Then, when deserializing, the type_id cannot be obtained by type name, which causes a problem. 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. primitive_type objects are static, so all primitives are supposed to be initialized on app startup, aren't they? 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. |
||
}; | ||
/// @} | ||
/// @} | ||
} // namespace cldnn |
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.
#13801 (comment)
Moved the include path. Thank you.