Skip to content

Commit

Permalink
ResizeTensor addition
Browse files Browse the repository at this point in the history
  • Loading branch information
swetha097 committed Sep 24, 2022
1 parent db53bc5 commit bb6ad60
Show file tree
Hide file tree
Showing 9 changed files with 440 additions and 12 deletions.
1 change: 1 addition & 0 deletions amd_openvx_extensions/amd_rpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ list(APPEND SOURCES
source/RandomShadowbatchPD.cpp
source/Remap.cpp
source/ResizebatchPD.cpp
source/Resizetensor.cpp
source/ResizeCropbatchPD.cpp
source/ResizeCropMirrorPD.cpp
source/RotatebatchPD.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ vx_status ThresholdingbatchPD_Register(vx_context);
vx_status VignettebatchPD_Register(vx_context);
vx_status WarpAffinebatchPD_Register(vx_context);
vx_status WarpPerspectivebatchPD_Register(vx_context);
vx_status Resizetensor_Register(vx_context);

// kernel names
#define VX_KERNEL_RPP_NOP_NAME "org.rpp.Nop"
Expand Down Expand Up @@ -197,5 +198,6 @@ vx_status WarpPerspectivebatchPD_Register(vx_context);
#define VX_KERNEL_RPP_CROPPD_NAME "org.rpp.CropPD"
#define VX_KERNEL_RPP_RESIZECROPMIRRORPD_NAME "org.rpp.ResizeCropMirrorPD"
#define VX_KERNEL_RPP_SEQUENCEREARRANGE_NAME "org.rpp.SequenceRearrange"
#define VX_KERNEL_RPP_RESIZETENSOR_NAME "org.rpp.Resizetensor"

#endif //_AMDVX_EXT__PUBLISH_KERNELS_H_
3 changes: 2 additions & 1 deletion amd_openvx_extensions/amd_rpp/include/kernels_rpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ extern "C"
VX_KERNEL_RPP_TENSORLOOKUP = VX_KERNEL_BASE(VX_ID_AMD, VX_LIBRARY_RPP) + 0x4e,
VX_KERNEL_RPP_VIGNETTEBATCHPD = VX_KERNEL_BASE(VX_ID_AMD, VX_LIBRARY_RPP) + 0x4f,
VX_KERNEL_RPP_WARPAFFINEBATCHPD = VX_KERNEL_BASE(VX_ID_AMD, VX_LIBRARY_RPP) + 0x50,
VX_KERNEL_RPP_WARPPERSPECTIVEBATCHPD = VX_KERNEL_BASE(VX_ID_AMD, VX_LIBRARY_RPP) + 0x51
VX_KERNEL_RPP_WARPPERSPECTIVEBATCHPD = VX_KERNEL_BASE(VX_ID_AMD, VX_LIBRARY_RPP) + 0x51,
VX_KERNEL_RPP_RESIZETENSOR = VX_KERNEL_BASE(VX_ID_AMD, VX_LIBRARY_RPP) + 0x52
};

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions amd_openvx_extensions/amd_rpp/include/vx_ext_rpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ extern "C" SHARED_PUBLIC vx_node VX_API_CALL vxExtrppNode_VignettebatchPD(vx_gr
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_int32 interpolation_type,vx_uint32 nbatchSize);
#ifdef __cplusplus
}
#endif
Expand Down
397 changes: 397 additions & 0 deletions amd_openvx_extensions/amd_rpp/source/Resizetensor.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ vx_status get_kernels_to_publish()
STATUS_ERROR_CHECK(ADD_KERENEL(Copy_Register));
STATUS_ERROR_CHECK(ADD_KERENEL(Nop_Register));
STATUS_ERROR_CHECK(ADD_KERENEL(SequenceRearrange_Register));
STATUS_ERROR_CHECK(ADD_KERENEL(Resizetensor_Register));
return status;
}

Expand Down
25 changes: 25 additions & 0 deletions amd_openvx_extensions/amd_rpp/source/kernel_rpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,31 @@ VX_API_ENTRY vx_node VX_API_CALL vxExtrppNode_ResizebatchPD(vx_graph graph, vx_i
return node;
}

VX_API_ENTRY 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_int32 interpolation_type, vx_uint32 nbatchSize)
{
vx_node node = NULL;
vx_context context = vxGetContext((vx_reference)graph);
if (vxGetStatus((vx_reference)context) == VX_SUCCESS)
{
vx_uint32 dev_type = getGraphAffinity(graph);
vx_scalar DEV_TYPE = vxCreateScalar(vxGetContext((vx_reference)graph), VX_TYPE_UINT32, &dev_type);
vx_scalar NBATCHSIZE = vxCreateScalar(vxGetContext((vx_reference)graph), VX_TYPE_UINT32, &nbatchSize);
vx_scalar INTERPOLATION_TYPE = vxCreateScalar(vxGetContext((vx_reference)graph), VX_TYPE_INT32, &interpolation_type);
vx_reference params[] = {
(vx_reference)pSrc,
(vx_reference)srcImgWidth,
(vx_reference)srcImgHeight,
(vx_reference)pDst,
(vx_reference)dstImgWidth,
(vx_reference)dstImgHeight,
(vx_reference)INTERPOLATION_TYPE,
(vx_reference)NBATCHSIZE,
(vx_reference)DEV_TYPE};
node = createNode(graph, VX_KERNEL_RPP_RESIZETENSOR, params, 9);
}
return node;
}

