mlx.core.pad

目录

mlx.core.pad#

pad(a: array, pad_width: int | tuple[int] | tuple[int, int] | list[tuple[int, int]], mode: Literal['constant', 'edge'] = 'constant', constant_values: scalar | array = 0, *, stream: None | Stream | Device = None) array#

用常数值填充数组

参数:
  • a (array) – 输入数组。

  • pad_width (int, tuple(int), tuple(int, int) 或 list(tuple(int, int))) – 要添加到每个轴边缘的填充值数量:((before_1, after_1), (before_2, after_2), ..., (before_N, after_N))。如果传递一个整数对,则所有 (before_i, after_i) 都相同。如果传递一个单个整数或包含单个整数的元组,则所有轴的每一侧都扩展相同的数量。

  • mode – 填充模式。以下字符串之一:“constant”(默认):使用常数值填充。“edge”:使用数组边缘值填充。

  • constant_value (arrayscalar, 可选) – 用于填充数组边缘的可选常数值。

返回:

填充后的数组。

返回类型:

array