replace itemset due to numpy version 2.0 removed itemset api#2879
Merged
lanluo-nvidia merged 8 commits intomainfrom Jun 3, 2024
Merged
replace itemset due to numpy version 2.0 removed itemset api#2879lanluo-nvidia merged 8 commits intomainfrom
lanluo-nvidia merged 8 commits intomainfrom
Conversation
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 14:05:15.070622+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 14:07:09.016476+00:00
@@ -92,11 +92,11 @@
if include_last_offset:
# modify the last index of offsets to the end index
# however, pytorch doc says if `include_last_offset` is True, the size of offsets
# is equal to the number of bags + 1. The last element is the size of the input,
# or the ending index position of the last bag (sequence).
- offsets_shape=offsets.shape
+ offsets_shape = offsets.shape
offsets = offsets.flatten()
offsets[-1] = len_embed
offsets.reshape(offsets_shape)
else:
# add the end index to offsetsThere was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 14:06:12.995886+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 14:08:07.030401+00:00
@@ -92,11 +92,11 @@
if include_last_offset:
# modify the last index of offsets to the end index
# however, pytorch doc says if `include_last_offset` is True, the size of offsets
# is equal to the number of bags + 1. The last element is the size of the input,
# or the ending index position of the last bag (sequence).
- offsets_shape=offsets.shape
+ offsets_shape = offsets.shape
offsets = offsets.flatten()
offsets[-1] = len_embed
offsets.reshape(offsets_shape)
else:
# add the end index to offsets
zewenli98
reviewed
Jun 3, 2024
… lluo/numpy_version
… lluo/numpy_version
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 20:24:01.501127+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 20:26:07.774711+00:00
@@ -92,16 +92,16 @@
if include_last_offset:
# modify the last index of offsets to the end index
# however, pytorch doc says if `include_last_offset` is True, the size of offsets
# is equal to the number of bags + 1. The last element is the size of the input,
# or the ending index position of the last bag (sequence).
-
+
# Notes: here offsets should always be 1d array
if len(offsets.shape) != 1:
raise TypeError(
- f"The offsets should be in 1d array, here offset shape is {offsets.shape}."
- )
+ f"The offsets should be in 1d array, here offset shape is {offsets.shape}."
+ )
offsets[-1] = len_embed
else:
# add the end index to offsets
offsets = np.append(offsets, len_embed)
zewenli98
approved these changes
Jun 3, 2024
Collaborator
zewenli98
left a comment
There was a problem hiding this comment.
The modification LGTM. Pending on CI
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 20:28:25.162585+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 20:30:20.926499+00:00
@@ -96,12 +96,12 @@
# or the ending index position of the last bag (sequence).
# Notes: here offsets should always be 1d array
if len(offsets.shape) != 1:
raise TypeError(
- f"The offsets should be in 1d array, here offset shape is {offsets.shape}."
- )
+ f"The offsets should be in 1d array, here offset shape is {offsets.shape}."
+ )
offsets[-1] = len_embed
else:
# add the end index to offsets
offsets = np.append(offsets, len_embed)
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 20:39:56.624958+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/embedding.py 2024-06-03 20:41:50.763279+00:00
@@ -97,11 +97,11 @@
# Notes: here offsets should always be 1d array
if len(offsets.shape) != 1:
raise TypeError(
f"The offsets should be in 1d array, here offset shape is {offsets.shape}."
- )
+ )
offsets[-1] = len_embed
else:
# add the end index to offsets
offsets = np.append(offsets, len_embed)
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Numpy has removed itemset api since 2.0, so need to replace the itemset call
Fixes # (issue)
E AttributeError:
itemsetwas removed from the ndarray class in NumPy 2.0. Usearr[index] = valueinstead.Collecting numpy (from torchvision==0.18.0->-r /__w/TensorRT/TensorRT/pytorch/tensorrt/tests/py/requirements.txt (line 8))
398
Downloading numpy-2.0.0rc2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.3 MB)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: