Commit 358b4e2
Fix VGF runtime aborts on 0-dim tensor inputs and Python scalar coercion (#19446)
Summary:
The ARM-backend VGF tests (e.g. ``test_sum_dim_intlist_vgf_quant`` and
``test_sum_dim_intlist_vgf_no_quant`` for all 19 parametrizations) were
hard-aborting the pytest process with two latent bugs that compounded:
1. **C++ aten_bridge nullptr assert on 0-dim tensors (T270603238).**
``executorch/extension/aten_util/aten_bridge.cpp::check_tensor_meta`` had two
unconditional ``ET_CHECK_MSG(b.{sizes,strides}().data() != nullptr, ...)``
asserts. For 0-dim (scalar) tensors, ``sizes()``/``strides()`` are empty
``IntArrayRef``s whose ``.data()`` may legitimately return nullptr. The
process aborted on every valid scalar tensor input. Fix: gate the nullptr
checks on ``b.dim() > 0``. The subsequent loops are no-ops when ``dim() ==
0`` and ``dim_order_to_stride_nocheck`` already early-returns for ``dims ==
0`` (``dim_order_util.h:132-134``), so the relaxed asserts are safe.
2. **VGF Python runner over-wrapping non-tensor inputs (Error::InvalidArgument
0x12).** ``runner_fb.run_vgf`` previously called ``torch.tensor(x)`` on
every non-tensor input (including ``None``/``bool``/``int``), producing
0-dim tensors. The lowered method's signature, however, expects ``EValue``
tags ``Int``/``Bool``/``None`` for those slots — receiving a ``Tensor``
caused ``Method::set_inputs`` to reject the inputs. The pybindings layer
(``pybindings.cpp:804-809``) already natively handles
``None``/``bool``/``int`` Python objects; the runner just had to stop
interfering. Fix: only wrap Python ``float`` (and other unknown types) as
0-dim tensors — the original ``addmm`` alpha/beta motivation. Pass
``None``/``bool``/``int`` through unchanged.
3. **Regression tests** for the C++ fix in
``executorch/extension/aten_util/test/aten_bridge_test.cpp``:
``AliasETensorToATenTensorZeroDim`` and ``AliasATTensorToETensorZeroDim``
construct true 0-dim tensors via ``at::scalar_tensor`` and verify the
bridge does not abort. The existing ``AliasETensorToATenTensorFail`` death
test still fires for ranked tensors with empty strides because that case
has ``dim() == 3 > 0``.
Fixes T270603238.
Differential Revision: D1046037391 parent a49171d commit 358b4e2
2 files changed
Lines changed: 57 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
26 | 37 | | |
27 | 38 | | |
28 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
158 | 199 | | |
159 | 200 | | |
160 | 201 | | |
| |||
0 commit comments