Commit 8dfc70e
committed
[Relax][Frontend][TFLite] Support dynamic RANGE scalar bounds
Previously convert_range raised OpNotImplemented when start/limit/delta
were runtime (non-constant) scalar tensors, so any TFLite model that
computes RANGE bounds at runtime failed to import. This was one of the
"partial implementation" items tracked in #19412.
relax.op.arange only takes compile-time PrimExpr bounds, and its struct-info
length formula (InferTypeArange) has no negative-step branch, so feeding
symbolic bounds straight in would mis-declare descending ranges. Instead,
compute the element count in-graph and lift it to one symbolic output
dimension via relax.op.tensor_to_shape + match_cast (the bridge already used
by _get_shape_expr_from_tensor), so the declared and runtime lengths match by
construction. Values are rebuilt as arange(0, count) * delta + start. One
unified path covers both dtypes:
- int: count = -floor_divide(start - limit, delta), exact and sign-agnostic
(no float-precision loss), equal to ceil((limit - start) / delta);
- float: count = ceil((limit - start) / delta).
No new Relax op is needed.
Replace the "not supported" test with a compile-and-run test covering
ascending/descending integer and float dynamic bounds.1 parent 9808108 commit 8dfc70e
2 files changed
Lines changed: 110 additions & 31 deletions
File tree
- python/tvm/relax/frontend/tflite
- tests/python/relax
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1542 | 1542 | | |
1543 | 1543 | | |
1544 | 1544 | | |
1545 | | - | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
1546 | 1552 | | |
1547 | 1553 | | |
1548 | 1554 | | |
| |||
1551 | 1557 | | |
1552 | 1558 | | |
1553 | 1559 | | |
1554 | | - | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1555 | 1572 | | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
| 1573 | + | |
1566 | 1574 | | |
1567 | 1575 | | |
1568 | | - | |
1569 | 1576 | | |
1570 | 1577 | | |
1571 | 1578 | | |
1572 | 1579 | | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1576 | 1586 | | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
| 1587 | + | |
| 1588 | + | |
1582 | 1589 | | |
1583 | | - | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
1584 | 1616 | | |
1585 | | - | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
1586 | 1640 | | |
1587 | 1641 | | |
1588 | 1642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
721 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
722 | 731 | | |
723 | 732 | | |
724 | 733 | | |
725 | 734 | | |
726 | | - | |
727 | | - | |
728 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
729 | 738 | | |
730 | 739 | | |
731 | 740 | | |
732 | | - | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
733 | 758 | | |
734 | | - | |
735 | | - | |
| 759 | + | |
| 760 | + | |
736 | 761 | | |
737 | 762 | | |
738 | 763 | | |
| |||
0 commit comments