Skip to content

Commit

Permalink
rocAL Tensor Video pipeline changes (#19)
Browse files Browse the repository at this point in the history
* Add changes to the video pipeline

Change instances of image to tensor
Remove video loader module
Remove VideoDecoderConfig, VideoReaderConfig
Remove VideoStorageType and VideoDecoderType

* Add tensor support for Sequence Rearrange

Code clean up

* Add sequence frame num and time stamps loader

All loader API call in master graph

* Add tensor support for sequence reader

Add sequence batch size variable to change the batch size based on sequence length

* Add support to allocate N*F ROI for sequences

* Add chnanges to process sequences brightness and CMN

* Minor changes

* Minor formatting changes

* Add check to pass only 5D tensors to SequenceRearrange

* Minor changes

Move SequenceInfo back to video reader
Null ptr check
Variable name change

* Query params directly from parameters in SequenceRearrange
  • Loading branch information
fiona-gladwin authored Apr 17, 2023
1 parent 862094b commit 0808d57
Show file tree
Hide file tree
Showing 39 changed files with 592 additions and 785 deletions.
2 changes: 1 addition & 1 deletion amd_openvx_extensions/amd_rpp/include/vx_ext_rpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_ThresholdingbatchPD(v
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_VignettebatchPD(vx_graph graph,vx_image pSrc,vx_array srcImgWidth,vx_array srcImgHeight,vx_image pDst,vx_array stdDev,vx_uint32 nbatchSize);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_WarpAffinebatchPD(vx_graph graph,vx_image pSrc,vx_array srcImgWidth,vx_array srcImgHeight,vx_image pDst,vx_array dstImgWidth,vx_array dstImgHeight,vx_array affine,vx_uint32 nbatchSize);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_WarpPerspectivebatchPD(vx_graph graph,vx_image pSrc,vx_array srcImgWidth,vx_array srcImgHeight,vx_image pDst,vx_array dstImgWidth,vx_array dstImgHeight,vx_array perspective,vx_uint32 nbatchSize);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_SequenceRearrange(vx_graph graph,vx_image pSrc,vx_image pDst, vx_array newOrder,vx_uint32 newSequenceLength, vx_uint32 sequenceLength, vx_uint32 sequenceCount);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_Resizetensor(vx_graph graph,vx_image pSrc,vx_array srcImgWidth,vx_array srcImgHeight,vx_image pDst,vx_array dstImgWidth,vx_array dstImgHeight,vx_uint32 nbatchSize);

extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_Brightness(vx_graph graph, vx_tensor pSrc, vx_tensor srcROI, vx_tensor pDst, vx_array alpha, vx_array beta, vx_scalar inputLayout, vx_scalar outputLayout, vx_scalar roiType);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_Copy(vx_graph graph, vx_tensor pSrc, vx_tensor pDst);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_CropMirrorNormalize(vx_graph graph, vx_tensor pSrc, vx_tensor srcROI, vx_tensor pDst, vx_array multiplier, vx_array offset, vx_array mirror, vx_scalar inputLayout, vx_scalar outputLayout, vx_scalar roiType);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_Nop(vx_graph graph, vx_tensor pSrc, vx_tensor pDst);
extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_SequenceRearrange(vx_graph graph, vx_tensor pSrc, vx_tensor pDst, vx_array newOrder, vx_scalar layout);
#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 4 additions & 7 deletions amd_openvx_extensions/amd_rpp/source/Brightness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct BrightnessLocalData {

static vx_status VX_CALLBACK refreshBrightness(vx_node node, const vx_reference *parameters, vx_uint32 num, BrightnessLocalData *data) {
vx_status status = VX_SUCCESS;
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[3], 0, data->srcDescPtr->n, sizeof(vx_float32), data->alpha, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[4], 0, data->srcDescPtr->n, sizeof(vx_float32), data->beta, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[3], 0, data->inputTensorDims[0], sizeof(vx_float32), data->alpha, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[4], 0, data->inputTensorDims[0], sizeof(vx_float32), data->beta, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));

if (data->deviceType == AGO_TARGET_AFFINITY_GPU) {
#if ENABLE_HIP
Expand All @@ -63,15 +63,12 @@ static vx_status VX_CALLBACK refreshBrightness(vx_node node, const vx_reference
data->roiPtr = (RpptROI *)data->roiTensorPtr;
if((data->inputLayout == 2 || data->inputLayout == 3)) { // For NFCHW and NFHWC formats
unsigned num_of_frames = data->inputTensorDims[1]; // Num of frames 'F'
for(int n = data->srcDescPtr->n - 1; n >= 0; n--) {
for(int n = data->inputTensorDims[0] - 1; n >= 0; n--) {
unsigned index = n * num_of_frames;
for(int f = 0; f < num_of_frames; f++) {
data->alpha[index + f] = data->alpha[n];
data->beta[index + f] = data->beta[n];
data->roiPtr[index + f].xywhROI.xy.x = data->roiPtr[n].xywhROI.xy.x;
data->roiPtr[index + f].xywhROI.xy.y = data->roiPtr[n].xywhROI.xy.y;
data->roiPtr[index + f].xywhROI.roiWidth = data->roiPtr[n].xywhROI.roiWidth;
data->roiPtr[index + f].xywhROI.roiHeight = data->roiPtr[n].xywhROI.roiHeight;
data->roiPtr[index + f].xywhROI = data->roiPtr[n].xywhROI;
}
}
}
Expand Down
13 changes: 5 additions & 8 deletions amd_openvx_extensions/amd_rpp/source/CropMirrorNormalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ struct CropMirrorNormalizeLocalData {

static vx_status VX_CALLBACK refreshCropMirrorNormalize(vx_node node, const vx_reference *parameters, vx_uint32 num, CropMirrorNormalizeLocalData *data) {
vx_status status = VX_SUCCESS;
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[3], 0, data->srcDescPtr->n * data->srcDescPtr->c, sizeof(vx_float32), data->multiplier, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[4], 0, data->srcDescPtr->n * data->srcDescPtr->c, sizeof(vx_float32), data->offset, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[5], 0, data->srcDescPtr->n, sizeof(vx_uint32), data->mirror, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[3], 0, data->inputTensorDims[0] * data->srcDescPtr->c, sizeof(vx_float32), data->multiplier, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[4], 0, data->inputTensorDims[0] * data->srcDescPtr->c, sizeof(vx_float32), data->offset, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));
STATUS_ERROR_CHECK(vxCopyArrayRange((vx_array)parameters[5], 0, data->inputTensorDims[0], sizeof(vx_uint32), data->mirror, VX_READ_ONLY, VX_MEMORY_TYPE_HOST));

if (data->deviceType == AGO_TARGET_AFFINITY_GPU) {
#if ENABLE_HIP
Expand All @@ -66,7 +66,7 @@ static vx_status VX_CALLBACK refreshCropMirrorNormalize(vx_node node, const vx_r
data->roiPtr = (RpptROI *)data->roiTensorPtr;
if(data->inputLayout == 2 || data->inputLayout == 3) { // For NFCHW and NFHWC formats
unsigned num_of_frames = data->inputTensorDims[1]; // Num of frames 'F'
for(int n = data->srcDescPtr->n - 1; n >= 0; n--) {
for(int n = data->inputTensorDims[0] - 1; n >= 0; n--) {
unsigned index = n * num_of_frames;
for(int f = 0; f < num_of_frames; f++) {
for(int c = 0; c < data->srcDescPtr->c; c++) {
Expand All @@ -76,10 +76,7 @@ static vx_status VX_CALLBACK refreshCropMirrorNormalize(vx_node node, const vx_r
data->offset[dst_ind] = data->offset[src_ind];
}
data->mirror[index + f] = data->mirror[n];
data->roiPtr[index + f].xywhROI.xy.x = data->roiPtr[n].xywhROI.xy.x;
data->roiPtr[index + f].xywhROI.xy.y = data->roiPtr[n].xywhROI.xy.y;
data->roiPtr[index + f].xywhROI.roiWidth = data->roiPtr[n].xywhROI.roiWidth;
data->roiPtr[index + f].xywhROI.roiHeight = data->roiPtr[n].xywhROI.roiHeight;
data->roiPtr[index + f].xywhROI = data->roiPtr[n].xywhROI;
}
}
}
Expand Down
Loading

0 comments on commit 0808d57

Please sign in to comment.