Skip to content

Conversation

@fiona-gladwin
Copy link
Contributor

@fiona-gladwin fiona-gladwin commented Dec 15, 2025

Motivation

Introduce support to extract argument extraction and initialize the Node during deserialization.

Technical Details

  • Adds a get() method to the Argument class for type-safe value retrieval and implements
  • Introduce initialize_args() methods in node classes to support deserialization-based initialization.
  • Add support for initialize_args() in ImageLoaderNode, ImageSingleShardNode and BrightnessNode

Test Plan

No new tests added. Must pass existing tests

NOTE : To be merged after PR #430

fiona-gladwin and others added 30 commits October 7, 2025 05:03
Remove the use of pipeline operator
Co-authored-by: spolifroni-amd <Sandra.Polifroni@amd.com>
@LakshmiKumar23
Copy link
Contributor

@fiona-gladwin Can you resolve merge conflicts? Thanks!

LakshmiKumar23
LakshmiKumar23 previously approved these changes Jan 12, 2026
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 2.24719% with 87 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rocAL/include/pipeline/argument.h 0.00% 49 Missing ⚠️
rocAL/source/loaders/image/node_image_loader.cpp 7.14% 13 Missing ⚠️
...e/loaders/image/node_image_loader_single_shard.cpp 7.69% 12 Missing ⚠️
rocAL/include/pipeline/node.h 0.00% 8 Missing ⚠️
...mentations/color_augmentations/node_brightness.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #432      +/-   ##
===========================================
- Coverage    79.97%   79.66%   -0.31%     
===========================================
  Files          294      294              
  Lines        22560    22647      +87     
===========================================
  Hits         18041    18041              
- Misses        4519     4606      +87     
Files with missing lines Coverage Δ
...ugmentations/color_augmentations/node_brightness.h 100.00% <ø> (ø)
rocAL/include/loaders/image/node_image_loader.h 33.33% <ø> (ø)
...ude/loaders/image/node_image_loader_single_shard.h 33.33% <ø> (ø)
...mentations/color_augmentations/node_brightness.cpp 82.50% <0.00%> (-11.79%) ⬇️
rocAL/include/pipeline/node.h 60.00% <0.00%> (-28.24%) ⬇️
...e/loaders/image/node_image_loader_single_shard.cpp 74.19% <7.69%> (-17.81%) ⬇️
rocAL/source/loaders/image/node_image_loader.cpp 73.77% <7.14%> (-19.98%) ⬇️
rocAL/include/pipeline/argument.h 48.61% <0.00%> (-25.07%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LakshmiKumar23
Copy link
Contributor

Copy link
Collaborator

@rrawther rrawther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the review comments

reader_cfg.set_sharding_info(sharding_info);

std::array<std::string, 23> arg_names = {
std::array<std::string, INIT_ARGS_COUNT> arg_names = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please define as const std::string arg_array[] = {...}
and use size(arguments) to get size if needed. This is not recommended

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are using std::array we have used the INIT_ARGS_COUNT to create the static array


#include "pipeline/exception.h"

#define INIT_ARGS_COUNT 23 // Modify in accordance with number of args in init
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove hardcoded parameter. see comment below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rrawther The INIT_ARGS_COUNT is used to ensure that the number of args serialized is retrieved correctly during deserialize.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a vector "std::vectorstd::string arguments" as part of the class and just copy the passed vector into the class member.
After that, you can just check the size of vector to get the size instead of hardcoded value

}

void ImageLoaderNode::initialize_args(std::vector<Argument> &arguments, std::shared_ptr<MetaDataReader> meta_data_reader) {
if (arguments.size() != INIT_ARGS_COUNT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use arg_array.size() instead

reader_cfg.set_sharding_info(sharding_info);

std::array<std::string, 23> arg_names = {
std::array<std::string, INIT_ARGS_COUNT> arg_names = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see the comment above

Copy link
Contributor Author

@fiona-gladwin fiona-gladwin Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rrawther The INIT_ARGS_COUNT is used to ensure that the number of args serialized is retrieved correctly during deserialize.

As in the initialize_args we need to check the required number of arguments are present to extract each of them and pass to the init function, If not it might lead to segmentation fault, hence we have hardcoded the value

DecoderType decoder_type, bool shuffle, bool loop, size_t load_batch_count, RocalMemType mem_type, std::shared_ptr<MetaDataReader> meta_data_reader, bool decoder_keep_orig = false, const ShardingInfo& sharding_info = ShardingInfo(),
const char *prefix = "", unsigned sequence_length = 0, unsigned step = 0, unsigned stride = 0, ExternalSourceFileMode external_file_mode = ExternalSourceFileMode::NONE, const std::string &index_path = "");

void initialize_args(std::vector<Argument> &arguments, std::shared_ptr<MetaDataReader> meta_data_reader) override;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please pass as const if the std::vector is read-only

Copy link
Collaborator

@rrawther rrawther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added review comments


#include "pipeline/exception.h"

#define INIT_ARGS_COUNT 23 // Modify in accordance with number of args in init
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a vector "std::vectorstd::string arguments" as part of the class and just copy the passed vector into the class member.
After that, you can just check the size of vector to get the size instead of hardcoded value

ShardingInfo sharding_info(arguments[13].get<RocalBatchPolicy>(), arguments[14].get<bool>(), arguments[15].get<bool>(), arguments[16].get<int32_t>());
std::string file_prefix = arguments[17].get<std::string>();

this->init(arguments[0].get<unsigned>(), arguments[1].get<unsigned>(), arguments[2].get<std::string>(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to get rid of hardcoded arguments in Init(), I suggest adding a new Init() function which takes the passed vector of arguments directly. Also you need to have some way of checking the values against expected. If so it will fail the Init function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rrawther As suggested I have removed the hardcoded value and introduced a map instead where the arguments are obtained from the map using the name of the argument (i.e string) Please let me know if this works

Store the args in a map in the Node
Modify initializers to accept and obtain values from the ArgumentSet using the string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants