Commit 7104ff3
committed
Update on "[ET-VK] Add pass to remove local_scalar_dense"
## 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]File tree
3 files changed
+2
-16
lines changed- backends/vulkan
- partitioner
3 files changed
+2
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | 146 | | |
153 | 147 | | |
154 | 148 | | |
155 | 149 | | |
156 | 150 | | |
157 | 151 | | |
158 | | - | |
| 152 | + | |
159 | 153 | | |
160 | 154 | | |
161 | | - | |
| 155 | + | |
162 | 156 | | |
163 | 157 | | |
164 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | 43 | | |
48 | 44 | | |
49 | 45 | | |
| |||
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | | - | |
60 | | - | |
61 | 55 | | |
62 | 56 | | |
63 | 57 | | |
| |||
0 commit comments