Skip to content
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

rocAL Tensor Video pipeline changes #19

Merged

Conversation

fiona-gladwin
Copy link
Collaborator

  • Change instances of image to tensor
  • Add changes to VideoFileSource, VideoFileResize and SequenceReader API
  • Remove video loader module and structures associated with it.
  • Make use of Loader module for video pipeline.
  • Remove VideoDecoderConfig, VideoReaderConfig, VideoStorageType and VideoDecoderType
  • Modify Sequence Rearrange wrt tensor.
  • Fix the brightness and CMN augmentations to operate on sequences

fiona-gladwin and others added 9 commits March 30, 2023 10:53
Change instances of image to tensor
Remove video loader module
Remove VideoDecoderConfig, VideoReaderConfig
Remove VideoStorageType and VideoDecoderType
All loader API call in master graph
Add sequence batch size variable to change the batch size based on sequence length
vxReleaseImage(&image);

// Check for input parameters
vx_tensor input;
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like input is not initialized here. Please use the parameter corresponding to input and output

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

return ERRMSG(VX_ERROR_INVALID_DIMENSION, "validate: SequenceRearrange: tensor: #0 dimensions=%lu (must be greater than or equal to 4)\n", in_num_tensor_dims);

// Check for output parameters
vx_tensor output;
Copy link
Collaborator

Choose a reason for hiding this comment

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

output is not initialized

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

STATUS_ERROR_CHECK(vxSetMetaFormatAttribute(metas[1], VX_TENSOR_DIMS, &tensor_dims, sizeof(tensor_dims)));
STATUS_ERROR_CHECK(vxSetMetaFormatAttribute(metas[1], VX_TENSOR_DATA_TYPE, &tensor_type, sizeof(tensor_type)));
STATUS_ERROR_CHECK(vxSetMetaFormatAttribute(metas[1], VX_TENSOR_FIXED_POINT_POSITION, &tensor_fixed_point_position, sizeof(tensor_fixed_point_position)));
vxReleaseTensor(&input);
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not release tensor here. Just reference it for querying. See samples in amd_nn extensions for proper usage

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

STATUS_ERROR_CHECK(vxSetMetaFormatAttribute(metas[1], VX_TENSOR_FIXED_POINT_POSITION, &tensor_fixed_point_position, sizeof(tensor_fixed_point_position)));
vxReleaseTensor(&input);
vxReleaseTensor(&output);
vxReleaseParameter(&input_param);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not required to release parameters and tensors

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

SequenceRearrangeLocalData *data;
STATUS_ERROR_CHECK(vxQueryNode(node, VX_NODE_LOCAL_DATA_PTR, &data, sizeof(data)));
STATUS_ERROR_CHECK(releaseGraphHandle(node, data->handle, data->deviceType));
free(data->newOrder);
Copy link
Collaborator

Choose a reason for hiding this comment

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

please check the data validity before freeing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

std::shared_ptr<SequenceRearrangeNode> sequence_rearrange_node = context->master_graph->add_node<SequenceRearrangeNode>({input}, {output});
sequence_rearrange_node->init(new_order, new_sequence_length, sequence_length, context->master_graph->internal_batch_size());
sequence_rearrange_node->init(new_order);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is the sequence_length and new_sequence_length not needed anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously we did not have the provision to store sequence length in ImageInfo
Now we can get the sequence length and new sequence length directly from the dims of input tensor and the new order vector length respectively.

info.set_color_format(color_format);
info.set_tensor_layout(RocalTensorlayout::NFHWC);
info.set_sequence_batch_size(sequence_length);
info.set_max_shape();
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does set_max_shape() api do here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Set max shape is to store the max width and height of the tensor wrt the layout passed.
It is set only only for the dataloaders i.e the first node.

{
Image* output = nullptr;
unsigned stride) {
rocalTensor* output = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

please move this after the context validity check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are checking if the context is set and we throw the error and return the rocalTensor
Hence the output rocalTensor is initialized to nullptr before the validity check

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.

@fiona-gladwin : please address review comments

@fiona-gladwin
Copy link
Collaborator Author

@fiona-gladwin : please address review comments

Hi @rrawther I have addressed all review comments. Please check

@rrawther
Copy link
Collaborator

@fiona-gladwin : Please merge tot changes before making next PR

@LakshmiKumar23 LakshmiKumar23 merged commit 0808d57 into LakshmiKumar23:lk/rocalTensor Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants