Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit db509bf

Browse files
committed
update 20170707
1 parent 09c6a52 commit db509bf

30 files changed

+5387
-2283
lines changed

examples/gdf/canny.gdf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# create input and output images
2+
data input = image:480,360,RGB2
3+
data output = image:480,360,U008
4+
5+
# specify input source for input image and request for displaying input and output images
6+
read input examples/images/face1.jpg
7+
view input inputWindow
8+
view output edgesWindow
9+
10+
# compute luma image channel from input RGB image
11+
data yuv = image-virtual:0,0,IYUV
12+
data luma = image-virtual:0,0,U008
13+
node org.khronos.openvx.color_convert input yuv
14+
node org.khronos.openvx.channel_extract yuv !CHANNEL_Y luma
15+
16+
# compute edges in luma image using Canny edge detector
17+
data hyst = threshold:RANGE,UINT8:INIT,80,100
18+
data gradient_size = scalar:INT32,3
19+
node org.khronos.openvx.canny_edge_detector luma hyst gradient_size !NORM_L1 output

examples/gdf/skintonedetect.gdf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# create input and output images
2+
data input = image:480,360,RGB2
3+
data output = image:480,360,U008
4+
5+
# specify input source for input image and request for displaying input and output images
6+
read input examples/images/face1.jpg
7+
view input inputWindow
8+
view output skintoneWindow
9+
10+
# threshold objects
11+
data thr95 = threshold:BINARY,UINT8:INIT,95 # threshold for computing R > 95
12+
data thr40 = threshold:BINARY,UINT8:INIT,40 # threshold for computing G > 40
13+
data thr20 = threshold:BINARY,UINT8:INIT,20 # threshold for computing B > 20
14+
data thr15 = threshold:BINARY,UINT8:INIT,15 # threshold for computing R-G > 15
15+
data thr0 = threshold:BINARY,UINT8:INIT,0 # threshold for computing R-B > 0
16+
17+
# virtual image objects for intermediate results
18+
data R = image-virtual:0,0,U008
19+
data G = image-virtual:0,0,U008
20+
data B = image-virtual:0,0,U008
21+
data RmG = image-virtual:0,0,U008
22+
data RmB = image-virtual:0,0,U008
23+
data R95 = image-virtual:0,0,U008
24+
data G40 = image-virtual:0,0,U008
25+
data B20 = image-virtual:0,0,U008
26+
data RmG15 = image-virtual:0,0,U008
27+
data RmB0 = image-virtual:0,0,U008
28+
data and1 = image-virtual:0,0,U008
29+
data and2 = image-virtual:0,0,U008
30+
data and3 = image-virtual:0,0,U008
31+
32+
# extract R,G,B channels and compute R-G and R-B
33+
node org.khronos.openvx.channel_extract input !CHANNEL_R R # extract R channel
34+
node org.khronos.openvx.channel_extract input !CHANNEL_G G # extract G channel
35+
node org.khronos.openvx.channel_extract input !CHANNEL_B B # extract B channel
36+
node org.khronos.openvx.subtract R G !SATURATE RmG # compute R-G
37+
node org.khronos.openvx.subtract R B !SATURATE RmB # compute R-B
38+
39+
# compute threshold
40+
node org.khronos.openvx.threshold R thr95 R95 # compute R > 95
41+
node org.khronos.openvx.threshold G thr40 G40 # compute G > 40
42+
node org.khronos.openvx.threshold B thr20 B20 # compute B > 20
43+
node org.khronos.openvx.threshold RmG thr15 RmG15 # compute RmG > 15
44+
node org.khronos.openvx.threshold RmB thr0 RmB0 # compute RmB > 0
45+
46+
# aggregate all thresholded values to produce SKIN pixels
47+
node org.khronos.openvx.and R95 G40 and1 # compute R95 & G40
48+
node org.khronos.openvx.and and1 B20 and2 # compute B20 & and1
49+
node org.khronos.openvx.and RmG15 RmB0 and3 # compute RmG15 & RmB0
50+
node org.khronos.openvx.and and2 and3 output # compute and2 & and3 as output

examples/images/face1.jpg

32.3 KB
Loading

openvx/ago/ago_drama_alloc.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int agoOptimizeDramaAllocGpuResources(AgoGraph * graph)
6666
// check to make sure that GPU resources are needed
6767
bool gpuNeeded = false;
6868
for (AgoNode * node = graph->nodeList.head; node; node = node->next) {
69-
if (node->attr_affinity.device_type == AGO_KERNEL_FLAG_DEVICE_GPU) {
69+
if (node->attr_affinity.device_type == AGO_KERNEL_FLAG_DEVICE_GPU || node->akernel->opencl_buffer_access_enable) {
7070
gpuNeeded = true;
7171
break;
7272
}
@@ -211,6 +211,15 @@ static int agoOptimizeDramaAllocGpuResources(AgoGraph * graph)
211211
}
212212
}
213213
}
214+
// allocate buffers for nodes with opencl_buffer_access_enable
215+
for (AgoNode * node = graph->nodeList.head; node; node = node->next) {
216+
if (node->akernel->opencl_buffer_access_enable) {
217+
// make sure that the GPU buffer resources are allocated in node
218+
if (agoGpuOclAllocBuffers(graph, node) < 0) {
219+
return -1;
220+
}
221+
}
222+
}
214223

