Skip to content

Commit dcbe5ed

Browse files
authored
Objects rework (#24)
* Added corevx namespace * Reworked objects * More updates to delay and lut * Cleanup to context * Moving sensitive members to private * Added C++ helpers for node kernel * Added some cpp samples * Fixed build issue * Documentation updates
1 parent c235a98 commit dcbe5ed

File tree

92 files changed

+1978
-1023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1978
-1023
lines changed

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ EXCLUDE_PATTERNS = */bazel-*/* \
11201120
*/build/* \
11211121
*/cts/* \
11221122
*/external/* \
1123-
*/kernels/NNEF-Tools/* \
1123+
*/kernels/nnef/NNEF-Tools/* \
11241124
*/kernels/utils/half/* \
11251125
*.md \
11261126
/private/var/tmp/_bazel* \

framework/include/vx_array.h

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,37 @@ class Array : public Reference
6969
* @param capacity capacity of array
7070
* @param is_virtual is array virtual
7171
* @param type array or lut
72-
* @return vx_array
72+
* @return vx_array array object
7373
* @ingroup group_int_array
7474
*/
75-
static vx_array createArray(vx_context context, vx_enum item_type, vx_size capacity, vx_bool is_virtual, vx_enum type);
75+
static vx_array createArray(
76+
vx_context context, vx_enum item_type, vx_size capacity, vx_bool is_virtual = vx_false_e, vx_enum type = VX_TYPE_ARRAY);
77+
78+
/**
79+
* @brief Create a LUT object
80+
*
81+
* @param context context object
82+
* @param data_type array object type
83+
* @param count count of array
84+
* @return vx_lut_t LUT object
85+
* @ingroup group_int_array
86+
*/
87+
static vx_lut_t createLUT(vx_context context, vx_enum data_type, vx_size count);
7688

7789
/**
7890
* @brief Validate array object
7991
*
8092
* @param item_type array object type
8193
* @param capacity capacity of array
82-
* @return vx_bool
94+
* @return vx_bool true if valid, false otherwise
8395
* @ingroup group_int_array
8496
*/
8597
vx_bool validateArray(vx_enum item_type, vx_size capacity);
8698

8799
/**
88100
* @brief Allocate memory for array object
89101
*
90-
* @return vx_bool
102+
* @return vx_bool true if successful, false otherwise
91103
* @ingroup group_int_array
92104
*/
93105
vx_bool allocateArray();
@@ -97,7 +109,7 @@ class Array : public Reference
97109
*
98110
* @param context global context
99111
* @param item_type item type
100-
* @return vx_size
112+
* @return vx_size size of item
101113
* @ingroup group_int_array
102114
*/
103115
static vx_size itemSize(vx_context context, vx_enum item_type);
@@ -107,7 +119,7 @@ class Array : public Reference
107119
*
108120
* @param context global context
109121
* @param item_type item type
110-
* @return vx_bool
122+
* @return vx_bool true if valid, false otherwise
111123
* @ingroup group_int_array
112124
*/
113125
static vx_bool isValidArrayItemType(vx_context context, vx_enum item_type);
@@ -116,7 +128,7 @@ class Array : public Reference
116128
* @brief Validate array object
117129
*
118130
* @param arr array object to check
119-
* @return vx_bool
131+
* @return vx_bool true if valid, false otherwise
120132
* @ingroup group_int_array
121133
*/
122134
static vx_bool isValidArray(vx_array arr);
@@ -133,7 +145,7 @@ class Array : public Reference
133145
*
134146
* @param item_type array object type
135147
* @param capacity capacity of array
136-
* @return vx_bool
148+
* @return vx_bool true if successful, false otherwise
137149
* @ingroup group_int_array
138150
*/
139151
vx_bool initVirtualArray(vx_enum item_type, vx_size capacity);
@@ -209,53 +221,53 @@ class Array : public Reference
209221
/**
210222
* @brief Access array range in object
211223
*
212-
* @param start start index
213-
* @param end end index
214-
* @param pStride pointer of stride
215-
* @param ptr pointer to data
216-
* @param usage ro | rw | wo
217-
* @return vx_status
224+
* @param start start index
225+
* @param end end index
226+
* @param pStride pointer of stride
227+
* @param ptr pointer to data
228+
* @param usage ro | rw | wo
229+
* @return vx_status VX_SUCCESS if successful, any other value indicates failure.
218230
* @ingroup group_int_array
219231
*/
220232
vx_status accessArrayRange(vx_size start, vx_size end, vx_size *pStride, void **ptr, vx_enum usage);
221233

222234
/**
223235
* @brief Commit array range
224236
*
225-
* @param start start index
226-
* @param end end index
227-
* @param ptr pointer to data
228-
* @return vx_status
237+
* @param start start index
238+
* @param end end index
239+
* @param ptr pointer to data
240+
* @return vx_status VX_SUCCESS if successful, any other value indicates failure.
229241
* @ingroup group_int_array
230242
*/
231243
vx_status commitArrayRange(vx_size start, vx_size end, const void *ptr);
232244

233245
/**
234246
* @brief Copy array range
235247
*
236-
* @param start start index
237-
* @param end end index
238-
* @param stride size of stride
239-
* @param ptr pointer to data
240-
* @param usage ro | rw | wo
241-
* @param mem_type host | device
242-
* @return vx_status
248+
* @param start start index
249+
* @param end end index
250+
* @param stride size of stride
251+
* @param ptr pointer to data
252+
* @param usage ro | rw | wo
253+
* @param mem_type host | device
254+
* @return vx_status VX_SUCCESS if successful, any other value indicates failure.
243255
* @ingroup group_int_array
244256
*/
245257
vx_status copyArrayRange(vx_size start, vx_size end, vx_size stride, void *ptr, vx_enum usage, vx_enum mem_type);
246258

247259
/**
248260
* @brief Map array range
249261
*
250-
* @param start start index
251-
* @param end end index
252-
* @param map_id memory map id
253-
* @param stride size of stride
254-
* @param ptr pointer to data
255-
* @param usage ro | rw | wo
256-
* @param mem_type host | device
257-
* @param flags additional flags
258-
* @return vx_status
262+
* @param start start index
263+
* @param end end index
264+
* @param map_id memory map id
265+
* @param stride size of stride
266+
* @param ptr pointer to data
267+
* @param usage ro | rw | wo
268+
* @param mem_type host | device
269+
* @param flags additional flags
270+
* @return vx_status VX_SUCCESS if successful, any other value indicates failure.
259271
* @ingroup group_int_array
260272
*/
261273
vx_status mapArrayRange(vx_size start, vx_size end, vx_map_id *map_id, vx_size *stride,
@@ -265,7 +277,7 @@ class Array : public Reference
265277
* @brief Unmap array range
266278
*
267279
* @param map_id memory map id
268-
* @return vx_status
280+
* @return vx_status VX_SUCCESS if successful, any other value indicates failure.
269281
* @ingroup group_int_array
270282
*/
271283
vx_status unmapArrayRange(vx_map_id map_id);
@@ -300,5 +312,4 @@ class Array : public Reference
300312

301313
} // namespace corevx
302314

303-
304-
#endif /* VX_ARRAY_H */
315+
#endif /* VX_ARRAY_H */

framework/include/vx_context.h

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,65 @@
2525

2626
/*!
2727
* \file
28-
* \brief
28+
* \brief The internal context implementation.
2929
*
3030
* \defgroup group_int_context Internal Context API
3131
* \ingroup group_internal
3232
* \brief The Internal Context API
3333
*/
3434

35-
/*! \brief The implementation string which is of the format "<vendor>.<substring>" */
36-
extern const vx_char implementation[];
37-
3835
/*! \brief The top level context data for the entire OpenVX instance
3936
* \ingroup group_int_context
4037
*/
4138
namespace corevx {
4239

43-
class Context : public Reference
40+
class Context final : public Reference
4441
{
42+
private:
43+
/**
44+
* @brief Launch worker graph thread
45+
*
46+
* @param arg Optional argument to pass as parameter.
47+
* @return vx_value_t Thread return value.
48+
* @ingroup group_int_context
49+
*/
50+
static vx_value_t workerGraph(void* arg);
51+
52+
/**
53+
* @brief Launch worker node
54+
*
55+
* @param worker The threadpool of the worker.
56+
* @return vx_bool vx_true_e if ran successful, vx_false_e otherwise
57+
* @ingroup group_int_context
58+
*/
59+
static vx_bool workerNode(vx_threadpool_worker_t* worker);
60+
4561
public:
4662
/**
4763
* @brief Construct a new Context object
4864
* @ingroup group_int_context
4965
*/
5066
Context();
5167

68+
/**
69+
* @brief Delete copy constructor and assignment operator to prevent copying
70+
* @ingroup group_int_context
71+
*/
72+
Context(const Context&) = delete;
73+
Context& operator=(const Context&) = delete;
74+
5275
/**
5376
* @brief Destroy the Context object
5477
* @ingroup group_int_context
5578
*/
5679
~Context();
5780

81+
/**
82+
* @brief Create a new context
83+
* @ingroup group_int_context
84+
*/
85+
static vx_context createContext();
86+
5887
/**
5988
* @brief Get vendor id
6089
*
@@ -167,6 +196,7 @@ class Context : public Reference
167196
*/
168197
std::vector<vx_kernel_info_t> uniqueKernelTable();
169198

199+
#ifdef OPENVX_USE_OPENCL_INTEROP
170200
/**
171201
* @brief Get the OpenCL context
172202
*
@@ -182,6 +212,7 @@ class Context : public Reference
182212
* @ingroup group_int_context
183213
*/
184214
cl_command_queue clCommandQueue() const;
215+
#endif /** OPENVX_USE_OPENCL_INTEROP */
185216

186217
/**
187218
* @brief Set the logging enabled state
@@ -313,24 +344,6 @@ class Context : public Reference
313344
*/
314345
static vx_bool isValidBorderMode(vx_enum mode);
315346

316-
/**
317-
* @brief Launch worker graph thread
318-
*
319-
* @param arg Optional argument to pass as parameter.
320-
* @return vx_value_t Thread return value.
321-
* @ingroup group_int_context
322-
*/
323-
static vx_value_t workerGraph(void *arg);
324-
325-
/**
326-
* @brief Launch worker node
327-
*
328-
* @param worker The threadpool of the worker.
329-
* @return vx_bool vx_true_e if ran successful, vx_false_e otherwise
330-
* @ingroup group_int_context
331-
*/
332-
static vx_bool workerNode(vx_threadpool_worker_t *worker);
333-
334347
/**
335348
* @brief Register a user struct with a certain number of bytes
336349
*
@@ -501,13 +514,12 @@ class Context : public Reference
501514
const vx_uint16 vendor_id;
502515
/*! \brief The version number this implements */
503516
const vx_uint16 version_number;
504-
/*! \brief The name of this impleemntation */
517+
/*! \brief The implementation string which is of the format "<vendor>.<substring>" */
505518
const vx_char implementation[VX_MAX_IMPLEMENTATION_NAME];
506519
/*! \brief The name of additional extensions in this impleemntation */
507520
const vx_char* extension;
508521
};
509522

510523
} // namespace corevx
511524

512-
513-
#endif /* VX_CONTEXT_H */
525+
#endif /* VX_CONTEXT_H */

framework/include/vx_convolution.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ class Convolution : public Matrix
4646
*/
4747
Convolution(vx_context context, vx_reference scope);
4848

49+
/**
50+
* @brief Create a new convolution
51+
*
52+
* @param context The context associated with this convolution
53+
* @param columns The number of columns in the convolution
54+
* @param rows The number of rows in the convolution
55+
* @return vx_convolution The convolution object
56+
* @ingroup group_int_convolution
57+
*/
58+
static vx_convolution createConvolution(vx_context context, vx_size columns, vx_size rows);
59+
4960
/**
5061
* @brief Get the scale factor of the convolution
5162
*
@@ -118,5 +129,4 @@ class Convolution : public Matrix
118129

119130
} // namespace corevx
120131

121-
122-
#endif /* VX_CONVOLUTION_H */
132+
#endif /* VX_CONVOLUTION_H */

framework/include/vx_debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
/*!
3131
* \file
32+
* \brief The internal debugging implementation.
3233
*
3334
* \defgroup group_int_debug Internal Debugging API
3435
* \ingroup group_internal

framework/include/vx_delay.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ class Delay : public Reference
4646
*/
4747
~Delay();
4848

49+
/**
50+
* @brief Create a delay object
51+
*
52+
* @param context
53+
* @param exemplar
54+
* @param count
55+
* @return vx_delay
56+
* @ingroup group_int_delay
57+
*/
58+
static vx_delay createDelay(vx_context context, vx_reference exemplar, vx_size count);
59+
4960
/**
5061
* @brief Get data type of references associated with this delay object
5162
*

framework/include/vx_distribution.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ class Distribution : public Reference
4545
*/
4646
Distribution(vx_context context, vx_reference scope);
4747

48+
/**
49+
* @brief Create a new distribution
50+
*
51+
* @param context The context associated with this distribution
52+
* @param numBins The number of bins in the distribution
53+
* @param offset The offset of the distribution
54+
* @param range The range of the distribution
55+
* @return vx_distribution The distribution object
56+
* @ingroup group_int_distribution
57+
*/
58+
static vx_distribution createDistribution(vx_context context, vx_size numBins, vx_int32 offset, vx_uint32 range);
59+
4860
/**
4961
* @brief Get the number of dimensions in the distribution
5062
*
@@ -171,5 +183,4 @@ class Distribution : public Reference
171183

172184
} // namespace corevx
173185

174-
175-
#endif /* VX_DISTRIBUTION_H */
186+
#endif /* VX_DISTRIBUTION_H */

0 commit comments

Comments
 (0)