reduce overhead in pad when an integer pad_width is provided
+import numbers
+
import numpy
import cupy
@@ -585,6 +587,9 @@ def pad(array, pad_width, mode='constant', **kwargs):
[100, 100, 100, 100, 100, 100, 100],
[100, 100, 100, 100, 100, 100, 100]])
"""
+ if isinstance(pad_width, numbers.Integral):
+ pad_width = ((pad_width, pad_width),) * array.ndim
+ else:
pad_width = numpy.asarray(pad_width)
if not pad_width.dtype.kind == 'i':
