-
Notifications
You must be signed in to change notification settings - Fork 13.7k
convert : remove redundant code #15708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Jie Fu <[email protected]>
| # if data ends up empty, it means data_torch was a scalar tensor -> restore | ||
| if len(data.shape) == 0: | ||
| data = data_torch.numpy() | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the intention here was to have the shape be non-zero for scalars, in which case
data = data.reshape(1)might be more appropriate in that otherwise redundant if condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @compilade for the comments.
Is there a case that data.reshape(1) is needed when converting gguf models?
If not, there might be some risk adding data.reshape(1) here.
I would suggest removing the code at the moment which doesn't change the logic.
And we can still add data.reshape(1) in the future if it really matters.
What do you think?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case that
data.reshape(1)is needed when converting gguf models?
Yes, and it's exactly when len(data.shape) == 0 (aka when the shape is an empty tuple ()).
It doesn't really happen in practice because most models don't have scalar tensors.
I would suggest removing the code at the moment which doesn't change the logic.
And we can still adddata.reshape(1)in the future if it really matters.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ggerganov and @compilade for your approval.
|
Thanks @taronaeo . |
Signed-off-by: Jie Fu <[email protected]>
Since
data = data_torch.numpy()has been called at line 303, line 307 seems to be redundant.Or am I missing something?
Thanks.