diff --git a/.bazelrc b/.bazelrc index 198b86d0..d7d44c9f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -5,7 +5,7 @@ common --enable_bzlmod build --compiler=g++ # Specify the compiler if needed, e.g., gcc, clang build --cxxopt=-std=c++23 # Use C++23 standard (adjust if needed) build --cxxopt=-DCL_TARGET_OPENCL_VERSION=300 -# build --per_file_copt=.*,-tests/*.cpp@-Werror +build --per_file_copt=.*,-tests/*.cpp@-Werror,-Wall,-Wextra,-Wpedantic,-Wno-deprecated-declarations # Test settings test --test_output=errors # Show errors from tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8f9d095..11154aaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,10 @@ jobs: - name: Build the code run: bazel build //... + # Run OpenVX Integration test + - name: OpenVX Integration Test + run: VX_CL_SOURCE_DIR=$GITHUB_WORKSPACE/kernels/opencl bazel run //tests:vx_test + # Test the project # - name: Run Bazel tests # run: | diff --git a/framework/include/vx_scalar.h b/framework/include/vx_scalar.h index 9fe823a4..bc3c8e59 100644 --- a/framework/include/vx_scalar.h +++ b/framework/include/vx_scalar.h @@ -93,7 +93,7 @@ class Scalar : public Reference /*! \brief Signed 64 bit */ vx_int64 s64; /*! \brief Unsigned 64 bit */ - vx_int64 u64; + vx_uint64 u64; #if defined(EXPERIMENTAL_PLATFORM_SUPPORTS_16_FLOAT) /*! \brief 16 bit float */ vx_float16 f16; diff --git a/framework/src/vx_context.cpp b/framework/src/vx_context.cpp index fbac0151..f8ff6219 100644 --- a/framework/src/vx_context.cpp +++ b/framework/src/vx_context.cpp @@ -254,7 +254,28 @@ vx_status Context::loadTarget(const vx_char* targetName) vx_status Context::unloadTarget(const vx_char* targetName) { - return VX_ERROR_NOT_IMPLEMENTED; + vx_status status = VX_FAILURE; + + for (vx_uint32 t = 0u; t < context->num_targets; t++) + { + if (context->targets[t] && + strncmp(context->targets[t]->name, targetName, VX_MAX_TARGET_NAME) == 0) + { + memset(&context->targets[t]->funcs, 0xFE, sizeof(vx_target_funcs_t)); + if (context->targets[t]->decrementReference(VX_INTERNAL) == 0) + { + /* The ReleaseReference() below errors out if the internal index is 0 */ + context->targets[t]->incrementReference(VX_INTERNAL); + } + Osal::unloadModule(context->targets[t]->module.handle); + context->targets[t]->module.handle = VX_MODULE_INIT; + + memset(context->targets[t]->module.name, 0, sizeof(context->targets[t]->module.name)); + status = Reference::releaseReference((vx_reference*)&context->targets[t], VX_TYPE_TARGET, VX_INTERNAL, nullptr); + } + } + + return status; } vx_status Context::unloadTarget(vx_uint32 index, vx_bool unload_module) @@ -758,8 +779,8 @@ VX_API_ENTRY vx_context VX_API_CALL vxCreateContext(void) if (context->num_targets == 0) { VX_PRINT(VX_ZONE_ERROR, "No targets loaded!\n"); - // free(context); Osal::semPost(&context_lock); + single_context.reset(); return nullptr; } @@ -774,8 +795,11 @@ VX_API_ENTRY vx_context VX_API_CALL vxCreateContext(void) { VX_PRINT(VX_ZONE_WARNING, "Target %s failed to initialize!\n", context->targets[t]->name); /* unload this module */ - context->unloadTarget(t, vx_true_e); - break; + /* @TODO: unload target now or on context release? */ + /* + * context->unloadTarget(t, vx_true_e); + * break; + */ } else { @@ -922,7 +946,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxReleaseContext(vx_context* c) /* de-initialize and unload each target */ for (t = 0u; t < context->num_targets; t++) { - if (context->targets[t]->enabled == vx_true_e) + /* if (context->targets[t]->enabled == vx_true_e) */ { context->targets[t]->funcs.deinit(context->targets[t]); context->targets[t]->enabled = vx_false_e; @@ -1118,7 +1142,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxQueryContext(vx_context context, vx_enum at case VX_CONTEXT_EXTENSIONS: if (size <= sizeof(extensions) && ptr) { - strncpy(reinterpret_cast(ptr), extensions, sizeof(extensions)); + strncpy(reinterpret_cast(ptr), extensions, size); } else { diff --git a/framework/src/vx_dot.cpp b/framework/src/vx_dot.cpp index fce99ad2..2a1f63f0 100644 --- a/framework/src/vx_dot.cpp +++ b/framework/src/vx_dot.cpp @@ -88,7 +88,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxExportGraphToDot(vx_graph graph, vx_char do { vx_pyramid pyr = (vx_pyramid)data[d]; fprintf(fp, "\tD%u [shape=triangle label=\"Pyramid\\n%lfx" VX_FMT_REF "\\nLevels: %zu\"];\n", - d, pyr->scale, pyr->levels, pyr->numLevels); + d, pyr->scale, (void*)pyr->levels, pyr->numLevels); break; } case VX_TYPE_SCALAR: @@ -155,6 +155,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxExportGraphToDot(vx_graph graph, vx_char do { fprintf(fp, "\tD%u [shape=box label=\"Distribution\"];\n", d); } + break; } case VX_TYPE_LUT: { diff --git a/framework/src/vx_error.cpp b/framework/src/vx_error.cpp index a8528d92..31608af9 100644 --- a/framework/src/vx_error.cpp +++ b/framework/src/vx_error.cpp @@ -29,7 +29,8 @@ status(VX_SUCCESS) Error::~Error() { vx_error ref = this; - releaseError(&ref); + if (internal_count) + releaseError(&ref); } void Error::releaseError(vx_error* error) diff --git a/framework/src/vx_helper.cpp b/framework/src/vx_helper.cpp index 01776698..1121b52a 100644 --- a/framework/src/vx_helper.cpp +++ b/framework/src/vx_helper.cpp @@ -160,7 +160,7 @@ vx_node vxCreateNodeByStructure(vx_graph graph, vx_node node = 0; vx_context context = vxGetContext((vx_reference)graph); vx_kernel kernel = vxGetKernelByEnum(context, kernelenum); - if (kernel) + if (VX_SUCCESS == vxGetStatus((vx_reference)kernel)) { node = vxCreateGenericNode(graph, kernel); if (vxGetStatus((vx_reference)node) == VX_SUCCESS) diff --git a/framework/src/vx_ix_export.cpp b/framework/src/vx_ix_export.cpp index 97c16f56..3418df21 100644 --- a/framework/src/vx_ix_export.cpp +++ b/framework/src/vx_ix_export.cpp @@ -268,6 +268,7 @@ static void calculateUses(VXBinExport *xport) break; /* Already assigned, do nothing */ case VX_OUTPUT: /* Part processed by putInTable, is a net output */ xport->ref_table[i].use = VX_IX_USE_NO_EXPORT_VALUES; + break; default: /* All other cases, assume we need to export values unless virtual */ xport->ref_table[i].use = xport->ref_table[i].ref->is_virtual ? VX_IX_USE_NO_EXPORT_VALUES : diff --git a/framework/src/vx_kernel.cpp b/framework/src/vx_kernel.cpp index 4da0c182..d0552fbe 100644 --- a/framework/src/vx_kernel.cpp +++ b/framework/src/vx_kernel.cpp @@ -44,7 +44,7 @@ Kernel::Kernel(vx_context context, vx_char name[VX_MAX_KERNEL_NAME], vx_param_description_t *parameters, vx_uint32 numParams, - vx_reference scope) : Reference(context, VX_TYPE_KERNEL, context) + vx_reference scope) : Reference(context, VX_TYPE_KERNEL, scope) { /* setup the kernel meta-data */ strncpy(this->name, name, VX_MAX_KERNEL_NAME - 1); @@ -556,7 +556,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxReleaseKernel(vx_kernel *kernel) if (nullptr != kernel) { vx_kernel ref = *kernel; - if (vx_true_e == Reference::isValidReference(ref, VX_TYPE_KERNEL) == vx_true_e) + if (vx_true_e == Reference::isValidReference(ref, VX_TYPE_KERNEL)) { VX_PRINT(VX_ZONE_KERNEL, "Releasing kernel " VX_FMT_REF "\n", (void *)ref); diff --git a/framework/src/vx_khr_import_kernel.cpp b/framework/src/vx_khr_import_kernel.cpp index 26fa19a2..1028497b 100644 --- a/framework/src/vx_khr_import_kernel.cpp +++ b/framework/src/vx_khr_import_kernel.cpp @@ -71,8 +71,9 @@ static inline void copy_dims(const vx_int32 *dims, vx_int32 num_dims, vx_size *d static vx_status VX_CALLBACK vxNNEFInitializer(vx_node node, const vx_reference parameters[], vx_uint32 num) { vx_char perror[MAXLEN] = ""; - vx_status status = VX_SUCCESS; + (void)parameters; + (void)num; // copy NNEF graph to node node->attributes.localDataPtr = nnef_graph_copy(node->kernel->attributes.localDataPtr); @@ -90,8 +91,8 @@ static vx_status VX_CALLBACK vxNNEFInitializer(vx_node node, const vx_reference static vx_status VX_CALLBACK vxNNEFDeinitializer(vx_node node, const vx_reference parameters[], vx_uint32 num) { vx_status status = VX_SUCCESS; - vx_int32 i = 0; - + vx_uint32 i = 0; + (void)parameters; vx_meta_format *meta = node->kernel->signature.meta_formats;; for (i = 0; i < num; i++) @@ -124,8 +125,8 @@ static vx_status VX_CALLBACK vxNNEFKernelDeinitializer(vx_kernel nn_kernel) static vx_status VX_CALLBACK vxNNEFValidator(vx_node node, const vx_reference parameters[], vx_uint32 num, vx_meta_format meta[]) { vx_status status = VX_SUCCESS; - vx_int32 i = 0; - + vx_uint32 i = 0; + (void)node; for (i = 0; i < num; i++) { status = vxSetMetaFormatFromReference(meta[i], parameters[i]); @@ -233,7 +234,7 @@ static vx_kernel CreateNNEFKernel(vx_context context, vx_int32 input_num, vx_int if (kernel) { - vx_uint32 p = 0; + vx_int32 p = 0; for (p = 0; p < num_params; p++) { status = vxAddParameterToKernel(kernel, p, @@ -297,7 +298,7 @@ VX_API_ENTRY vx_kernel VX_API_CALL vxImportKernelFromURL(vx_context context, con { vx_kernel kernel = nullptr; vx_int32 i = 0, j = 0; - + (void)type; vx_char perror[MAXLEN] = ""; vx_char kernel_name[MAXLEN] = ""; static vx_int32 counter = 1; diff --git a/framework/src/vx_node_nn_api.cpp b/framework/src/vx_node_nn_api.cpp index ca217fca..6067d49d 100644 --- a/framework/src/vx_node_nn_api.cpp +++ b/framework/src/vx_node_nn_api.cpp @@ -153,6 +153,7 @@ VX_API_ENTRY vx_node VX_API_CALL vxLocalResponseNormalizationLayer(vx_graph grap vx_float32 bias, vx_tensor outputs) { + (void)bias; vx_context context = vxGetContext((vx_reference)graph); vx_scalar type_scalar = vxCreateScalar(context, VX_TYPE_ENUM, &type); vx_scalar norm_size_scalar = vxCreateScalar(context, VX_TYPE_SIZE, &normalization_size); diff --git a/framework/src/vx_osal.cpp b/framework/src/vx_osal.cpp index 5a95c3e5..99f08b3a 100644 --- a/framework/src/vx_osal.cpp +++ b/framework/src/vx_osal.cpp @@ -209,7 +209,7 @@ vx_bool Osal::waitEventInternal(vx_internal_event_t *e, vx_uint32 ms) gettimeofday(&now, nullptr); time_spec.tv_sec = now.tv_sec + (ms / 1000); time_spec.tv_nsec = (now.tv_usec * 1000) + ((ms%1000) * 1000000); - if (time_spec.tv_nsec > BILLION) { + if (static_cast(time_spec.tv_nsec) > BILLION) { time_spec.tv_sec += 1; time_spec.tv_nsec -= BILLION; } @@ -313,6 +313,8 @@ void Osal::sleepThread(vx_uint32 milliseconds) nanosleep(&rtsp, nullptr); #elif defined(_WIN32) || defined(UNDER_CE) Sleep(milliseconds); +#else + (void)milliseconds; #endif } @@ -320,7 +322,10 @@ vx_thread_t Osal::createThread(vx_thread_f func, void *arg) { vx_thread_t thread = 0; #if defined(__linux__) || defined(__ANDROID__) || defined(__QNX__) || defined(__CYGWIN__) || defined(__APPLE__) - pthread_create(&thread, nullptr, (pthread_f)func, arg); + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-function-type" + pthread_create(&thread, nullptr, reinterpret_cast(func), arg); + #pragma GCC diagnostic pop #elif defined(_WIN32) || defined(UNDER_CE) thread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, arg, CREATE_SUSPENDED, nullptr); if (thread) diff --git a/framework/src/vx_xml_export.cpp b/framework/src/vx_xml_export.cpp index 5a31cac8..cb3f7919 100644 --- a/framework/src/vx_xml_export.cpp +++ b/framework/src/vx_xml_export.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "vx_internal.h" #include "vx_type_pairs.h" @@ -457,7 +458,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_char *ptr = (vx_char *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { /* character array is a string in xsd, not space-separated as lists are */ fprintf(fp, "%c", ptr[j]); } @@ -468,7 +469,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_int8 *ptr = (vx_int8 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%hhd ", ptr[j]); } fprintf(fp, "\n"); @@ -478,7 +479,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_int16 *ptr = (vx_int16 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%hd ", ptr[j]); } fprintf(fp, "\n"); @@ -488,7 +489,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_int32 *ptr = (vx_int32 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%d ", ptr[j]); } fprintf(fp, "\n"); @@ -498,8 +499,8 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_int64 *ptr = (vx_int64 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { - fprintf(fp, "%lld ", ptr[j]); + for (j = 0; j < static_cast(array->num_items); j++) { + fprintf(fp, "%" PRId64 " ", ptr[j]); } fprintf(fp, "\n"); break; @@ -508,7 +509,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_uint8 *ptr = (vx_uint8 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%hhu ", ptr[j]); } fprintf(fp, "\n"); @@ -518,7 +519,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_uint16 *ptr = (vx_uint16 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%hu ", ptr[j]); } fprintf(fp, "\n"); @@ -528,7 +529,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_uint32 *ptr = (vx_uint32 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%u ", ptr[j]); } fprintf(fp, "\n"); @@ -538,8 +539,8 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_uint64 *ptr = (vx_uint64 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { - fprintf(fp, "%llu ", ptr[j]); + for (j = 0; j < static_cast(array->num_items); j++) { + fprintf(fp, "%" PRIu64 " ", ptr[j]); } fprintf(fp, "\n"); break; @@ -548,7 +549,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_float32 *ptr = (vx_float32 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%f ", ptr[j]); } fprintf(fp, "\n"); @@ -558,7 +559,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_float64 *ptr = (vx_float64 *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%lf ", ptr[j]); } fprintf(fp, "\n"); @@ -568,7 +569,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_enum *ptr = (vx_enum *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%d ", ptr[j]); } fprintf(fp, "\n"); @@ -578,7 +579,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_bool *ptr = (vx_bool *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s ", (ptr[j]?"true":"false")); } fprintf(fp, "\n"); @@ -588,7 +589,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_df_image *ptr = (vx_df_image *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s ", vxFourCCString(ptr[j])); } fprintf(fp, "\n"); @@ -598,7 +599,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, { vx_size *ptr = (vx_size *)array->memory.ptrs[0]; fprintf(fp, "%s\t", indent); - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%zu ", ptr[j]); } fprintf(fp, "\n"); @@ -607,7 +608,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, case VX_TYPE_RECTANGLE: { vx_rectangle_t *rect = (vx_rectangle_t *)array->memory.ptrs[0]; - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s\t\n", indent); fprintf(fp, "%s\t\t%u\n", indent, rect[j].start_x); fprintf(fp, "%s\t\t%u\n", indent, rect[j].start_y); @@ -620,7 +621,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, case VX_TYPE_KEYPOINT: { vx_keypoint_t *key = (vx_keypoint_t *)array->memory.ptrs[0]; - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s\t\n", indent); fprintf(fp, "%s\t\t%u\n", indent, key[j].x); fprintf(fp, "%s\t\t%u\n", indent, key[j].y); @@ -636,7 +637,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, case VX_TYPE_COORDINATES2D: { vx_coordinates2d_t *cord2d = (vx_coordinates2d_t *)array->memory.ptrs[0]; - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s\t\n", indent); fprintf(fp, "%s\t\t%u\n", indent, cord2d[j].x); fprintf(fp, "%s\t\t%u\n", indent, cord2d[j].y); @@ -647,7 +648,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, case VX_TYPE_COORDINATES3D: { vx_coordinates3d_t *cord3d = (vx_coordinates3d_t *)array->memory.ptrs[0]; - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s\t\n", indent); fprintf(fp, "%s\t\t%u\n", indent, cord3d[j].x); fprintf(fp, "%s\t\t%u\n", indent, cord3d[j].y); @@ -659,7 +660,7 @@ static vx_status vxExportToXMLArray(FILE* fp, vx_reference refs[], vx_uint32 r, default: if(isUserType) { vx_uint8 *ptr = (vx_uint8 *)array->memory.ptrs[0]; - for (j = 0; j < array->num_items; j++) { + for (j = 0; j < static_cast(array->num_items); j++) { fprintf(fp, "%s\t", indent); for (i = 0; i < array->item_size; i++) { fprintf(fp, "%hhu ", ptr[j*array->item_size+i]); @@ -702,7 +703,7 @@ static vx_status vxExportToXMLLut(FILE* fp, vx_reference refs[], vx_uint32 r, vx if (refs[r]->write_count > 0) { - for (j = 0; j < lut->num_items; j++) + for (j = 0; j < static_cast(lut->num_items); j++) { vx_uint8 *ptr = (vx_uint8 *)lut->memory.ptrs[0]; fprintf(fp, "%s\t%hhu\n", @@ -812,7 +813,7 @@ static vx_status vxExportToXMLDistribution(FILE* fp, vx_reference refs[], vx_uin { vx_status status = VX_SUCCESS; vx_distribution dist = (vx_distribution)refs[r]; - vx_int32 b; + vx_uint32 b; vx_uint32 bins = (vx_uint32)dist->memory.dims[0][VX_DIM_X]; vx_char indent[10] = {0}; vx_uint32 i; @@ -1004,7 +1005,7 @@ static vx_status vxExportToXMLScalar(FILE* fp, vx_reference refs[], vx_uint32 r, fprintf(fp, "%s\t%d\n", indent, scalar->data.s32); break; case VX_TYPE_INT64: - fprintf(fp, "%s\t%lld\n", indent, scalar->data.s64); + fprintf(fp, "%s\t%" PRId64 "\n", indent, scalar->data.s64); break; case VX_TYPE_UINT8: fprintf(fp, "%s\t%hhu\n", indent, scalar->data.u08); @@ -1016,7 +1017,7 @@ static vx_status vxExportToXMLScalar(FILE* fp, vx_reference refs[], vx_uint32 r, fprintf(fp, "%s\t%u\n", indent, scalar->data.u32); break; case VX_TYPE_UINT64: - fprintf(fp, "%s\t%llu\n", indent, scalar->data.u64); + fprintf(fp, "%s\t%" PRIu64 "\n", indent, scalar->data.u64); break; case VX_TYPE_FLOAT32: fprintf(fp, "%s\t%f\n", indent, scalar->data.f32); diff --git a/framework/src/vx_xml_import.cpp b/framework/src/vx_xml_import.cpp index 0f79f7ad..59ce1782 100644 --- a/framework/src/vx_xml_import.cpp +++ b/framework/src/vx_xml_import.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "vx_internal.h" #include "vx_type_pairs.h" @@ -305,7 +306,8 @@ static int32_t xml_match_tag(xmlNodePtr cur, xml_tag_t tags[], size_t num_tags) static vx_status vxReserveReferences(vx_context context, vx_uint32 num) { vx_status status = VX_SUCCESS; - + (void)context; + (void)num; return status; } @@ -314,7 +316,8 @@ static vx_status vxReserveReferences(vx_context context, vx_uint32 num) static vx_status vxReleaseReferences(vx_context context, vx_uint32 num) { vx_status status = VX_SUCCESS; - + (void)context; + (void)num; return status; } @@ -442,7 +445,7 @@ static vx_status vxLoadDataForImage(vx_image image, xmlNodePtr cur, vx_reference if (tag == ROI_TAG) { vxImportFromXMLRoi( image, cur, refs, total); } else if (tag == RECTANGLE_TAG) { - vx_rectangle_t rect = {0}; + vx_rectangle_t rect = {0,0,0,0}; vx_uint32 pIdx = xml_prop_ulong(cur, "plane"); XML_FOREACH_CHILD_TAG (cur, tag, tags) { if (tag == START_X_TAG) { @@ -455,7 +458,7 @@ static vx_status vxLoadDataForImage(vx_image image, xmlNodePtr cur, vx_reference rect.end_y = xml_ulong(cur); } else if (tag == PIXELS_TAG) { void *base = nullptr; - vx_imagepatch_addressing_t addr = {0}; + vx_imagepatch_addressing_t addr = {}; status |= vxAccessImagePatch(image, &rect, pIdx, &addr, &base, VX_WRITE_ONLY); if (status == VX_SUCCESS) { XML_FOREACH_CHILD_TAG(cur, tag, tags) { @@ -628,7 +631,7 @@ static vx_status vxLoadDataForArray(vx_array array, xmlNodePtr cur) status |= vxAddArrayItems(array, strlen(str), str, sizeof(char)); free(str); } else if (tag == KEYPOINT_TAG) { - vx_keypoint_t kp = {0}; + vx_keypoint_t kp = {}; XML_FOREACH_CHILD_TAG(cur, tag, tags) { if (tag == X_TAG) { kp.x = (vx_int32)xml_long(cur); @@ -648,7 +651,7 @@ static vx_status vxLoadDataForArray(vx_array array, xmlNodePtr cur) } status |= vxAddArrayItems(array, 1, &kp, sizeof(vx_keypoint_t)); } else if (tag == COORDINATES2D_TAG) { - vx_coordinates2d_t coord = {0}; + vx_coordinates2d_t coord = {0,0}; XML_FOREACH_CHILD_TAG(cur, tag, tags) { if (tag == X_TAG) { coord.x = (vx_uint32)xml_ulong(cur); @@ -658,7 +661,7 @@ static vx_status vxLoadDataForArray(vx_array array, xmlNodePtr cur) } status |= vxAddArrayItems(array, 1, &coord, sizeof(vx_coordinates2d_t)); } else if (tag == COORDINATES3D_TAG) { - vx_coordinates3d_t coord = {0}; + vx_coordinates3d_t coord = {0,0,0}; XML_FOREACH_CHILD_TAG(cur, tag, tags) { if (tag == X_TAG) { coord.x = (vx_uint32)xml_ulong(cur); @@ -670,7 +673,7 @@ static vx_status vxLoadDataForArray(vx_array array, xmlNodePtr cur) } status |= vxAddArrayItems(array, 1, &coord, sizeof(vx_coordinates3d_t)); } else if (tag == RECTANGLE_TAG) { - vx_rectangle_t rect = {0}; + vx_rectangle_t rect = {0,0,0,0}; XML_FOREACH_CHILD_TAG(cur, tag, tags) { if (tag == START_X_TAG) { rect.start_x = (vx_uint32)xml_ulong(cur); @@ -720,7 +723,7 @@ static vx_status vxLoadDataForArray(vx_array array, xmlNodePtr cur) status |= vxAddArrayItems(array, 1, &v, array->item_size); } else if (tag == UINT64_TAG) { vx_uint64 v; - sscanf(tmp, "%llu", &v); + sscanf(tmp, "%" PRIu64, &v); status |= vxAddArrayItems(array, 1, &v, array->item_size); } else if (tag == INT8_TAG) { vx_int8 v; @@ -736,7 +739,7 @@ static vx_status vxLoadDataForArray(vx_array array, xmlNodePtr cur) status |= vxAddArrayItems(array, 1, &v, array->item_size); } else if (tag == INT64_TAG) { vx_int64 v; - sscanf(tmp, "%lld", &v); + sscanf(tmp, "%" PRId64, &v); status |= vxAddArrayItems(array, 1, &v, array->item_size); } else if (tag == FLOAT32_TAG) { vx_float32 v; @@ -792,7 +795,7 @@ static vx_status vxLoadDataForPyramid(vx_pyramid pyr, xmlNodePtr cur, vx_referen } if (refIdx < total) { - if((level >= 0) && (level < levels)) { + if ((level >= 0) && (level < static_cast(levels))) { if(pyr->levels[level]->width == width && pyr->levels[level]->height == height) { refs[refIdx] = (vx_reference)pyr->levels[level]; @@ -876,7 +879,8 @@ static vx_status vxLoadDataForLut(vx_lut lut, xmlNodePtr cur, vx_enum type, vx_s { vx_status status = VX_SUCCESS; vx_xml_tag_e tag = UNKNOWN_TAG; - + (void)type; + (void)count; if (XML_HAS_CHILD(cur)) { void *ptr = nullptr; if( (status = vxAccessLUT(lut, &ptr, VX_WRITE_ONLY)) == VX_SUCCESS) @@ -1016,7 +1020,7 @@ static vx_status vxLoadDataForScalar(vx_scalar scalar, xmlNodePtr cur) } else if (tag == UINT64_TAG) { vx_uint64 v = 0u; xml_string(cur, value, sizeof(value)); - sscanf(value, "%llu", &v); + sscanf(value, "%" PRIu64, &v); vxCopyScalar(scalar, &v, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST); } else if (tag == INT8_TAG) { vx_int8 v = 0u; @@ -1036,7 +1040,7 @@ static vx_status vxLoadDataForScalar(vx_scalar scalar, xmlNodePtr cur) } else if (tag == INT64_TAG) { vx_int64 v = 0u; xml_string(cur, value, sizeof(value)); - sscanf(value, "%lld", &v); + sscanf(value, "%" PRId64, &v); vxCopyScalar(scalar, &v, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST); } else if (tag == SIZE_TAG) { vx_size v = xml_ulong(cur); @@ -1121,7 +1125,7 @@ static vx_status vxImportFromXMLArray(vx_reference ref, xmlNodePtr cur, vx_refer xml_prop_string(cur, "elemType", typeName, sizeof(typeName)); if(TypePairs::typeFromString(typeName, &type) != VX_SUCCESS) { /* Type was not found, check if it is a user type */ - if(sscanf(typeName, "USER_STRUCT_%d", &userNum) == 1) { + if(sscanf(typeName, "USER_STRUCT_%u", &userNum) == 1) { if(vxStructGetEnum(user_struct_table, userNum, &type) != VX_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; /* INVALID type */ } @@ -1565,7 +1569,7 @@ VX_API_ENTRY vx_import VX_API_CALL vxImportFromXML(vx_context context, xml_prop_string(cur, "elemType", typeName, sizeof(typeName)); if(TypePairs::typeFromString(typeName, &type) != VX_SUCCESS) { /* Type was not found, check if it is a user type */ - if(sscanf(typeName, "USER_STRUCT_%d", &userNum) == 1) { + if(sscanf(typeName, "USER_STRUCT_%u", &userNum) == 1) { if(vxStructGetEnum(user_struct_table, userNum, &type) != VX_SUCCESS) { status = VX_ERROR_INVALID_TYPE; /* INVALID type */ goto exit_error; diff --git a/kernels/NNEF-Tools/parser/cpp/src/nnef.cpp b/kernels/NNEF-Tools/parser/cpp/src/nnef.cpp index 576993e5..c3dd11d4 100644 --- a/kernels/NNEF-Tools/parser/cpp/src/nnef.cpp +++ b/kernels/NNEF-Tools/parser/cpp/src/nnef.cpp @@ -27,46 +27,47 @@ namespace nnef { - + struct ParseCallback : public Parser::Callback { Graph& graph; - + std::istream& qis; const std::string& qfn; Dictionary> quantizations; - + ParseCallback( Graph& graph, std::istream& qis, const std::string& qfn ) : graph(graph), qis(qis), qfn(qfn) { } - + virtual void beginGraph( const Prototype& proto, const Dictionary& fragments ) { graph.name = proto.name(); graph.operations.clear(); graph.tensors.clear(); - + graph.inputs.resize(proto.paramCount()); for ( size_t i = 0; i < proto.paramCount(); ++i ) { graph.inputs[i] = proto.param(i).name(); } - + graph.outputs.resize(proto.resultCount()); for ( size_t i = 0; i < proto.resultCount(); ++i ) { graph.outputs[i] = proto.result(i).name(); } - + if ( qis ) { quantizations = nnef::QuantParser::parse(qis, qfn.c_str(), fragments); } } - + virtual void endGraph( const Prototype& proto, const Dictionary& dtypes ) { + (void)proto; for ( auto& it : dtypes ) { Tensor tensor; @@ -79,17 +80,18 @@ namespace nnef tensor.quantization.push_back(item); } } - + graph.tensors.emplace(it.first, std::move(tensor)); } } - + virtual void operation( const Prototype& proto, const Dictionary& args, const Dictionary& dtypes ) { + (void)dtypes; Operation operation; operation.name = proto.name(); operation.dtype = args.count("?") ? args.at("?").string() : std::string(); - + for ( size_t i = 0; i < proto.paramCount(); ++i ) { auto& param = proto.param(i); @@ -109,31 +111,31 @@ namespace nnef auto& value = args.at(result.name()); operation.outputs.emplace_back(result.name(), value); } - + graph.operations.push_back(std::move(operation)); } }; - + std::string format_error_position( const Error::Position& pos ) { return "'" + std::string(pos.filename) + "' [" + std::to_string(pos.line) + ":" + std::to_string(pos.column) + "]"; } - + bool parse( std::istream& graph_is, const std::string& graph_fn, std::istream& quant_is, const std::string& quant_fn, Graph& graph, std::string& error, const std::string& stdlib, const std::set& lowered ) noexcept { ParseCallback callback(graph, quant_is, quant_fn); CompParser parser(stdlib, lowered); - + try { parser.parse(graph_is, graph_fn.c_str(), callback); return true; } - catch ( nnef::Error e ) + catch ( nnef::Error& e ) { error = "Parse error in file " + format_error_position(e.position()) + " " + e.what(); - + auto origin = e.position().origin; while ( origin ) { @@ -143,7 +145,7 @@ namespace nnef return false; } } - + bool parse_file( const std::string& graph_fn, const std::string& quant_fn, Graph& graph, std::string& error, const std::string& stdlib, const std::set& lowered ) noexcept { @@ -153,7 +155,7 @@ namespace nnef error = "Could not open graph file: " + std::string(graph_fn); return false; } - + std::ifstream quant_is(quant_fn); if ( !quant_fn.empty() ) { @@ -164,10 +166,10 @@ namespace nnef return false; } } - + return parse(graph_is, graph_fn, quant_is, quant_fn, graph, error, stdlib, lowered); } - + bool parse_string( const std::string& graph_str, const std::string& quant_str, Graph& graph, std::string& error, const std::string& stdlib, const std::set& lowered ) noexcept { @@ -184,7 +186,7 @@ namespace nnef { return dtype == "scalar" ? sizeof(float) : dtype == "integer" ? sizeof(int) : dtype == "logical" ? sizeof(bool) : 0; } - + size_t item_bits( const std::string& dtype ) { return dtype == "scalar" ? 32 : dtype == "integer" ? 32 : dtype == "logical" ? 1 : 0; @@ -198,21 +200,21 @@ namespace nnef { header.item_type = TensorHeader::Int; } - + try { validate_tensor_header(header); tensor.shape.assign(header.extents, header.extents + header.rank); } - catch ( nnef::Error e ) + catch ( nnef::Error& e ) { error = "Invalid tensor header: " + std::string(e.what()); return false; } - + std::vector bytes(header.data_length); is.read(bytes.data(), bytes.size()); - + if ( !is ) { error = "Failed to read tensor data"; @@ -220,7 +222,7 @@ namespace nnef } const size_t count = volume_of(tensor.shape); - + if ( header.item_type == TensorHeader::Float ) { tensor.dtype = "scalar"; @@ -251,7 +253,7 @@ namespace nnef error = "Unsupported tensor item-type '" + std::to_string(header.item_type) + "' and bits per item '" + std::to_string(header.bits_per_item) + "'"; return false; } - + return (bool)is; } @@ -262,20 +264,20 @@ namespace nnef error = "Tensor rank " + std::to_string(tensor.shape.size()) + " exceeds maximum allowed rank (" + std::to_string(TensorHeader::MaxRank) + ")"; return false; } - + const bool quantized = !tensor.quantization.empty(); const bool is_signed = (bool)tensor.quantization.get("signed", Value::logical(true)); const TensorHeader::ItemType item_type = quantized ? (is_signed ? TensorHeader::Qint : TensorHeader::Quint) : tensor.dtype == "scalar" ? TensorHeader::Float : tensor.dtype == "integer" ? TensorHeader::Int : TensorHeader::Bool; - + TensorHeader header; const size_t version[] = { 1, 0 }; fill_tensor_header(header, version, tensor.shape.size(), tensor.shape.data(), item_bits(tensor.dtype), item_type); - + const size_t count = volume_of(tensor.shape); std::vector bytes(header.data_length); - + if ( tensor.dtype == "scalar" ) { if ( quantized ) @@ -300,10 +302,10 @@ namespace nnef error = "Invalid tensor data-type: '" + tensor.dtype + "'"; return false; } - + os.write((char*)&header, sizeof(header)); os.write(bytes.data(), bytes.size()); - + if ( !os ) { error = "Failed to write tensor data"; @@ -333,11 +335,11 @@ namespace nnef } return write_tensor(os, tensor, error); } - + bool load_variables( const std::string& path, Graph& graph, std::string& error ) noexcept { const std::string sep = path.back() == '/' || path.back() == '\\' ? "" : "/"; - + for ( auto& op : graph.operations ) { if ( op.name == "variable" ) @@ -346,26 +348,26 @@ namespace nnef auto& shape = op.attribs.get("shape"); auto& id = op.outputs.begin()->second.identifier(); auto& tensor = graph.tensors.at(id); - + const std::string filename = path + sep + label + ".dat"; if ( !read_tensor(filename, tensor, error) ) { return false; } - + if ( tensor.dtype != op.dtype ) { error = "item-type " + tensor.dtype + " in variable file '" + filename + "' does not match data-type " + op.dtype + " defined in network structure"; return false; } - + Value::items_t items(tensor.shape.size()); for ( size_t i = 0; i < items.size(); ++i ) { items[i] = Value::integer(tensor.shape[i]); } Value tensorShape = Value::array(items); - + if ( tensorShape != shape ) { error = "shape " + tensorShape.toString() + " in variable file '" + filename + "' does not match shape " @@ -376,25 +378,25 @@ namespace nnef } return true; } - + bool file_exists( const std::string& path ) { std::ifstream is(path); return is.is_open(); } - + bool load_graph( const std::string& path, Graph& graph, std::string& error, const std::string& stdlib, const std::set& lowered ) noexcept { const std::string sep = path.back() == '/' || path.back() == '\\' ? "" : "/"; const std::string graph_fn = path + sep + "graph.nnef"; const std::string quant_fn = path + sep + "graph.quant"; - + if ( !file_exists(graph_fn) ) { return parse_file(path, "", graph, error, stdlib, lowered); } - + if ( !parse_file(graph_fn, file_exists(quant_fn) ? quant_fn : "", graph, error, stdlib, lowered) ) { return false; @@ -405,48 +407,48 @@ namespace nnef } return true; } - - + + namespace impl { - + template struct index_sequence {}; - + template struct index_sequence_maker : public index_sequence_maker {}; - + template struct index_sequence_maker<0U, Next ... > { using type = index_sequence; }; - + template using make_index_sequence = typename index_sequence_maker::type; - - + + template struct front_count_of { enum { value = 0 }; }; - + template struct front_count_of { enum { value = front_count_of::value + 1 }; }; - - + + const Shape& shape_of( const Graph& graph, const Value& value ) { static const Shape singleton; return value.kind() == Value::Identifier ? graph.tensors.at(value.identifier()).shape : singleton; } - + Shape& shape_ref( Graph& graph, const Value& value ) { return graph.tensors[value.identifier()].shape; } - - + + template ShapeFunc make_shape_func( Shape(*func)(const Args&...), index_sequence, index_sequence ) { @@ -459,24 +461,24 @@ namespace nnef } }; } - + template ShapeFunc make_shape_func( std::vector(*func)(const Shape&,const Args&...), index_sequence ) { return [=]( const Operation& op, Graph& graph ) { const std::vector shapes = func(shape_of(graph, op.inputs.front().second), op.attribs[Idxs].second...); - + const auto& outputs = op.outputs.front().second; check(shapes.size() == outputs.size(), "number of shapes (%d) does not match number of outputs (%d)", (int)shapes.size(), (int)outputs.size()); - + for ( size_t i = 0; i < outputs.size(); ++i ) { shape_ref(graph, outputs[i]) = shapes[i]; } }; } - + template ShapeFunc make_shape_func( Shape(*func)(const std::vector&,const Args&...), index_sequence ) { @@ -488,7 +490,7 @@ namespace nnef { shapes[i] = shape_of(graph, inputs[i]); } - + const Shape shape = func(shapes, op.attribs[Idxs].second...); for ( size_t i = 0; i < op.outputs.size(); ++i ) { @@ -496,41 +498,41 @@ namespace nnef } }; } - + } // namespace impl - - + + template ShapeFunc make_shape_func( Shape(*func)(const Value&,const Args&...) ) { return impl::make_shape_func(func, impl::make_index_sequence<0>(), impl::make_index_sequence()); } - + template::value> ShapeFunc make_shape_func( Shape(*func)(const Shape&,const Args&...) ) { return impl::make_shape_func(func, impl::make_index_sequence(), impl::make_index_sequence()); } - + template ShapeFunc make_shape_func( Shape(*func)(const std::vector&,const Args&...) ) { return impl::make_shape_func(func, impl::make_index_sequence()); } - + template ShapeFunc make_shape_func( std::vector(*func)(const Shape&,const Args&...) ) { return impl::make_shape_func(func, impl::make_index_sequence()); } - - + + static const std::map StandardShapeFuncs = { { "external", make_shape_func(nullary_shape) }, { "constant", make_shape_func(constant_shape) }, { "variable", make_shape_func(nullary_shape) }, - + { "copy", make_shape_func(unary_shape) }, { "neg", make_shape_func(unary_shape) }, { "not", make_shape_func(unary_shape) }, @@ -559,7 +561,7 @@ namespace nnef { "rsqr", make_shape_func(unary_shape) }, { "rsqrt", make_shape_func(unary_shape) }, { "log2", make_shape_func(unary_shape) }, - + { "relu", make_shape_func(unary_shape) }, { "sigmoid", make_shape_func(unary_shape) }, { "elu", make_shape_func(unary_shape) }, @@ -570,12 +572,12 @@ namespace nnef { "softplus", make_shape_func(unary_shape) }, { "leaky_relu", make_shape_func(unary_shape) }, { "prelu", make_shape_func(asymmetric_binary_shape) }, - + { "linear_quantize", make_shape_func(linear_quantize_shape) }, { "logarithmic_quantize", make_shape_func(logarithmic_quantize_shape) }, { "min_max_linear_quantize", make_shape_func(linear_quantize_shape) }, { "zero_point_linear_quantize", make_shape_func(zero_point_linear_quantize_shape) }, - + { "add", make_shape_func(binary_shape) }, { "sub", make_shape_func(binary_shape) }, { "mul", make_shape_func(binary_shape) }, @@ -591,12 +593,12 @@ namespace nnef { "ne", make_shape_func(binary_shape) }, { "and", make_shape_func(binary_shape) }, { "or", make_shape_func(binary_shape) }, - + { "conv", make_shape_func(conv_shape) }, { "deconv", make_shape_func(deconv_shape) }, { "separable_conv", make_shape_func(separable_conv_shape) }, { "separable_deconv", make_shape_func(separable_deconv_shape) }, - + { "box", make_shape_func(pool_shape) }, { "max_pool", make_shape_func(pool_shape) }, { "argmax_pool", make_shape_func(pool_shape) }, @@ -606,7 +608,7 @@ namespace nnef { "debox", make_shape_func(unpool_shape) }, { "sample", make_shape_func(sample_shape) }, { "desample", make_shape_func(desample_shape) }, - + { "sum_reduce", make_shape_func(reduce_shape) }, { "min_reduce", make_shape_func(reduce_shape) }, { "max_reduce", make_shape_func(reduce_shape) }, @@ -616,12 +618,12 @@ namespace nnef { "any_reduce", make_shape_func(reduce_shape) }, { "all_reduce", make_shape_func(reduce_shape) }, { "moments", make_shape_func(reduce_shape) }, - + { "nearest_downsample", make_shape_func(downsample_shape) }, { "area_downsample", make_shape_func(downsample_shape) }, { "nearest_upsample", make_shape_func(upsample_shape) }, { "multilinear_upsample", make_shape_func(upsample_shape) }, - + { "local_response_normalization", make_shape_func(normalize_shape_size) }, { "local_mean_normalization", make_shape_func(normalize_shape_size) }, { "local_variance_normalization", make_shape_func(normalize_shape_size) }, @@ -629,13 +631,13 @@ namespace nnef { "l1_normalization", make_shape_func(normalize_shape_axes) }, { "l2_normalization", make_shape_func(normalize_shape_axes) }, { "batch_normalization", make_shape_func(batchnorm_shape) }, - + { "avg_roi_pool", make_shape_func(roi_shape) }, { "max_roi_pool", make_shape_func(roi_shape) }, { "avg_roi_align", make_shape_func(roi_shape) }, { "max_roi_align", make_shape_func(roi_shape) }, { "roi_resample", make_shape_func(roi_shape_resample) }, - + { "reshape", make_shape_func(reshape_shape) }, { "transpose", make_shape_func(transpose_shape) }, { "split", make_shape_func(split_shape) }, @@ -658,8 +660,8 @@ namespace nnef { "select", make_shape_func(ternary_shape) }, { "clamp", make_shape_func(ternary_shape) }, }; - - + + bool infer_shapes( Graph& graph, std::string& error, const std::map& input_shapes, const std::map& custom_shapes ) noexcept { @@ -676,7 +678,7 @@ namespace nnef } } auto func = it->second; - + if ( op.name == "external" ) { auto& id = op.outputs.get("output").identifier(); @@ -694,12 +696,12 @@ namespace nnef continue; } } - + try { func(op, graph); } - catch ( std::exception e ) + catch ( std::exception& e ) { auto& output = op.outputs.front().second; auto& id = output.kind() == Value::Identifier ? output.identifier() : output[0].identifier(); @@ -710,10 +712,11 @@ namespace nnef } return true; } - - + + bool allocate_buffers( Graph& graph, std::string& error ) noexcept { + (void)error; for ( auto& item : graph.tensors ) { auto& tensor = item.second; @@ -721,7 +724,7 @@ namespace nnef } return true; } - + bool execute( Graph& graph, std::string& error ) noexcept { @@ -739,11 +742,11 @@ namespace nnef } return true; } - catch ( std::runtime_error e ) + catch ( std::runtime_error& e ) { error = "Runtime error: " + std::string(e.what()); return false; } } - + } // namespace nnef diff --git a/kernels/c_model/c_bilateral_filter.cpp b/kernels/c_model/c_bilateral_filter.cpp index e00058fc..837f27a2 100644 --- a/kernels/c_model/c_bilateral_filter.cpp +++ b/kernels/c_model/c_bilateral_filter.cpp @@ -143,7 +143,7 @@ static vx_status bilateralFilter_8u(void* src, vx_size* src_strides, vx_size* di vx_float32 *color_weight = nullptr; vx_float32 *space_weight = nullptr; vx_uint8 cn = num_of_dims == 2 ? 1 : 3; - + (void)dst_strides; vx_float64 gauss_color_coeff = -0.5/(sigma_color*sigma_color); vx_float64 gauss_space_coeff = -0.5/(sigma_space*sigma_space); @@ -158,9 +158,9 @@ static vx_status bilateralFilter_8u(void* src, vx_size* src_strides, vx_size* di if (bordermode->mode == VX_BORDER_UNDEFINED) { low_x = radius; - high_x = (dims[num_of_dims - 2] >= radius) ? dims[num_of_dims - 2] - radius : 0; + high_x = (dims[num_of_dims - 2] >= static_cast(radius)) ? dims[num_of_dims - 2] - radius : 0; low_y = radius; - high_y = (dims[num_of_dims - 1] >= radius) ? dims[num_of_dims - 1] - radius : 0; + high_y = (dims[num_of_dims - 1] >= static_cast(radius)) ? dims[num_of_dims - 1] - radius : 0; } else { @@ -190,11 +190,11 @@ static vx_status bilateralFilter_8u(void* src, vx_size* src_strides, vx_size* di } vx_int32 neighbor_x = x + radius_x; vx_int32 neighbor_y = y + radius_y; - vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > (dims[0] - 1) ? (dims[0] - 1) : neighbor_x); - vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > (dims[1] - 1) ? (dims[1] - 1) : neighbor_y); + vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > static_cast(dims[0] - 1) ? static_cast(dims[0] - 1) : neighbor_x); + vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > static_cast(dims[1] - 1) ? static_cast(dims[1] - 1) : neighbor_y); vx_uint8 neighborVal = 0; neighborVal = *((vx_uint8 *)src + tmpy * src_strides[1] + tmpx * src_strides[0]); - if (neighbor_x < 0 || neighbor_y < 0 || neighbor_x >= dims[0] || neighbor_y >= dims[1]) + if (neighbor_x < 0 || neighbor_y < 0 || neighbor_x >= static_cast(dims[0]) || neighbor_y >= static_cast(dims[1])) { if (border_mode == VX_BORDER_MODE_CONSTANT) { @@ -231,8 +231,8 @@ static vx_status bilateralFilter_8u(void* src, vx_size* src_strides, vx_size* di } vx_int32 neighbor_x = x + radius_x; vx_int32 neighbor_y = y + radius_y; - vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > (dims[1] - 1) ? (dims[1] - 1) : neighbor_x); - vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > (dims[2] - 1) ? (dims[2] - 1) : neighbor_y); + vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > static_cast(dims[1] - 1) ? (dims[1] - 1) : neighbor_x); + vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > static_cast(dims[2] - 1) ? (dims[2] - 1) : neighbor_y); vx_uint8 b = 0, g = 0, r = 0; b = *((vx_uint8 *)src + tmpy * src_strides[2] + tmpx * src_strides[1] + 0 * src_strides[0]); g = *((vx_uint8 *)src + tmpy * src_strides[2] + tmpx * src_strides[1] + 1 * src_strides[0]); @@ -271,7 +271,7 @@ static vx_status bilateralFilter_s16(void* src, vx_size* src_strides, vx_size* d void* dst, vx_size* dst_strides, vx_border_t *bordermode) { vx_status status = VX_FAILURE; - vx_int32 y = 0, x = 0; + vx_size y = 0, x = 0; vx_int32 low_x, low_y, high_x, high_y; vx_int32 radius_y, radius_x; vx_int32 radius = diameter/2; @@ -326,7 +326,7 @@ static vx_status bilateralFilter_s16(void* src, vx_size* src_strides, vx_size* d return VX_ERROR_NO_MEMORY; } scale_index = kExpNumBins / len; - for (vx_uint32 i = 0; i < (kExpNumBins + 2); i++) + for (vx_int32 i = 0; i < (kExpNumBins + 2); i++) { if (lastExpVal > 0.f) { @@ -351,23 +351,23 @@ static vx_status bilateralFilter_s16(void* src, vx_size* src_strides, vx_size* d if (bordermode->mode == VX_BORDER_UNDEFINED) { low_x = radius; - high_x = (dims[num_of_dims - 2] >= radius) ? dims[num_of_dims - 2] - radius : 0; + high_x = (static_cast(dims[num_of_dims - 2]) >= radius) ? static_cast(dims[num_of_dims - 2]) - radius : 0; low_y = radius; - high_y = (dims[num_of_dims - 1] >= radius) ? dims[num_of_dims - 1] - radius : 0; + high_y = (static_cast(dims[num_of_dims - 1]) >= radius) ? static_cast(dims[num_of_dims - 1]) - radius : 0; } else { low_x = 0; - high_x = dims[num_of_dims - 2]; + high_x = static_cast(dims[num_of_dims - 2]); low_y = 0; - high_y = dims[num_of_dims - 1]; + high_y = static_cast(dims[num_of_dims - 1]); } - for (y = low_y; y < high_y; y++) + for (y = low_y; y < static_cast(high_y); y++) { if (num_of_dims == 2) { - for (x = low_x; x < high_x; x++) + for (x = low_x; x < static_cast(high_x); x++) { vx_int16 val0 = *(vx_int16 *)((vx_int8 *)src + y * src_strides[1] + x * src_strides[0]); vx_float32 sum = 0, wsum = 0; @@ -383,8 +383,8 @@ static vx_status bilateralFilter_s16(void* src, vx_size* src_strides, vx_size* d } vx_int32 neighbor_x = x + radius_x; vx_int32 neighbor_y = y + radius_y; - vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > (dims[0] - 1) ? (dims[0] - 1) : neighbor_x); - vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > (dims[1] - 1) ? (dims[1] - 1) : neighbor_y); + vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > static_cast(dims[0] - 1) ? static_cast(dims[0] - 1) : neighbor_x); + vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > static_cast(dims[1] - 1) ? static_cast(dims[1] - 1) : neighbor_y); vx_int16 val = *(vx_int16 *)((vx_int8 *)src + tmpy * src_strides[1] + tmpx * src_strides[0]); if (neighbor_x < 0 || neighbor_y < 0) { @@ -409,7 +409,7 @@ static vx_status bilateralFilter_s16(void* src, vx_size* src_strides, vx_size* d } else if (num_of_dims == 3) { - for (x = low_x; x < high_x; x++) + for (x = low_x; x < static_cast(high_x); x++) { vx_float32 sum_b = 0, sum_g = 0, sum_r = 0, wsum = 0; vx_int16 b0 = *(vx_int16 *)((vx_uint8 *)src + y * src_strides[2] + x * src_strides[1] + 0 * src_strides[0]); @@ -427,8 +427,8 @@ static vx_status bilateralFilter_s16(void* src, vx_size* src_strides, vx_size* d } vx_int32 neighbor_x = x + radius_x; vx_int32 neighbor_y = y + radius_y; - vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > (dims[1] - 1) ? (dims[1] - 1) : neighbor_x); - vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > (dims[2] - 1) ? (dims[2] - 1) : neighbor_y); + vx_int32 tmpx = neighbor_x < 0 ? 0 : (neighbor_x > static_cast(dims[1] - 1) ? static_cast(dims[1] - 1) : neighbor_x); + vx_int32 tmpy = neighbor_y < 0 ? 0 : (neighbor_y > static_cast(dims[2] - 1) ? static_cast(dims[2] - 1) : neighbor_y); vx_int16 b = *(vx_int16 *)((vx_uint8 *)src + tmpy * src_strides[2] + tmpx * src_strides[1] + 0 * src_strides[0]); vx_int16 g = *(vx_int16 *)((vx_uint8 *)src + tmpy * src_strides[2] + tmpx * src_strides[1] + 1 * src_strides[0]); vx_int16 r = *(vx_int16 *)((vx_uint8 *)src + tmpy * src_strides[2] + tmpx * src_strides[1] + 2 * src_strides[0]); diff --git a/kernels/c_model/c_channel.cpp b/kernels/c_model/c_channel.cpp index 5db75caa..11e7c52d 100644 --- a/kernels/c_model/c_channel.cpp +++ b/kernels/c_model/c_channel.cpp @@ -228,8 +228,8 @@ static vx_status vxCopyPlaneToImage(vx_image src, { void *src_base = nullptr; void *dst_base = nullptr; - vx_imagepatch_addressing_t src_addr = {0}; - vx_imagepatch_addressing_t dst_addr = {0}; + vx_imagepatch_addressing_t src_addr = {}; + vx_imagepatch_addressing_t dst_addr = {}; vx_rectangle_t src_rect, dst_rect; vx_uint32 x, y; vx_status status = VX_SUCCESS; diff --git a/kernels/c_model/c_khr_nn.cpp b/kernels/c_model/c_khr_nn.cpp index 5f188a73..d2278234 100644 --- a/kernels/c_model/c_khr_nn.cpp +++ b/kernels/c_model/c_khr_nn.cpp @@ -326,7 +326,7 @@ void FullyConnectedKernelImpl( assert (fmt == TENSOR_C_FMT_Q78 || fmt == TENSOR_C_FMT_U8 || fmt == TENSOR_C_FMT_S8); const size_t batch_dim_num = output.dim_num - 1; - assert (batch_dim_num >= 0 && batch_dim_num <= 3); + assert (/* batch_dim_num >= 0 && */ batch_dim_num <= 3); const size_t core_dim_num = input.dim_num - batch_dim_num; assert ((core_dim_num == 1 && weight.dim_num == 2) || @@ -508,7 +508,7 @@ void PoolingKernelImpl( if (!max_pooling) { //result = conversion_24_8(result / (int16_t)(size_x * size_y)); - result = CLAMP(result / (size_x * size_y), getMinValue(fmt), getMaxValue(fmt)); + result = static_cast(CLAMP(result / static_cast(size_x * size_y), getMinValue(fmt), getMaxValue(fmt))); } const size_t output_byte_offset = @@ -804,10 +804,10 @@ void ROIPoolingKernelImpl( const int dy_after = ((y + 1) * roi_h + (out_h - 1)) / out_h; // clamp in case roi_x or roi_y were unreasonable - const int x_begin = CLAMP(roi_x0 + dx_begin, 0, data_w); - const int y_begin = CLAMP(roi_y0 + dy_begin, 0, data_h); - const int x_after = CLAMP(roi_x0 + dx_after, 0, data_w); - const int y_after = CLAMP(roi_y0 + dy_after, 0, data_h); + const int x_begin = static_cast(CLAMP(roi_x0 + dx_begin, 0, static_cast(data_w))); + const int y_begin = static_cast(CLAMP(roi_y0 + dy_begin, 0, static_cast(data_h))); + const int x_after = static_cast(CLAMP(roi_x0 + dx_after, 0, static_cast(data_w))); + const int y_after = static_cast(CLAMP(roi_y0 + dy_after, 0, static_cast(data_h))); const char * data_b_ptr = (char*)in0_ptr + in0.strides[3] * b + in0.strides[2] * c; diff --git a/kernels/utils/conversion_utils.cpp b/kernels/utils/conversion_utils.cpp index ba65e18f..51ac8f23 100644 --- a/kernels/utils/conversion_utils.cpp +++ b/kernels/utils/conversion_utils.cpp @@ -136,7 +136,7 @@ int16_t conversion_24_8(int32_t acc_value) } else { - out = 0x8000; + out = static_cast(0x8000); } return(out); } diff --git a/targets/c_model/vx_colorconvert.cpp b/targets/c_model/vx_colorconvert.cpp index 38c529e3..64297622 100644 --- a/targets/c_model/vx_colorconvert.cpp +++ b/targets/c_model/vx_colorconvert.cpp @@ -28,9 +28,8 @@ static vx_status VX_CALLBACK vxColorConvertKernel(vx_node node, const vx_reference *parameters, vx_uint32 num) { - (void)node; - - if (num == 2) + if (vx_true_e == Reference::isValidReference(node, VX_TYPE_NODE) && + (2 == num)) { vx_image src = (vx_image)parameters[0]; vx_image dst = (vx_image)parameters[1]; @@ -72,6 +71,7 @@ static vx_status VX_CALLBACK vxColorConvertInputValidator(vx_node node, vx_uint3 break; } /* no break */ + /* fall through */ case VX_DF_IMAGE_YUYV: /* 4:2:2 interleaved */ case VX_DF_IMAGE_UYVY: /* 4:2:2 interleaved */ if (width & 1) diff --git a/targets/c_model/vx_khr_nn.cpp b/targets/c_model/vx_khr_nn.cpp index 3ff6dce0..b91db4cf 100644 --- a/targets/c_model/vx_khr_nn.cpp +++ b/targets/c_model/vx_khr_nn.cpp @@ -2038,8 +2038,8 @@ static vx_status VX_CALLBACK nnDeconvolutionValidator( return VX_ERROR_INVALID_DIMENSION; } - UNLESS (a_x >= 0 && a_x < upscale_x && - a_y >= 0 && a_y < upscale_y) + UNLESS (/* a_x >= 0 && */ a_x < upscale_x && + /* a_y >= 0 && */ a_y < upscale_y) { VX_PRINT(VX_ZONE_ERROR, "Deconvolution layer requires 0 <= a < upscale"); return VX_ERROR_INVALID_DIMENSION; diff --git a/targets/c_model/vx_optpyrlk.cpp b/targets/c_model/vx_optpyrlk.cpp index 7fe94cd6..7fcaced8 100644 --- a/targets/c_model/vx_optpyrlk.cpp +++ b/targets/c_model/vx_optpyrlk.cpp @@ -809,9 +809,6 @@ static vx_status VX_CALLBACK vxOpticalFlowPyrLKOutputValidator(vx_node node, vx_ return status; } -#ifdef __cplusplus -extern "C" -#endif vx_kernel_description_t optpyrlk_kernel = { VX_KERNEL_OPTICAL_FLOW_PYR_LK, diff --git a/targets/c_model/vx_pyramid.cpp b/targets/c_model/vx_pyramid.cpp index 1736fc9e..1dd701c4 100644 --- a/targets/c_model/vx_pyramid.cpp +++ b/targets/c_model/vx_pyramid.cpp @@ -1224,8 +1224,8 @@ static vx_status VX_CALLBACK vxLaplacianReconstructInitializer(vx_node node, con static vx_status VX_CALLBACK vxLaplacianReconstructDeinitializer(vx_node node, const vx_reference parameters[], vx_uint32 num) { vx_status status = VX_ERROR_INVALID_PARAMETERS; + (void)node; (void)parameters; - if (num == dimof(laplacian_reconstruct_kernel_params)) { status = VX_SUCCESS; diff --git a/targets/debug/vx_compare.cpp b/targets/debug/vx_compare.cpp index 28bcbd44..b52a3b9d 100644 --- a/targets/debug/vx_compare.cpp +++ b/targets/debug/vx_compare.cpp @@ -20,6 +20,7 @@ * \author Erik Rainey * \defgroup group_debug_ext Debugging Extension */ +#include #include #include @@ -89,9 +90,8 @@ VX_CALLBACK ownCompareImagesKernel(vx_node node, const vx_reference parameters[] if (VX_SUCCESS == status && vxFindOverlapRectangle(&rect_a, &rect_b, &rect) == vx_true_e) { - const vx_uint32 planeSize = a_planes; - vx_map_id a_map_id[planeSize]; - vx_map_id b_map_id[planeSize]; + std::vector a_map_id(a_planes); + std::vector b_map_id(a_planes); status = VX_SUCCESS; diff --git a/targets/extras/vx_edge_trace.cpp b/targets/extras/vx_edge_trace.cpp index d23c9ad1..7da46d50 100644 --- a/targets/extras/vx_edge_trace.cpp +++ b/targets/extras/vx_edge_trace.cpp @@ -222,9 +222,9 @@ vx_status VX_CALLBACK own_edge_trace_validator( const vx_reference parameters[], vx_uint32 num, vx_meta_format metas[]) { vx_status status = VX_ERROR_INVALID_PARAMETERS; - (void)parameters; if (nullptr != node && + nullptr != parameters && num == dimof(edge_trace_kernel_params) && nullptr != metas) { diff --git a/targets/extras/vx_extras_module.cpp b/targets/extras/vx_extras_module.cpp index 5e5147ce..682e9343 100644 --- a/targets/extras/vx_extras_module.cpp +++ b/targets/extras/vx_extras_module.cpp @@ -36,7 +36,7 @@ static vx_kernel_description_t* kernels[] = &harris_score_kernel, &laplacian3x3_kernel, &image_lister_kernel, - &nonmaxsuppression_kernel, + &extras_nonmaxsuppression_kernel, &norm_kernel, &scharr3x3_kernel, &sobelMxN_kernel, @@ -73,7 +73,7 @@ extern "C" VX_API_ENTRY vx_status VX_API_CALL vxPublishKernels(vx_context contex kernels[k]->validate, kernels[k]->initialize, kernels[k]->deinitialize); - if (kernel) + if (VX_SUCCESS == vxGetStatus((vx_reference)kernel)) { status = VX_SUCCESS; // temporary for (p = 0; p < kernels[k]->numParams; p++) diff --git a/targets/extras/vx_extras_module.h b/targets/extras/vx_extras_module.h index 40283d69..1caca54a 100644 --- a/targets/extras/vx_extras_module.h +++ b/targets/extras/vx_extras_module.h @@ -23,23 +23,14 @@ #ifndef _VX_EXTRAS_MODULE_H_ #define _VX_EXTRAS_MODULE_H_ -#ifdef __cplusplus -extern "C" { -#endif - extern vx_kernel_description_t edge_trace_kernel; extern vx_kernel_description_t euclidean_nonmaxsuppression_harris_kernel; extern vx_kernel_description_t harris_score_kernel; extern vx_kernel_description_t laplacian3x3_kernel; extern vx_kernel_description_t image_lister_kernel; -extern vx_kernel_description_t nonmaxsuppression_kernel; +extern vx_kernel_description_t extras_nonmaxsuppression_kernel; extern vx_kernel_description_t norm_kernel; extern vx_kernel_description_t scharr3x3_kernel; extern vx_kernel_description_t sobelMxN_kernel; -#ifdef __cplusplus -} -#endif - #endif /* _VX_EXTRAS_MODULE_H_ */ - diff --git a/targets/extras/vx_harris_score.cpp b/targets/extras/vx_harris_score.cpp index 7203c402..3b7e8ffb 100644 --- a/targets/extras/vx_harris_score.cpp +++ b/targets/extras/vx_harris_score.cpp @@ -775,6 +775,7 @@ static vx_status VX_CALLBACK own_harris_score_validator( const vx_reference parameters[], vx_uint32 num, vx_meta_format metas[]) { vx_status status = VX_ERROR_INVALID_PARAMETERS; + (void)parameters; if (nullptr != node && num == dimof(harris_score_kernel_params) && nullptr != metas) diff --git a/targets/extras/vx_nonmax.cpp b/targets/extras/vx_nonmax.cpp index 2726df69..ac87e547 100644 --- a/targets/extras/vx_nonmax.cpp +++ b/targets/extras/vx_nonmax.cpp @@ -374,7 +374,7 @@ vx_status VX_CALLBACK own_nonmaxsuppresson_validator( return status; } /* own_nonmaxsuppresson_validator() */ -vx_kernel_description_t nonmaxsuppression_kernel = +vx_kernel_description_t extras_nonmaxsuppression_kernel = { VX_KERNEL_EXTRAS_NONMAXSUPPRESSION_CANNY, "org.khronos.extra.nonmaximasuppression", diff --git a/targets/opencl/vx_absdiff.cpp b/targets/opencl/vx_absdiff.cpp index e5ff4707..31ce6f5b 100644 --- a/targets/opencl/vx_absdiff.cpp +++ b/targets/opencl/vx_absdiff.cpp @@ -29,7 +29,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)parameters; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pidx, pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_bitwise.cpp b/targets/opencl/vx_bitwise.cpp index b9400d34..5f4f224d 100644 --- a/targets/opencl/vx_bitwise.cpp +++ b/targets/opencl/vx_bitwise.cpp @@ -124,7 +124,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)parameters; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pidx, pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_convolution.cpp b/targets/opencl/vx_convolution.cpp index e7b4e83f..d007a582 100644 --- a/targets/opencl/vx_convolution.cpp +++ b/targets/opencl/vx_convolution.cpp @@ -40,7 +40,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)num; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_filter.cpp b/targets/opencl/vx_filter.cpp index aa8745f9..8c5e99db 100644 --- a/targets/opencl/vx_filter.cpp +++ b/targets/opencl/vx_filter.cpp @@ -30,7 +30,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)parameters; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pidx, pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_gradients.cpp b/targets/opencl/vx_gradients.cpp index c54166c3..acb612ba 100644 --- a/targets/opencl/vx_gradients.cpp +++ b/targets/opencl/vx_gradients.cpp @@ -29,7 +29,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)parameters; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pidx, pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_interface.cpp b/targets/opencl/vx_interface.cpp index 5ca6ef9d..40de80f4 100644 --- a/targets/opencl/vx_interface.cpp +++ b/targets/opencl/vx_interface.cpp @@ -64,6 +64,9 @@ static void VX_CALLBACK vxcl_platform_notifier(const char *errinfo, { //vx_target target = (vx_target)user_data; VX_PRINT(VX_ZONE_ERROR, "%s\n", errinfo); + (void)private_info; + (void)cb; + (void)user_data; } extern "C" vx_status vxTargetInit(vx_target target) @@ -443,6 +446,7 @@ extern "C" vx_action vxTargetProcess(vx_target target, vx_node nodes[], vx_size vx_action action = VX_ACTION_CONTINUE; vx_status status = VX_SUCCESS; vx_size n = 0; + (void)target; for (n = startIndex; (n < (startIndex + numNodes)) && (action == VX_ACTION_CONTINUE); n++) { VX_PRINT(VX_ZONE_GRAPH,"Executing Kernel %s:%d in Nodes[%u] on target %s\n", @@ -482,6 +486,8 @@ extern "C" vx_action vxTargetProcess(vx_target target, vx_node nodes[], vx_size extern "C" vx_status vxTargetVerify(vx_target target, vx_node node) { vx_status status = VX_SUCCESS; + (void)target; + (void)node; return status; } @@ -552,7 +558,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { static struct timeval start, start1, end; gettimeofday(&start, nullptr); - + (void)parameters; vx_status status = VX_FAILURE; vx_context context = node->context; __attribute__((unused)) @@ -685,7 +691,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen } } else if (memory->cl_type == CL_MEM_OBJECT_IMAGE2D) { - vx_rectangle_t rect = {0}; + vx_rectangle_t rect = {0,0,0,0}; vx_image image = (vx_image)ref; vxGetValidRegionImage(image, &rect); size_t origin[3] = {rect.start_x, rect.start_y, 0}; @@ -825,7 +831,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen CL_ERROR_MSG(err, "clEnqueueReadBuffer"); } else if (memory->cl_type == CL_MEM_OBJECT_IMAGE2D) { - vx_rectangle_t rect = {0}; + vx_rectangle_t rect = {0,0,0,0}; vx_image image = (vx_image)ref; vxGetValidRegionImage(image, &rect); size_t origin[3] = {rect.start_x, rect.start_y, 0}; diff --git a/targets/opencl/vx_morphology.cpp b/targets/opencl/vx_morphology.cpp index 1304a845..624f175e 100644 --- a/targets/opencl/vx_morphology.cpp +++ b/targets/opencl/vx_morphology.cpp @@ -29,7 +29,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)parameters; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pidx, pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_nonlinearfilter.cpp b/targets/opencl/vx_nonlinearfilter.cpp index cedd6685..54c036c3 100644 --- a/targets/opencl/vx_nonlinearfilter.cpp +++ b/targets/opencl/vx_nonlinearfilter.cpp @@ -26,7 +26,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)num; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pln, didx, plidx, argidx; cl_int err = 0; @@ -127,9 +127,9 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen status |= vxCopyMatrix(mask, m, VX_READ_ONLY, VX_MEMORY_TYPE_HOST); int mask_index = 0; int count_mask = 0; - for (int r = 0; r < mat->rows; ++r) + for (vx_size r = 0; r < mat->rows; ++r) { - for (int c = 0; c < mat->columns; ++c, ++mask_index) + for (vx_size c = 0; c < mat->columns; ++c, ++mask_index) { if (m[mask_index]) ++count_mask; diff --git a/targets/opencl/vx_phase.cpp b/targets/opencl/vx_phase.cpp index e971e034..2c2e14ca 100644 --- a/targets/opencl/vx_phase.cpp +++ b/targets/opencl/vx_phase.cpp @@ -29,7 +29,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)parameters; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pidx, pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/opencl/vx_warp.cpp b/targets/opencl/vx_warp.cpp index 750861a1..02d875e9 100644 --- a/targets/opencl/vx_warp.cpp +++ b/targets/opencl/vx_warp.cpp @@ -29,7 +29,7 @@ static vx_status VX_CALLBACK vxclCallOpenCLKernel(vx_node node, const vx_referen { vx_status status = VX_FAILURE; vx_context context = node->context; - + (void)num; vx_cl_kernel_description_t *vxclk = vxclFindKernel(node->kernel->enumeration); vx_uint32 pln, didx, plidx, argidx; cl_int err = 0; diff --git a/targets/venum/vx_optpyrlk.cpp b/targets/venum/vx_optpyrlk.cpp index caa2d425..7c3db3b9 100644 --- a/targets/venum/vx_optpyrlk.cpp +++ b/targets/venum/vx_optpyrlk.cpp @@ -816,9 +816,6 @@ static vx_status VX_CALLBACK vxOpticalFlowPyrLKOutputValidator(vx_node node, vx_ return status; } -#ifdef __cplusplus -extern "C" -#endif vx_kernel_description_t optpyrlk_kernel = { VX_KERNEL_OPTICAL_FLOW_PYR_LK,