mlx icon indicating copy to clipboard operation
mlx copied to clipboard

[Feature Request] Add Symmetric and Reflect padding modes to mx.pad

Open kyrollosyanny opened this issue 7 months ago • 1 comments

Describe the feature mlx.pad currently only has two modes edge and constant, it would be great to add other modes like symmetric and reflect

Expected behavior Something similar to PyTorch or tensor flow padding options:

t = tf.constant([[1, 2, 3], [4, 5, 6]])
paddings = tf.constant([[1, 1,], [2, 2]])

tf.pad(t, paddings, "CONSTANT")  # [[0, 0, 0, 0, 0, 0, 0],
                                 #  [0, 0, 1, 2, 3, 0, 0],
                                 #  [0, 0, 4, 5, 6, 0, 0],
                                 #  [0, 0, 0, 0, 0, 0, 0]]

tf.pad(t, paddings, "REFLECT")  # [[6, 5, 4, 5, 6, 5, 4],
                                #  [3, 2, 1, 2, 3, 2, 1],
                                #  [6, 5, 4, 5, 6, 5, 4],
                                #  [3, 2, 1, 2, 3, 2, 1]]

tf.pad(t, paddings, "SYMMETRIC")  # [[2, 1, 1, 2, 3, 3, 2],
                                  #  [2, 1, 1, 2, 3, 3, 2],
                                  #  [5, 4, 4, 5, 6, 6, 5],
                                  #  [5, 4, 4, 5, 6, 6, 5]]

kyrollosyanny avatar May 06 '25 20:05 kyrollosyanny

I can take this issue

ParamThakkar123 avatar May 07 '25 02:05 ParamThakkar123