From 721a8b9bc04e6b2a731d959811918d7c79c6a271 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Thu, 15 Jun 2023 14:57:20 -0700 Subject: [PATCH 1/5] intermediate updates --- src/resources/triton_python_backend_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/resources/triton_python_backend_utils.py b/src/resources/triton_python_backend_utils.py index e2045429..a41fb2bd 100644 --- a/src/resources/triton_python_backend_utils.py +++ b/src/resources/triton_python_backend_utils.py @@ -111,12 +111,16 @@ def deserialize_bytes_tensor(encoded_tensor): strs = list() offset = 0 val_buf = encoded_tensor + print("here") + print(val_buf) while offset < len(val_buf): - l = struct.unpack_from("I", val_buf, offset)[0] + print(l) offset += 4 - sb = struct.unpack_from("<{}s".format(l), val_buf, offset)[0] + sb = struct.unpack_from(">{}s".format(l), val_buf, offset)[0] offset += l strs.append(sb) + print("here2") return (np.array(strs, dtype=np.object_)) From c4757726ec08c96b3c5ba7f1556aec398581ee72 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 23 Jun 2023 07:00:57 -0700 Subject: [PATCH 2/5] remove explicit endianness from serialization (will follow native machine) --- src/resources/triton_python_backend_utils.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/resources/triton_python_backend_utils.py b/src/resources/triton_python_backend_utils.py index a41fb2bd..846ad938 100644 --- a/src/resources/triton_python_backend_utils.py +++ b/src/resources/triton_python_backend_utils.py @@ -85,7 +85,7 @@ def serialize_byte_tensor(input_tensor): s = str(obj.item()).encode('utf-8') else: s = obj.item() - flattened_ls.append(struct.pack("I", val_buf, offset)[0] - print(l) + l = struct.unpack_from("I", val_buf, offset)[0] offset += 4 - sb = struct.unpack_from(">{}s".format(l), val_buf, offset)[0] + sb = struct.unpack_from("{}s".format(l), val_buf, offset)[0] offset += l strs.append(sb) - print("here2") return (np.array(strs, dtype=np.object_)) From 5bcff5855ecb14d03d7c1ca506184845768be692 Mon Sep 17 00:00:00 2001 From: Neelay Shah Date: Wed, 12 Jul 2023 12:41:34 -0700 Subject: [PATCH 3/5] Update src/resources/triton_python_backend_utils.py updating to be explicit in choice to use native format --- src/resources/triton_python_backend_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/triton_python_backend_utils.py b/src/resources/triton_python_backend_utils.py index 846ad938..eac347ae 100644 --- a/src/resources/triton_python_backend_utils.py +++ b/src/resources/triton_python_backend_utils.py @@ -85,7 +85,7 @@ def serialize_byte_tensor(input_tensor): s = str(obj.item()).encode('utf-8') else: s = obj.item() - flattened_ls.append(struct.pack("I", len(s))) + flattened_ls.append(struct.pack("@I", len(s))) flattened_ls.append(s) flattened = b''.join(flattened_ls) return flattened From 7bb17abeb297bfdf4c98d6a91c98d3c1e5a66cd0 Mon Sep 17 00:00:00 2001 From: Neelay Shah Date: Wed, 12 Jul 2023 12:41:55 -0700 Subject: [PATCH 4/5] Update src/resources/triton_python_backend_utils.py updated to be explicit in choice to use native format --- src/resources/triton_python_backend_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/triton_python_backend_utils.py b/src/resources/triton_python_backend_utils.py index eac347ae..25745312 100644 --- a/src/resources/triton_python_backend_utils.py +++ b/src/resources/triton_python_backend_utils.py @@ -112,7 +112,7 @@ def deserialize_bytes_tensor(encoded_tensor): offset = 0 val_buf = encoded_tensor while offset < len(val_buf): - l = struct.unpack_from("I", val_buf, offset)[0] + l = struct.unpack_from("@I", val_buf, offset)[0] offset += 4 sb = struct.unpack_from("{}s".format(l), val_buf, offset)[0] offset += l From 7158473ec6554f0aa62a537244c51299a1d523b5 Mon Sep 17 00:00:00 2001 From: Neelay Shah Date: Wed, 12 Jul 2023 12:43:32 -0700 Subject: [PATCH 5/5] Update src/resources/triton_python_backend_utils.py updated to be explicit in choice to use native byte order --- src/resources/triton_python_backend_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/triton_python_backend_utils.py b/src/resources/triton_python_backend_utils.py index 25745312..53c661d5 100644 --- a/src/resources/triton_python_backend_utils.py +++ b/src/resources/triton_python_backend_utils.py @@ -114,7 +114,7 @@ def deserialize_bytes_tensor(encoded_tensor): while offset < len(val_buf): l = struct.unpack_from("@I", val_buf, offset)[0] offset += 4 - sb = struct.unpack_from("{}s".format(l), val_buf, offset)[0] + sb = struct.unpack_from("@{}s".format(l), val_buf, offset)[0] offset += l strs.append(sb) return (np.array(strs, dtype=np.object_))