Skip to content

Commit

Permalink
improvement(*): replace flatten with ravel to avoid unnecessary time …
Browse files Browse the repository at this point in the history
…cost of data copy
  • Loading branch information
Joker.Zhou committed Aug 2, 2023
1 parent f7c45d3 commit 89c2ae0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def set_shared_memory_region(cuda_shm_handle, input_values):

offset_current = 0
for input_value in input_values:
input_value = np.ascontiguousarray(input_value).flatten()
input_value = np.ascontiguousarray(input_value).ravel()
# When the input array is in type "BYTES" (np.object_ is
# the numpy equivalent), expect the array has been serialized
# via 'tritonclient.utils.serialize_byte_tensor'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def set_shared_memory_region(shm_handle, input_values, offset=0):

offset_current = offset
for input_value in input_values:
input_value = np.ascontiguousarray(input_value).flatten()
input_value = np.ascontiguousarray(input_value).ravel()
if input_value.dtype == np.object_:
input_value = input_value.item()
byte_size = np.dtype(np.byte).itemsize * len(input_value)
Expand Down

0 comments on commit 89c2ae0

Please sign in to comment.