Skip to content

[ET-VK] Add pass to remove local_scalar_dense #5886

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 7 commits into from

Conversation

SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Oct 4, 2024

Stack from ghstack (oldest at bottom):

Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

scalar_tensor[0].item()

This translates to the following chain in the graph

index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)

This diff introduces a pass to remove the local_scalar_dense "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

Differential Revision: D63913432

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Oct 4, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit b860608 with merge base aad548c (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 Oct 4, 2024
SS-JIA added a commit that referenced this pull request Oct 4, 2024
## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

ghstack-source-id: 246377322
Pull Request resolved: #5886
@facebook-github-bot
Copy link
Contributor

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

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

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

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

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

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

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

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

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

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

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

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

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

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

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

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

## Context

Scalar tensors (i.e. tensors with only 1 element) are often passed in to functions as scalars via

```
scalar_tensor[0].item()
```

This translates to the following chain in the graph

```
index_select = index_select(scalar_tensor, ...)
scalar = local_scalar_dense(index_select)
```

This diff introduces a pass to remove the `local_scalar_dense` "chain" in favor of passing in the input tensor directly.

Note that this replacement only occurs if the original tensor is a scalar tensor.

In the Vulkan backend, these scalar tensors will be represented as symbolic integers instead of actual tensors, which is why this replacement is valid. However, it may not a valid replacement for other backends.

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

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

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 400fefa.

@SS-JIA SS-JIA deleted the gh/SS-JIA/107/head branch January 24, 2025 19:45
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