pub fn pad<'a>(
a: impl AsRef<Array>,
width: impl Into<PadWidth<'a>>,
value: impl Into<Option<Array>>,
mode: impl Into<Option<PadMode>>,
) -> Result<Array>
Expand description
Pad an array with a constant value. Returns an error if the width is invalid.
§Params
a
: The input array.width
: Number of padded values to add to the edges of each axis:((before_1, after_1), (before_2, after_2), ..., (before_N, after_N))
. If a single pair of integers is passed then(before_i, after_i)
are all the same. If a single integer or tuple with a single integer is passed then all axes are extended by the same number on each side.value
: The value to pad the array with. Default is0
if not provided.mode
: The padding mode. Default isPadMode::Constant
if not provided.
§Example
use mlx_rs::{Array, ops::*};
let a = Array::from_iter(0..4, &[2, 2]);
let result = pad(&a, 1, Array::from_int(0), None);