Skip to content

Commit fd0f6ba

Browse files
authored
Convert non-contiguous tensors to contiguous tensors (triton-inference-server#61)
1 parent 0869282 commit fd0f6ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/resources/triton_python_backend_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ def __init__(self, name, numpy_array=None, triton_dtype=None):
261261
if triton_dtype is None:
262262
triton_dtype = numpy_to_triton_type(numpy_array.dtype.type)
263263

264+
if not numpy_array.flags['C_CONTIGUOUS']:
265+
numpy_array = np.ascontiguousarray(
266+
numpy_array, dtype=numpy_array.dtype)
267+
264268
self._triton_dtype = triton_dtype
265269
self._name = name
266270
self._numpy_array = numpy_array

0 commit comments

Comments
 (0)