Repository: arrayfire/arrayfire-rust (language: rust)

Issue:
zero padding not working in convolve2_nn [BUG]
Description
===========

* Details regarding the bug
    * Zero Padding not allowed by Convolve2_nn
* Did you build ArrayFire yourself or did you use the official installers
    * Official Installers 
* Which backend is experiencing this issue? (CPU, CUDA, OpenCL)
    * all of them
* Do you have a workaround?
    * No 
* Can the bug be reproduced reliably on your system?
    * Yes
* A clear and concise description of what you expected to happen.
    * My understanding was this was resolved in https://github.com/arrayfire/arrayfire/pull/2820
* Run your executable with AF_TRACE=all and AF_PRINT_ERRORS=1 environment
  variables set.
* Screenshot or terminal output of the results from above run

![screenshot of failure](https://user-images.githubusercontent.com/7086165/153902236-fb7125fc-3eb8-454a-b074-d0753335a9d6.png)

Reproducible Code and/or Steps
------------------------------
```
#[test]
    fn mnist__convolutional_neural_net__learns_mnist_fail() {
        let signal = randu::<f32>(dim4!(8, 8, 3, 1));

        let quadrant1 = Array::new(&vec![1f32, 0.0, 0.0, 0.0], dim4![2, 2, 1, 1]);

        let q1 = convolve2_nn(
            &signal,
            &quadrant1,
            dim4!(2, 2, 1, 1),
            dim4!(0, 0, 1, 1),
            dim4!(1, 1, 1, 1),
        );

        af_print!("q1", q1);
    }
```

System Information
------------------

Please provide the following information:
1. ArrayFire version
   *  3.8
2. Devices installed on the system
    *. RTX 3090, R9 5950X 
3. (optional) Output from the af::info() function if applicable.

ArrayFire v3.8.1 (CUDA, 64-bit Linux, build default)
Platform: CUDA Runtime 11.5, Driver: 510.47.03
[0] NVIDIA GeForce RTX 3090, 24252 MB, CUDA Compute 8.6
test tests::info____ ... ok

4. Output from the following scripts:

LSB Version:    n/a
Distributor ID: ManjaroLinux
Description:    Manjaro Linux
Release:        21.2.3
Codename:       Qonos

name, memory.total [MiB], driver_version
NVIDIA GeForce RTX 3090, 24576 MiB, 510.47.03

Checklist
---------

- [Y] Using the latest available ArrayFire release
- [Y] GPU drivers are up to date



Discussion / hints:
For devs reference, issue is on this line:
https://github.com/arrayfire/arrayfire-rust/blob/f53bf4cb0faa33d6d4d5ee984eb9cb74a8fd1f27/src/ml/mod.rs#L81 
and the corresponding line for the gradient function as well. 
ndims() will return 0 for 0 padding when it should pass a "2" (or matching signal.ndims() ) instead

Fix patch:
diff --git a/README.md b/README.md
index 02320d4bc..178189c43 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 [![ci][19]][16] [![docs][18]][3] [![book][22]][21] [![slack][17]][4] [![github-discussions][20]][5]
 
-# Arrayfire Rust Bindings
+# ArrayFire Rust Bindings
 
 [ArrayFire][1] is a high performance library for parallel computing with an easy-to-use API. It
 enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU
diff --git a/src/ml/mod.rs b/src/ml/mod.rs
index 1080a4768..e448e023f 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(),
-            strides.ndims() as c_uint,
+            4,
             strides.get().as_ptr() as *const dim_t,
-            padding.ndims() as c_uint,
+            4,
             padding.get().as_ptr() as *const dim_t,
-            dilation.ndims() as c_uint,
+            4,
             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(),
-            strides.ndims() as c_uint,
+            4,
             strides.get().as_ptr() as *const dim_t,
-            padding.ndims() as c_uint,
+            4,
             padding.get().as_ptr() as *const dim_t,
-            dilation.ndims() as c_uint,
+            4,
             dilation.get().as_ptr() as *const dim_t,
             grad_type as c_uint,
         );


Test patch: