Skip to content
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

Add repr method on tensor subclass #397

Merged

Conversation

tugsbayasgalan
Copy link

@tugsbayasgalan tugsbayasgalan commented Jun 18, 2024

Stack from ghstack (oldest at bottom):

Without this, it will go through default tensor repr method which has some aten ops to print the tensor. This results in triggerring subclass's torch_dispatch.

Differential Revision: D58786586

Copy link

pytorch-bot bot commented Jun 18, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/397

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit c22adf2 with merge base f5b6ec9 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

tugsbayasgalan added a commit that referenced this pull request Jun 18, 2024
ghstack-source-id: 1adc8a1bb74725d7c9b1709a5df70973d2b60497
Pull Request resolved: #397
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2024
tugsbayasgalan added a commit that referenced this pull request Jun 18, 2024
ghstack-source-id: f3d4313996236644408268f914fa880cb079165d
Pull Request resolved: #397
@@ -480,6 +480,9 @@ def _apply_fn_to_data(self, fn):
self.scale_and_zero = fn(self.scale_and_zero)
return self

def __repr__(self):
return f"TensorCoreTiledAQTLayout(packed_weight={self.packed_weight}, scale_and_zero={self.scale_and_zero})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can display the result of get_plain() here, packed_weight is not very useful

int_data, scale, zero_point = self.get_plain()
return f"TensorCoreTiledAQTLayout(int_data={int_data}, scale={scale}, zero_point={zero_point})"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok sure!

Without this, it will go through default tensor __repr__ method which has some aten ops to print the tensor. This results in triggerring subclass's torch_dispatch. 


[ghstack-poisoned]
tugsbayasgalan added a commit that referenced this pull request Jun 18, 2024
ghstack-source-id: f644a8d9f41ea3c999b2f54bd370e93a12ef4f35
Pull Request resolved: #397
@msaroufim
Copy link
Member

Btw @tugsbayasgalan do you intend to merge this to main? since seems like you're targeting your own branch

Screenshot 2024-06-18 at 7 17 50 PM

@jerryzh168
Copy link
Contributor

btw, the way to merge this PR is the following (heard from Vasiliy):

  1. ghimport this PR to fbcode
  2. land from fbcode

@tugsbayasgalan
Copy link
Author

@tugsbayasgalan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot merged commit ea71549 into gh/tugsbayasgalan/1/base Jun 19, 2024
8 of 9 checks passed
jerryzh168 added a commit to jerryzh168/ao that referenced this pull request Jun 25, 2024
Summary:
* added repr for TensorCoreTiledAQTLayoutTensor: pytorch#397
* removed the str -> apply_tensor_class map that was used to implement string APIs, which is removed in pytorch#400

Test Plan:
CI

Reviewers:

Subscribers:

Tasks:

Tags:
jerryzh168 added a commit to jerryzh168/ao that referenced this pull request Jun 25, 2024
Summary:
* added repr for TensorCoreTiledAQTLayoutTensor: pytorch#397
* removed the str -> apply_tensor_class map that was used to implement string APIs, which is removed in pytorch#400

Test Plan:
CI

Reviewers:

Subscribers:

Tasks:

Tags:
jerryzh168 added a commit that referenced this pull request Jun 26, 2024
Summary:
* added repr for TensorCoreTiledAQTLayoutTensor: #397
* removed the str -> apply_tensor_class map that was used to implement string APIs, which is removed in #400

Test Plan:
CI

Reviewers:

Subscribers:

Tasks:

Tags:
dbyoung18 pushed a commit to dbyoung18/ao that referenced this pull request Jul 31, 2024
Summary:
* added repr for TensorCoreTiledAQTLayoutTensor: pytorch#397
* removed the str -> apply_tensor_class map that was used to implement string APIs, which is removed in pytorch#400

Test Plan:
CI

Reviewers:

Subscribers:

Tasks:

Tags:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants