diff --git a/apps/cpp_clml/clml_runner.cc b/apps/cpp_clml/clml_runner.cc index 12aff7cd6d65..d733922da499 100644 --- a/apps/cpp_clml/clml_runner.cc +++ b/apps/cpp_clml/clml_runner.cc @@ -59,12 +59,12 @@ CLMLRunner::CLMLRunner(std::string name, ToolArgs& args, cl_platform_id arg_plat cl_int majorVersions[MAX_VERSIONS]; cl_int minorVersions[MAX_VERSIONS]; cl_uint numVersions = 0; - result = clQueryMLInterfaceVersionsQCOM(NULL, NULL, 0, &numVersions); + result = clQueryMLInterfaceVersionsQCOM(nullptr, nullptr, 0, &numVersions); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); CLML_SDK_TEST_AND_EXIT(numVersions > 0u); CLML_SDK_TEST_AND_EXIT(numVersions <= MAX_VERSIONS); - result = clQueryMLInterfaceVersionsQCOM(majorVersions, minorVersions, numVersions, NULL); + result = clQueryMLInterfaceVersionsQCOM(majorVersions, minorVersions, numVersions, nullptr); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); for (cl_uint i = 0; i < numVersions; ++i) { @@ -74,7 +74,7 @@ CLMLRunner::CLMLRunner(std::string name, ToolArgs& args, cl_platform_id arg_plat break; } } - CLML_SDK_TEST_AND_EXIT(this->h_ClmlIntf != NULL); + CLML_SDK_TEST_AND_EXIT(this->h_ClmlIntf != nullptr); result = h_ClmlIntf->clCreateMLTuningCacheQCOM(&tuning_cache); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); @@ -103,8 +103,8 @@ int CLMLRunner::Run(void) { cl_int result; for (size_t i = 0; i < this->function.size(); ++i) { - result = - h_ClmlIntf->clEnqueueMLOpQCOM(queue, this->function[i], this->descriptorSet, 0, NULL, NULL); + result = h_ClmlIntf->clEnqueueMLOpQCOM(queue, this->function[i], this->descriptorSet, 0, + nullptr, nullptr); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); } if (!r_args.output.empty()) { @@ -155,13 +155,13 @@ void CLMLRunner::PrintMetaInfo(void) { LOG(INFO) << "\n" << this->meta_info; } void CLMLRunner::CopyDataToCLMLTensor(std::shared_ptr tensor, void* data, cl_ml_tensor_layout_qcom layout) { cl_int result = 0; - cl_event evt = NULL; + cl_event evt = nullptr; result = h_ClmlIntf->clEnqueueWriteMLTensorDataQCOM(this->queue, data, layout, tensor->tensor, tensor->memory, - 0, // n waitlist - NULL, // waitlist - &evt); // event - CLML_SDK_TEST_AND_EXIT((evt != NULL) && result == CL_SUCCESS); + 0, // n waitlist + nullptr, // waitlist + &evt); // event + CLML_SDK_TEST_AND_EXIT((evt != nullptr) && result == CL_SUCCESS); } /*! @@ -173,12 +173,12 @@ void CLMLRunner::CopyDataToCLMLTensor(std::shared_ptr tensor, void* data, cl_ml_tensor_layout_qcom layout) { cl_int result = 0; - cl_event readEvent = NULL; + cl_event readEvent = nullptr; // Read the output tensor result = h_ClmlIntf->clEnqueueReadMLTensorDataQCOM(this->queue, tensor->tensor, tensor->memory, data, layout, 0, // n waitlist - NULL, // waitlist + nullptr, // waitlist &readEvent); // event CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); result = clWaitForEvents(1, &readEvent); @@ -194,12 +194,12 @@ cl_int CLMLRunner::AllocateTensorMemory( std::shared_ptr pTensorMemDesc) { uint32_t size = 0; cl_int result = CL_OUT_OF_HOST_MEMORY; - cl_mem buffer = NULL; + cl_mem buffer = nullptr; result = h_ClmlIntf->clGetMLTensorMemorySizeQCOM(context, pTensorMemDesc->tensor, &size); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); - buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, size, NULL, &result); + buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, size, nullptr, &result); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); pTensorMemDesc->memory = buffer; @@ -257,7 +257,7 @@ void CLMLRunner::MakeUnusedTensor(void) { cl_ml_tensor_desc_qcom desc = {}; desc.num_dimensions = CL_TENSOR_UNUSED_QCOM; this->unusedTensor = std::make_shared(); - result = this->h_ClmlIntf->clCreateMLTensorQCOM(this->context, NULL, &desc, + result = this->h_ClmlIntf->clCreateMLTensorQCOM(this->context, nullptr, &desc, &(this->unusedTensor->tensor)); CLML_SDK_TEST_AND_EXIT(this->unusedTensor && result == CL_SUCCESS); } @@ -321,7 +321,8 @@ std::shared_ptr CLMLRunner::MakeCLMLTensor( auto tensor_dsc = std::make_shared(); cl_ml_tensor_desc_qcom desc = { cl_dtype, layout, dims.n, dims.c, dims.h, dims.w, 0, CL_TENSOR_DIMENSIONS_4D_QCOM, {0}}; - result = this->h_ClmlIntf->clCreateMLTensorQCOM(this->context, NULL, &desc, &tensor_dsc->tensor); + result = + this->h_ClmlIntf->clCreateMLTensorQCOM(this->context, nullptr, &desc, &tensor_dsc->tensor); CLML_SDK_TEST_AND_EXIT(tensor_dsc->tensor && result == CL_SUCCESS); return tensor_dsc; } @@ -372,7 +373,7 @@ void CLMLRunner::MakeConv2D(std::shared_ptr input {clml_dilation[0], clml_dilation[1]}, 0, cl_arithmetic_mode}; - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; if (!has_act) { result = h_ClmlIntf->clCreateMLOpConvolutionForwardQCOM( this->context, 0, &conv_desc, input_desc->tensor, weight_desc->tensor, bias_desc->tensor, @@ -381,7 +382,7 @@ void CLMLRunner::MakeConv2D(std::shared_ptr input } else { result = h_ClmlIntf->clCreateMLOpFusedConvolutionActivationForwardQCOM( this->context, 0, &conv_desc, &act_desc, input_desc->tensor, weight_desc->tensor, - bias_desc->tensor, NULL, output_desc->tensor, &op, tuning_cache); + bias_desc->tensor, nullptr, output_desc->tensor, &op, tuning_cache); CLML_SDK_TEST_AND_EXIT(op && result == CL_SUCCESS); } this->function.push_back(op); @@ -443,7 +444,7 @@ void CLMLRunner::MakeConv2DWithBN(std::shared_ptr {clml_dilation[0], clml_dilation[1]}, 0, cl_arithmetic_mode}; - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_ml_op_batchnorm_desc_qcom bn_desc = {CL_BATCHNORM_MODE_SPATIAL_QCOM, cl_arithmetic_mode}; if (!has_act) { result = h_ClmlIntf->clCreateMLOpFusedConvolutionBatchNormForwardQCOM( @@ -454,7 +455,7 @@ void CLMLRunner::MakeConv2DWithBN(std::shared_ptr } else { result = h_ClmlIntf->clCreateMLOpFusedConvolutionBatchNormActivationForwardQCOM( this->context, 0, &conv_desc, &bn_desc, &act_desc, input_desc->tensor, weight_desc->tensor, - bias_desc->tensor, output_desc->tensor, NULL, bn_mean->tensor, bn_var->tensor, + bias_desc->tensor, output_desc->tensor, nullptr, bn_mean->tensor, bn_var->tensor, bn_scale->tensor, bn_bias->tensor, &op, tuning_cache); CLML_SDK_TEST_AND_EXIT(op && result == CL_SUCCESS); } @@ -472,7 +473,7 @@ void CLMLRunner::MakeRelu(std::shared_ptr input_d std::shared_ptr output_desc, cl_activation_function_qcom relu_type, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_activation_desc_qcom act_desc = {relu_type, CL_PROPAGATE_NAN_QCOM, cl_arithmetic_mode}; @@ -502,7 +503,7 @@ void CLMLRunner::MakeBatchNorm(std::shared_ptr in std::shared_ptr bn_var, std::vector bn_attrs, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_batchnorm_desc_qcom bn_desc = {CL_BATCHNORM_MODE_SPATIAL_QCOM, cl_arithmetic_mode}; @@ -531,7 +532,7 @@ void CLMLRunner::MakePool2D(std::shared_ptr input std::vector padding, std::string pool_type, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_pooling_desc_qcom pool_desc = { @@ -567,7 +568,7 @@ void CLMLRunner::MakeGlobalPool2D(std::shared_ptr std::vector in_shape, std::string pool_type, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_pooling_desc_qcom pool_desc = { pool_type == "nn.global_max_pool2d" ? CL_POOLING_MODE_MAX_QCOM @@ -599,7 +600,7 @@ void CLMLRunner::MakeReshape(std::shared_ptr inpu std::shared_ptr output_desc, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; result = h_ClmlIntf->clCreateMLOpReshapeQCOM(this->context, 0, input_desc->tensor, @@ -620,7 +621,7 @@ void CLMLRunner::MakeConcatenate( std::vector> in_list, std::shared_ptr output_desc, int axis, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_tensor_qcom* concatInputs = new cl_ml_tensor_qcom[in_list.size()]; @@ -650,7 +651,7 @@ void CLMLRunner::MakeDense(std::shared_ptr input_ std::shared_ptr bias_desc, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_convolution_desc_qcom conv_desc = {CL_CONVOLUTION_MODE_CONVOLUTION_QCOM, @@ -681,7 +682,7 @@ void CLMLRunner::MakeSoftMax(std::shared_ptr inpu std::shared_ptr output_desc, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_softmax_desc_qcom softmax_desc = {CL_SOFTMAX_ALGORITHM_ACCURATE_QCOM, @@ -706,7 +707,7 @@ void CLMLRunner::MakePad(std::shared_ptr input_de std::shared_ptr output_desc, std::string pad_mode, std::vector padding, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_pad_mode_qcom clml_pad_mode = CL_PAD_MODE_CONSTANT_QCOM; @@ -741,7 +742,7 @@ void CLMLRunner::MakeBatchFlatten(std::shared_ptr std::shared_ptr output_desc, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; result = h_ClmlIntf->clCreateMLOpReshapeQCOM(this->context, 0, input_desc->tensor, @@ -763,7 +764,7 @@ void CLMLRunner::MakeClip(std::shared_ptr input_d float a_min, std::string dtype) { LOG(INFO) << "MakeClip called"; cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_ml_op_clip_desc_qcom clip_desc = { @@ -788,7 +789,7 @@ void CLMLRunner::MakeBinaryOp(std::shared_ptr inp std::shared_ptr output_desc, std::string op_name, std::string dtype) { cl_arithmetic_mode_qcom cl_arithmetic_mode = MakeCLArithMode(MakeCLDataType(dtype)); - cl_ml_op_qcom op = NULL; + cl_ml_op_qcom op = nullptr; cl_int result; cl_binary_op_qcom binary_op = CL_TENSOR_OP_ADD_QCOM; diff --git a/apps/cpp_clml/clml_runner.h b/apps/cpp_clml/clml_runner.h index 7ddd73001887..4e73674d72ae 100644 --- a/apps/cpp_clml/clml_runner.h +++ b/apps/cpp_clml/clml_runner.h @@ -229,20 +229,20 @@ class CLMLRunner { /*! \brief ML API interface */ GET_ML_API_INTERFACE* h_ClmlIntf = nullptr; /*! \brief Tuning cache object */ - cl_ml_tuningcache_qcom tuning_cache = NULL; + cl_ml_tuningcache_qcom tuning_cache = nullptr; /*! \brief Flag to inticate a tuning run */ bool is_tuning_run; /*! \brief The tuning file for loading or storing cache */ char* tuning_file; /*! \brief OpenCL platform */ - cl_platform_id platform{NULL}; + cl_platform_id platform{nullptr}; /*! \brief OpenCL context */ - cl_context context{NULL}; + cl_context context{nullptr}; /*! \brief OpenCL device */ - cl_device_id device_id{NULL}; + cl_device_id device_id{nullptr}; /*! \brief OpenCL Queue */ - cl_command_queue queue{NULL}; + cl_command_queue queue{nullptr}; /*! \brief Numpy object for params */ cnpy::npz_t npz_params; /*! \brief Numpy object for inputs */ diff --git a/apps/cpp_clml/main.cc b/apps/cpp_clml/main.cc index 5e000374346f..b918618a1772 100644 --- a/apps/cpp_clml/main.cc +++ b/apps/cpp_clml/main.cc @@ -148,11 +148,11 @@ void ParseCmdArgs(int argc, char* argv[], struct ToolArgs& args) { bool ExtensionStringPresent(cl_platform_id platform_id, cl_device_id device_id) { cl_int result = 0; size_t reqd_size = 0; - result = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, 0, NULL, &reqd_size); + result = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, 0, nullptr, &reqd_size); CLML_SDK_TEST_AND_EXIT(reqd_size > 0u && result == CL_SUCCESS); std::vector buf(reqd_size); - result = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, reqd_size, buf.data(), NULL); + result = clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, reqd_size, buf.data(), nullptr); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); std::string extensions(buf.data()); @@ -174,25 +174,25 @@ int ExecuteModel(ToolArgs& args) { // Init OpenCL Environment cl_int result; cl_event readEvent = nullptr; - cl_platform_id platform = NULL; - cl_context context = NULL; - cl_device_id device_id = NULL; - cl_command_queue queue = NULL; + cl_platform_id platform = nullptr; + cl_context context = nullptr; + cl_device_id device_id = nullptr; + cl_command_queue queue = nullptr; // Initialize Context and Command Queue - result = clGetPlatformIDs(1, &platform, NULL); + result = clGetPlatformIDs(1, &platform, nullptr); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); uint32_t num_devices = 0; - result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); + result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &num_devices); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS && num_devices == 1); - result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL); + result = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device_id, nullptr); CLML_SDK_TEST_AND_EXIT(device_id && result == CL_SUCCESS); CLML_SDK_TEST_AND_EXIT(ExtensionStringPresent(platform, device_id) == true); - context = clCreateContext(0, 1, &device_id, NULL, NULL, &result); + context = clCreateContext(0, 1, &device_id, nullptr, nullptr, &result); CLML_SDK_TEST_AND_EXIT(result == CL_SUCCESS); cl_command_queue_properties queue_props = 0;