-
Notifications
You must be signed in to change notification settings - Fork 54
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
Introduced a format for displaying the DCSR_matrix #1176
Conversation
Thank you for the PR! |
Thank you for the PR! |
@Sai-Suraj-27 Regarding the introduced format I have a question: your picture of the PyTorch print result shows that indices are given by a 2D-tensor (which makes sense because specifying the position of a non-zero entry in a matrix requires us to state row- and column-index). In your print result for DCSR, the index-tensor is 1D. Is this due to the CSR-format? |
@mrfh92 Yes, sir. In PyTorch's sparse tensor representation, the indices are stored as a 2D tensor. On the other hand, In CSR format, the indices are stored as a 1D tensor, where each element represents the column index of a non-zero entry. |
Hi @Sai-Suraj-27, |
Ok, sir. I will wait for the feedback. |
Thank you for the PR! |
Thank you for the PR! |
Hi @Sai-Suraj-27, |
@mrfh92 sir, so do you want me to update the function such that we will be printing like this: |
Thank you for the PR! |
@@ -337,3 +337,22 @@ def __repr__(self) -> str: | |||
if self.comm.rank != 0: | |||
return "" | |||
return print_string | |||
|
|||
def __str__(self) -> str: |
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.
It would be better if this function is moved to the core/printing
module. There are cases like local print vs global print to be handled. See the __str__
method of the DNDarray
class for more information.
And it is usually best to use the printing format used by PyTorch since it gives more information to the user. The information outputted by __str__
should prioritize user-readability more than anything else. Just the indptr
and indices
would be too difficult to understand. I, personally, would prefer to see the exact coordinates being printed out. I say this because the users of Heat shouldn't be expected to know about the CSR matrix and its format. They should just be able to use this more-efficient data structure without having to learn too much about it.
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.
What @mrfh92 says also seems acceptable to me. Maybe the users won't want to see the actual data points. But my only problem with this solution is, the users wouldn't be able to see the data points even if they wanted to. There is no other way for them to get the coordinates if we don't show it in the print
output.
This pull request is stale because it has been open for 60 days with no activity. |
This pull request was closed because it has been inactive for 60 days since being marked as stale. |
Description
Added a
__str__()
method for printing the DCSR_matrix.PyTorch displays the
sparse tensors
in this format:The introduced format displays the following:
Issue/s resolved: #1040
Changes proposed:
Type of change
Due Diligence
Does this change modify the behaviour of other functions? If so, which?
No