Commit 58554e2
committed
Update base for 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]1 parent ae48f99 commit 58554e2
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 | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 122 | | |
129 | 123 | | |
130 | 124 | | |
131 | | - | |
| 125 | + | |
132 | 126 | | |
133 | 127 | | |
134 | | - | |
| 128 | + | |
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 39 | | |
44 | 40 | | |
45 | 41 | | |
| |||
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
55 | | - | |
56 | | - | |
57 | 51 | | |
58 | 52 | | |
59 | 53 | | |
| |||
0 commit comments