Skip to content

[ET-Ext] Enable operator<< for Half tensor data #3779

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

Closed
wants to merge 4 commits into from

Conversation

jorgep31415
Copy link
Contributor

@jorgep31415 jorgep31415 commented May 30, 2024

Stack from ghstack (oldest at bottom):

Useful for debugging Half i.e. fp16 models, when we have EValues that are Half dtype and we do the following:

std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}

Before

===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])

After

===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])

Differential Revision: D57977366

Useful for debugging `Half` i.e. `fp16` models.

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented May 30, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/3779

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

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

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

@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 May 30, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D57977366

jorgep31415 added a commit that referenced this pull request May 30, 2024
Useful for debugging `Half` i.e. `fp16` models.

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)

ghstack-source-id: 228310784
Pull Request resolved: #3779
@jorgep31415 jorgep31415 changed the title [ET][EZ] Print tensor data for Half dtype [ET][EZ] Enable operator<< for Half tensor data May 30, 2024
Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following:
```
std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}
```

## Before
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])
```

## After
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])
```

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D57977366

jorgep31415 added a commit that referenced this pull request May 30, 2024
Pull Request resolved: #3779

Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following:
```
std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}
```

## Before
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])
```

## After
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])
```

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)
ghstack-source-id: 228335774
Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following:
```
std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}
```

## Before
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])
```

## After
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])
```

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D57977366

jorgep31415 added a commit that referenced this pull request May 30, 2024
Pull Request resolved: #3779

Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following:
```
std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}
```

## Before
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])
```

## After
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])
```
ghstack-source-id: 228346052

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)
Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following:
```
std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}
```

## Before
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])
```

## After
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])
```

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D57977366

@jorgep31415 jorgep31415 changed the title [ET][EZ] Enable operator<< for Half tensor data [ET-Ext] Enable operator<< for Half tensor data May 31, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 8c8d965.

kedarnath03 pushed a commit to kedarnath03/executorch that referenced this pull request Jun 25, 2025
Pull Request resolved: pytorch/executorch#3779

Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following:
```
std::cout << "===== INPUT =====" << std::endl;
for (EValue& v : inputs) {
  std::cout << v << std::endl;
}

std::cout << "===== OUTPUT =====" << std::endl;
for (EValue& v : outputs) {
  std::cout << v << std::endl;
}
```

## Before
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>])
```

## After
```
===== INPUT =====
tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043])
===== OUTPUT =====
tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312])
```
ghstack-source-id: 228461839

Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)
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. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants