Fg/ser2 pipe serialize#20
Open
fgladwin wants to merge 135 commits into
Open
Conversation
Remove the usage of API enums in internal node files
Add support to register all internal enums
Creates an argument instance for each arg passed in the Node Handles different argument types i.e parameters, vectors, enums and predefined types
…and ImageLoaderNode
Add support to serialize the args and pipeline details Add support to serialize the tensors.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Create single constructor with check for different data types in Argument class
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 72ff657.
…ocs/sphinx (ROCm#426) Bumps [rocm-docs-core[api_reference]](https://github.com/ROCm/rocm-docs-core) from 1.30.1 to 1.31.0. - [Release notes](https://github.com/ROCm/rocm-docs-core/releases) - [Changelog](https://github.com/ROCm/rocm-docs-core/blob/v1.31.0/CHANGELOG.md) - [Commits](ROCm/rocm-docs-core@v1.30.1...v1.31.0) --- updated-dependencies: - dependency-name: rocm-docs-core[api_reference] dependency-version: 1.31.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces pipeline serialization support for rocAL by adding a protobuf schema and a serializer that captures pipeline config, operators, arguments, and tensor metadata, then exposes this via new public C APIs.
Changes:
- Added
rocal.protoand a newPipelineSerializerto emit a binary protobuf representation of the built pipeline. - Added public APIs
rocalSerialize()androcalGetSerializedString()and wired them throughMasterGraph. - Adjusted several tensor/node/operator accessors to return
const&for more efficient, const-correct access, and updated build/docs dependencies accordingly.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| rocAL/source/pipeline/pipeline_serializer.cpp | Implements protobuf population + serialization for pipeline config, operators, args, and tensors |
| rocAL/source/pipeline/master_graph.cpp | Adds MasterGraph::serialize() entry point to build the serialized pipeline string |
| rocAL/source/api/rocal_api.cpp | Exposes serialization through new C APIs and copies serialized bytes to user buffer |
| rocAL/proto/rocal.proto | Defines protobuf messages for pipeline/operator/argument/tensor serialization |
| rocAL/include/pipeline/tensor.h | Makes tensor_name() return const std::string& and const-qualifies it |
| rocAL/include/pipeline/pipeline_serializer.h | Declares PipelineSerializer interface |
| rocAL/include/pipeline/pipeline_operator.h | Adds helpers to retrieve operator arguments and node IO tensors |
| rocAL/include/pipeline/node.h | Changes input()/output() to return const std::vector<Tensor*>& |
| rocAL/include/pipeline/master_graph.h | Declares serialization APIs and stores serialized pipeline string |
| rocAL/include/api/rocal_api.h | Declares new public serialization APIs and documents buffer requirements |
| rocAL/CMakeLists.txt | Adds protobuf generation/build integration for rocal.proto |
| docs/sphinx/requirements.txt | Adjusts Sphinx-related dependency versions |
| docs/sphinx/requirements.in | Bumps rocm-docs-core dependency version |
| CHANGELOG.md | Notes new serialization functionality and APIs for upcoming release |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+25
to
+26
| #include <fstream> | ||
|
|
|
|
||
| void PipelineSerializer::serialize_to_string(std::string& serialized_string) { | ||
| if (!_pipeline_proto.SerializeToString(&serialized_string)) { | ||
| THROW("Failed to serialize pipeline to string."); |
Comment on lines
+42
to
+52
| void set_tensor_proto(rocal_proto::InputOutput *in_out_proto, Tensor *tensor, bool is_input) { | ||
| in_out_proto->set_name(tensor->tensor_name()); | ||
| in_out_proto->set_device(static_cast<int>(tensor->info().mem_type())); | ||
| in_out_proto->set_dtype(static_cast<int>(tensor->info().data_type())); | ||
| in_out_proto->set_layout(static_cast<int>(tensor->info().layout())); | ||
| in_out_proto->set_color_format(static_cast<int>(tensor->info().color_format())); | ||
| for (auto &dim : tensor->info().dims()) | ||
| in_out_proto->add_dims(dim); | ||
| in_out_proto->set_num_dims(tensor->info().num_of_dims()); | ||
| in_out_proto->set_is_argument_input(is_input); | ||
| } |
Comment on lines
+82
to
+85
| if (op_arg.values.empty()) { | ||
| // Represent empty vector by adding an empty vector message of the right type | ||
| if (op_arg.type_name == "int" || op_arg.type_name == "shared_ptr" | ||
| || op_arg.type_name == "unsigned" || op_arg.type_name == "size_t") { |
Comment on lines
+56
to
+60
| void serialize_output_tensors(TensorList& output_tensors_list); | ||
| /** | ||
| * @brief Serialize all operators in the pipeline, their arguments, and IO tensors. | ||
| */ | ||
| void serialize_operators(std::vector<std::shared_ptr<PipelineOperator>>& operators); |
| */ | ||
| void serialize(size_t *serialized_string_size); // Serialize the current pipeline to an internal string and return its size. | ||
| // Returns the last serialized pipeline string, Should be called after serialize(). Returns an empty string if serialize() hasn't been called. | ||
| std::string& get_serialized_string() { return _serialized_pipeline; } |
| auto context = static_cast<Context*>(rocal_context); | ||
| try { | ||
| if (!serialized_string) { | ||
| THROW("String copy failed, Invalid pointer passed for serialize.") |
Comment on lines
+126
to
+139
| * into the user-provided buffer. The buffer must be pre-allocated with size | ||
| * at least serialized_string_size + 1 bytes to accommodate the null terminator. | ||
| * | ||
| * \warning The caller is responsible for ensuring the destination buffer has | ||
| * sufficient capacity (at least serialized_string_size + 1 bytes as returned by | ||
| * rocalSerialize). Passing an insufficiently sized buffer will result in buffer | ||
| * overflow and undefined behavior. | ||
| * | ||
| * \param [in] rocal_context the rocAL context | ||
| * \param [out] serialized_string destination buffer to receive the serialized string (null-terminated). | ||
| * Must be pre-allocated with at least serialized_string_size + 1 bytes. | ||
| * \return A \ref RocalStatus - A status code indicating the success or failure. | ||
| */ | ||
| extern "C" RocalStatus ROCAL_API_CALL rocalGetSerializedString(RocalContext rocal_context, char* serialized_string); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.