215224
return 0;
216225
}

openvx/ago/ago_interface.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ static int agoDataSyncFromGpuToCpu(AgoGraph * graph, AgoNode * node, AgoData * d
18691869
// transfer only region that has valid data
18701870
size = dataToSync->u.arr.numitems * dataToSync->u.arr.itemsize;
18711871
}
1872-
else if (dataToSync->ref.type == VX_TYPE_IMAGE && node->akernel->opencl_image_access_enable) {
1872+
else if (node->akernel->opencl_buffer_access_enable) {
18731873
// no need to transfer to CPU for this node
18741874
size = 0;
18751875
}
@@ -2088,12 +2088,15 @@ int agoExecuteGraph(AgoGraph * graph)
20882088
// mark that node outputs are dirty
20892089
for (vx_uint32 i = 0; i < node->paramCount; i++) {
20902090
AgoData * data = node->paramList[i];
2091-
if (data && data->opencl_buffer && !data->u.img.enableUserBufferOpenCL &&
2091+
if (data && data->opencl_buffer &&
20922092
(node->parameters[i].direction == VX_OUTPUT || node->parameters[i].direction == VX_BIDIRECTIONAL))
20932093
{
20942094
auto dataToSync = (data->ref.type == VX_TYPE_IMAGE && data->u.img.isROI) ? data->u.img.roiMasterImage : data;
20952095
dataToSync->buffer_sync_flags &= ~AGO_BUFFER_SYNC_FLAG_DIRTY_MASK;
2096-
dataToSync->buffer_sync_flags |= AGO_BUFFER_SYNC_FLAG_DIRTY_BY_NODE;
2096+
dataToSync->buffer_sync_flags |=
2097+
((node->akernel->opencl_buffer_access_enable || data->u.img.enableUserBufferOpenCL)
2098+
? AGO_BUFFER_SYNC_FLAG_DIRTY_BY_NODE_CL
2099+
: AGO_BUFFER_SYNC_FLAG_DIRTY_BY_NODE);
20972100
}
20982101
}
20992102
#endif

openvx/ago/ago_internal.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ THE SOFTWARE.
157157
// thread scheduling configuration
158158
#define CONFIG_THREAD_DEFAULT 1 // 0:disable 1:enable separate threads for graph scheduling
159159

160+
// module specific
161+
#define MAX_MODULE_NAME_SIZE 256
162+
#define MAX_MODULE_PATH_SIZE 1024
163+
160164
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
161165
// helpful macros
162166
//
@@ -474,7 +478,7 @@ struct AgoKernel {
474478
amd_kernel_opencl_global_work_update_callback_f opencl_global_work_update_callback_f;
475479
amd_kernel_opencl_buffer_update_callback_f opencl_buffer_update_callback_f;
476480
vx_uint32 opencl_buffer_update_param_index;
477-
vx_bool opencl_image_access_enable;
481+
vx_bool opencl_buffer_access_enable;
478482
vx_uint32 importing_module_index_plus1;
479483
public:
480484
AgoKernel();
@@ -616,6 +620,7 @@ struct AgoGraph {
616620
vx_uint32 execFrameCount;
617621
bool enable_performance_profiling;
618622
std::vector<AgoProfileEntry> performance_profile;
623+
std::map<std::string,void *> moduleHandle;
619624
public:
620625
AgoGraph();
621626
~AgoGraph();
@@ -630,8 +635,8 @@ struct AgoImageFormatDescItem {
630635
AgoImageFormatDescription desc;
631636
};
632637
struct ModuleData {
633-
char module_name[256];
634-
char module_path[1024];
638+
char module_name[MAX_MODULE_NAME_SIZE];
639+
char module_path[MAX_MODULE_PATH_SIZE];
635640
ago_module hmodule;
636641
vx_uint8 * module_internal_data_ptr;
637642
vx_size module_internal_data_size;

openvx/ago/ago_platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ THE SOFTWARE.
3737
#include <stdio.h>
3838
#include <stdarg.h>
3939
#include <stdlib.h>
40+
#include <string.h>
4041
#include <limits.h>
4142
#include <float.h>
4243
#include <math.h>

openvx/ago/ago_util.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static struct { const char * name; vx_enum value; vx_size size; } s_table_consta
6767
{ "KEYPOINT", VX_TYPE_KEYPOINT, sizeof(vx_keypoint_t) },
6868
{ "COORDINATES2D", VX_TYPE_COORDINATES2D, sizeof(vx_coordinates2d_t) },
6969
{ "COORDINATES3D", VX_TYPE_COORDINATES3D, sizeof(vx_coordinates3d_t) },
70+
{ "COORDINATES2DF", VX_TYPE_COORDINATES2DF, sizeof(vx_coordinates2df_t) },
7071
{ "DF_IMAGE", VX_TYPE_DF_IMAGE, sizeof(vx_df_image) },
7172
{ "ENUM", VX_TYPE_ENUM, sizeof(vx_enum) },
7273
{ "UINT64", VX_TYPE_UINT64, sizeof(vx_uint64) },
@@ -85,6 +86,13 @@ static struct { const char * name; vx_enum value; vx_size size; } s_table_consta
8586
{ "BOOL", VX_TYPE_BOOL, sizeof(vx_bool) },
8687
{ "KEYPOINT_XYS", AGO_TYPE_KEYPOINT_XYS, sizeof(ago_keypoint_xys_t) },
8788
{ "STRING", VX_TYPE_STRING_AMD },
89+
{ "VX_TYPE_HOG", VX_TYPE_HOG, sizeof(vx_hog_t) },
90+
{ "VX_TYPE_HOUGH_LINES_P", VX_TYPE_HOUGH_LINES_P, sizeof(vx_hough_lines_p_t) },
91+
{ "VX_TYPE_LINE2D", VX_TYPE_LINE2D, sizeof(vx_line2d_t) },
92+
{ "VX_TYPE_MATRIX_MULTIPLY_PARAMS", VX_TYPE_MATRIX_MULTIPLY_PARAMS, sizeof(vx_matrix_multiply_params_t) },
93+
{ "VX_TYPE_NN_CONV_PARAMS", VX_TYPE_NN_CONV_PARAMS, sizeof(vx_nn_convolution_params_t) },
94+
{ "VX_TYPE_NN_DECONV_PARAMS", VX_TYPE_NN_DECONV_PARAMS, sizeof(vx_nn_deconvolution_params_t) },
95+
{ "VX_TYPE_NN_ROIPOOL_PARAMS", VX_TYPE_NN_ROIPOOL_PARAMS, sizeof(vx_nn_roi_pool_params_t) },
8896
// for debug purposes only
8997
{ "VX_TYPE_LUT", VX_TYPE_LUT },
9098
{ "VX_TYPE_DISTRIBUTION", VX_TYPE_DISTRIBUTION },
@@ -2961,7 +2969,7 @@ AgoKernel::AgoKernel()
29612969
kernel_f{ nullptr }, validate_f{ nullptr }, input_validate_f{ nullptr }, output_validate_f{ nullptr }, initialize_f{ nullptr }, deinitialize_f{ nullptr },
29622970
query_target_support_f{ nullptr }, opencl_codegen_callback_f{ nullptr }, regen_callback_f{ nullptr }, opencl_global_work_update_callback_f{ nullptr },
29632971
opencl_buffer_update_callback_f{ nullptr }, opencl_buffer_update_param_index{ 0 },
2964-
opencl_image_access_enable{ vx_false_e }, importing_module_index_plus1{ 0 }
2972+
opencl_buffer_access_enable{ vx_false_e }, importing_module_index_plus1{ 0 }
29652973
{
29662974
memset(&name, 0, sizeof(name));
29672975
memset(&argConfig, 0, sizeof(argConfig));

openvx/ago/ago_util_opencl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ static void clDumpBuffer(const char * fileNameFormat, cl_command_queue opencl_cm
3535
char fileName[1024]; sprintf(fileName, fileNameFormat, dumpBufferCount);
3636
cl_mem opencl_buffer = data->opencl_buffer;
3737
cl_uint opencl_buffer_offset = data->opencl_buffer_offset;
38-
cl_uint size = (cl_uint)(data->u.img.stride_in_bytes*data->u.img.height);
38+
cl_uint size = (cl_uint)0;
39+
if (data->ref.type == VX_TYPE_IMAGE)
40+
size = (cl_uint)(data->u.img.stride_in_bytes*data->u.img.height);
41+
else
42+
size = (cl_uint)data->size;
3943
FILE * fp = fopen(fileName, "wb"); if (!fp) { printf("ERROR: unable to create: %s\n", fileName); exit(1); }
4044
clFinish(opencl_cmdq);
4145
void * p = clEnqueueMapBuffer(opencl_cmdq, opencl_buffer, CL_TRUE, CL_MAP_READ, 0, opencl_buffer_offset + size, 0, NULL, NULL, NULL);

0 commit comments

Comments
 (0)