Closed
Description
Description
https://github.com/arrayfire/arrayfire/blob/c7f16cca120f722014458696e50aa292cb803e76/test/pad_borders.cpp#L147-L159 tells me I should be able to pad a corner.
arrayfire-rust uses af_pad
wrapper around the function being tested in that code. That wrapper checks for nonzero number of dimensions (https://github.com/arrayfire/arrayfire/blob/1405a9448f79ca56cc875f57db36cc6c33806272/src/api/c/data.cpp#L431-L432).
The problem is if begin/end padding is &[0, 0, 0, 0]
, this line
arrayfire-rust/src/core/data.rs
Line 951 in 39ab7a5
af_pad
that there are 0 dimensions (begin.ndims()
calls begin.elements()
which multiplies all 4 values and ends up being 0).
ArrayFire v3.7.2 (CPU, 64-bit Linux, build default)
[0] AMD: AMD Ryzen 7 2700X Eight-Core Processor
[3 3 1 1]
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
thread 'main' panicked at 'Error message: Size is incorrect
Last error: In function af_err af_pad(void**, af_array, unsigned int, const dim_t*, unsigned int, const dim_t*, af_border_type)
In file src/api/c/data.cpp:431
Invalid dimension for argument 2
Expected: begin_ndims > 0 && begin_ndims <= 4
Reproducible Code and/or Steps
let a = constant::<f32>(1.0, Dim4::new(&[3, 3, 1, 1]));
print(&a);
let begin_dims = Dim4::new(&[0, 0, 0, 0]);
let end_dims = Dim4::new(&[2, 2, 0, 0]);
let padded = pad(&a, begin_dims, end_dims, BorderType::ZERO);
print(&padded);
System Information
Checklist
- Using the latest available ArrayFire release
- GPU drivers are up to date