From f811c710c6a8971797e9e03e0e9e5cd294701e10 Mon Sep 17 00:00:00 2001 From: Aitor Ruano <45633475+c0dearm@users.noreply.github.com> Date: Thu, 23 Jun 2022 14:46:20 +0200 Subject: [PATCH 1/2] Set correct number of dimensions for convolve2_nn and convolve2_gradient_nn Fixes issue https://github.com/arrayfire/arrayfire-rust/issues/323 --- src/ml/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ml/mod.rs b/src/ml/mod.rs index e448e023..baa2688a 100644 --- a/src/ml/mod.rs +++ b/src/ml/mod.rs @@ -76,11 +76,11 @@ where &mut temp as *mut af_array, signal.get(), filter.get(), - 4, + 2, strides.get().as_ptr() as *const dim_t, - 4, + 2, padding.get().as_ptr() as *const dim_t, - 4, + 2, dilation.get().as_ptr() as *const dim_t, ); HANDLE_ERROR(AfError::from(err_val)); @@ -126,11 +126,11 @@ where original_signal.get(), original_filter.get(), convolved_output.get(), - 4, + 2, strides.get().as_ptr() as *const dim_t, - 4, + 2, padding.get().as_ptr() as *const dim_t, - 4, + 2, dilation.get().as_ptr() as *const dim_t, grad_type as c_uint, ); From bfe72c3133921347f63bba6c8a912c410bc5c686 Mon Sep 17 00:00:00 2001 From: Aitor Ruano Date: Thu, 23 Jun 2022 15:18:45 +0200 Subject: [PATCH 2/2] fix clippy lints --- build.rs | 2 +- opencl-interop/src/lib.rs | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/build.rs b/build.rs index c1fca518..43f41849 100644 --- a/build.rs +++ b/build.rs @@ -281,7 +281,7 @@ fn run_cmake_command(conf: &Config, build_dir: &std::path::Path) { run( make_cmd .arg(format!("-j{}", conf.build_threads)) - .arg("install".to_string()), + .arg("install"), "make", ); } diff --git a/opencl-interop/src/lib.rs b/opencl-interop/src/lib.rs index b8676f09..d841a348 100644 --- a/opencl-interop/src/lib.rs +++ b/opencl-interop/src/lib.rs @@ -88,35 +88,27 @@ pub fn get_device_id() -> cl_device_id { } /// Set the cl_device_id as the active ArrayFire OpenCL device -pub fn set_device_id(dev_id: cl_device_id) { - unsafe { - let err_val = afcl_set_device_id(dev_id); - handle_error_general(AfError::from(err_val)); - } +pub unsafe fn set_device_id(dev_id: cl_device_id) { + let err_val = afcl_set_device_id(dev_id); + handle_error_general(AfError::from(err_val)); } /// Push user provided device, context and queue tuple to ArrayFire device mamanger -pub fn add_device_context(dev_id: cl_device_id, ctx: cl_context, queue: cl_command_queue) { - unsafe { - let err_val = afcl_add_device_context(dev_id, ctx, queue); - handle_error_general(AfError::from(err_val)); - } +pub unsafe fn add_device_context(dev_id: cl_device_id, ctx: cl_context, queue: cl_command_queue) { + let err_val = afcl_add_device_context(dev_id, ctx, queue); + handle_error_general(AfError::from(err_val)); } /// Set the device identified by device & context pair as the active device for ArrayFire -pub fn set_device_context(dev_id: cl_device_id, ctx: cl_context) { - unsafe { - let err_val = afcl_set_device_context(dev_id, ctx); - handle_error_general(AfError::from(err_val)); - } +pub unsafe fn set_device_context(dev_id: cl_device_id, ctx: cl_context) { + let err_val = afcl_set_device_context(dev_id, ctx); + handle_error_general(AfError::from(err_val)); } /// Remove the user provided device, context pair from ArrayFire device mamanger -pub fn delete_device_context(dev_id: cl_device_id, ctx: cl_context) { - unsafe { - let err_val = afcl_delete_device_context(dev_id, ctx); - handle_error_general(AfError::from(err_val)); - } +pub unsafe fn delete_device_context(dev_id: cl_device_id, ctx: cl_context) { + let err_val = afcl_delete_device_context(dev_id, ctx); + handle_error_general(AfError::from(err_val)); } ///// Fetch Active ArrayFire device's type i.e. CPU/GPU/Accelerator etc.