VX_API_ENTRY vx_node VX_API_CALL vxExtrppNode_ResizeCropbatchPD(vx_graph graph, vx_image pSrc, vx_array srcImgWidth, vx_array srcImgHeight, vx_image pDst, vx_array dstImgWidth, vx_array dstImgHeight, vx_array x1, vx_array y1, vx_array x2, vx_array y2, vx_uint32 nbatchSize)
{
vx_node node = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void ResizeNode::create_node()
height_status = vxAddArrayItems(_dst_roi_height, _batch_size, dst_roi_height.data(), sizeof(vx_uint32));
if(width_status != 0 || height_status != 0)
THROW(" vxAddArrayItems failed in the resize (vxExtrppNode_ResizebatchPD) node: "+ TOSTR(width_status) + " "+ TOSTR(height_status))
// _node = vxExtrppNode_ResizebatchPD(_graph->get(), _inputs[0]->handle(), _src_roi_width, _src_roi_height, _outputs[0]->handle(), _dst_roi_width, _dst_roi_height, _batch_size);

_node = vxExtrppNode_ResizebatchPD(_graph->get(), _inputs[0]->handle(), _src_roi_width, _src_roi_height, _outputs[0]->handle(), _dst_roi_width, _dst_roi_height, _batch_size);

_node = vxExtrppNode_Resizetensor(_graph->get(), _inputs[0]->handle(), _src_roi_width, _src_roi_height, _outputs[0]->handle(), _dst_roi_width, _dst_roi_height, _interpolation_type, _batch_size);
vx_status status;
if((status = vxGetStatus((vx_reference)_node)) != VX_SUCCESS)
THROW("Adding the resize (vxExtrppNode_ResizebatchPD) node failed: "+ TOSTR(status))
Expand Down
18 changes: 9 additions & 9 deletions rocAL/rocAL_pybind/amd/rocal/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def image_random_crop(*inputs, user_feature_key_map=None, path='', file_root='',
"shuffle": random_shuffle,
"loop": False,
"decode_size_policy": types.USER_GIVEN_SIZE_ORIG,
"max_width": 3000,
"max_height": 3000,
"max_width": 2000,
"max_height": 2000,
"x_drift_factor": None,
"y_drift_factor": None}
crop_output_image = b.FusedDecoderCropShard(
Expand All @@ -202,7 +202,7 @@ def image_random_crop(*inputs, user_feature_key_map=None, path='', file_root='',


def image_slice(*inputs, file_root='', path='', annotations_file='', shard_id=0, num_shards=1, random_shuffle=False, affine=True, axes=None, axis_names="WH", bytes_per_sample_hint=0, device_memory_padding=16777216,
device_memory_padding_jpeg2k=0, host_memory_padding=8388608, random_aspect_ratio=[0.8, 1.25], random_area=[0.08, 1.0], num_attemps=100,
device_memory_padding_jpeg2k=0, host_memory_padding=8388608, random_aspect_ratio=[0.8, 1.25], random_area=[0.08, 1.0], num_attempts=100,
host_memory_padding_jpeg2k=0, hybrid_huffman_threshold=1000000,
memory_stats=False, normalized_anchor=True, normalized_shape=True, output_type=types.RGB,
preserve=False, seed=1, split_stages=False, use_chunk_allocator=False, use_fast_idct=False, device=None):
Expand All @@ -222,7 +222,7 @@ def image_slice(*inputs, file_root='', path='', annotations_file='', shard_id=0,
'is_output': False,
"area_factor": random_area,
"aspect_ratio": random_aspect_ratio,
"num_attemps": num_attemps,
"num_attempts": num_attempts,
"shuffle": random_shuffle,
"loop": False,
"decode_size_policy": types.MAX_SIZE,
Expand All @@ -241,7 +241,7 @@ def image_slice(*inputs, file_root='', path='', annotations_file='', shard_id=0,
'is_output': False,
"area_factor": random_area,
"aspect_ratio": random_aspect_ratio,
"num_attemps": num_attemps,
"num_attempts": num_attempts,
"shuffle": random_shuffle,
"loop": False,
"decode_size_policy": types.MAX_SIZE,
Expand All @@ -260,7 +260,7 @@ def image_slice(*inputs, file_root='', path='', annotations_file='', shard_id=0,
'is_output': False,
"area_factor": random_area,
"aspect_ratio": random_aspect_ratio,
"num_attemps": num_attemps,
"num_attempts": num_attempts,
"shuffle": random_shuffle,
"loop": False,
"decode_size_policy": types.MAX_SIZE,
Expand All @@ -279,12 +279,12 @@ def image_slice(*inputs, file_root='', path='', annotations_file='', shard_id=0,
'is_output': False,
"area_factor": random_area,
"aspect_ratio": random_aspect_ratio,
"num_attemps": num_attemps,
"num_attempts": num_attempts,
"shuffle": random_shuffle,
"loop": False,
"decode_size_policy": types.USER_GIVEN_SIZE_ORIG,
"max_width": 3000,
"max_height": 3000,
"max_width": 2000,
"max_height": 2000,
"x_drift_factor": None,
"y_drift_factor": None}
image_decoder_slice = b.FusedDecoderCropShard(
Expand Down

0 comments on commit bb6ad60

Please sign in to comment.