Skip to content

Add repr method on tensor subclass - #397

Merged
facebook-github-bot merged 3 commits into
gh/tugsbayasgalan/1/basefrom
gh/tugsbayasgalan/1/head
Jun 19, 2024
Merged

facebook-github-bot merged 3 commits into
gh/tugsbayasgalan/1/basefrom
gh/tugsbayasgalan/1/head

Conversation

@tugsbayasgalan

@tugsbayasgalan tugsbayasgalan commented Jun 18, 2024 •

Copy link
Copy Markdown
Contributor

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

@pytorch-bot

pytorch-bot Bot commented Jun 18, 2024 •

Copy link
Copy Markdown

🔗 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 pushed a commit that referenced this pull request Jun 18, 2024
ghstack-source-id: 1adc8a1
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 pushed a commit that referenced this pull request Jun 18, 2024
ghstack-source-id: f3d4313
Pull Request resolved: #397
Comment thread torchao/dtypes/aqt.py Outdated
return self

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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 pushed a commit that referenced this pull request Jun 18, 2024
ghstack-source-id: f644a8d
Pull Request resolved: #397
@msaroufim

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor 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
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:
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