Commit d55940d
committed
Fix ops.tile shape inference issue on TensorFlow backend
When ops.tile is called inside a Layer's call method with concrete
integer repeats, the TensorFlow backend was converting those repeats
to a tensor, which prevented TensorFlow's shape inference from properly
determining the output shape. This resulted in all-None shapes.
Changes:
1. Modified TensorFlow backend's tile() to detect when repeats contains
only concrete integer values and pass them directly to tf.tile as a
Python list/tuple instead of converting to a tensor. This allows
TensorFlow's shape inference to work correctly.
2. Enhanced ops.numpy.Tile.compute_output_spec() to handle symbolic
repeat values more gracefully by checking if each repeat is a
concrete integer before attempting multiplication.
3. Added regression tests to verify shape inference works correctly
both in direct ops.tile calls and when used inside Layer.call().
Fixes #20914
Signed-off-by: Samaresh Kumar Singh <[email protected]>1 parent e048ae4 commit d55940d
File tree
3 files changed
+75
-1
lines changed- keras/src
- backend/tensorflow
- ops
3 files changed
+75
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2742 | 2742 | | |
2743 | 2743 | | |
2744 | 2744 | | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
2745 | 2781 | | |
2746 | 2782 | | |
2747 | 2783 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6411 | 6411 | | |
6412 | 6412 | | |
6413 | 6413 | | |
| 6414 | + | |
| 6415 | + | |
| 6416 | + | |
| 6417 | + | |
| 6418 | + | |
| 6419 | + | |
| 6420 | + | |
| 6421 | + | |
| 6422 | + | |
6414 | 6423 | | |
6415 | 6424 | | |
6416 | 6425 | | |
6417 | 6426 | | |
6418 | 6427 | | |
6419 | 6428 | | |
6420 | 6429 | | |
| 6430 | + | |
| 6431 | + | |
6421 | 6432 | | |
6422 | 6433 | | |
6423 | | - | |
| 6434 | + | |
6424 | 6435 | | |
| 6436 | + | |
| 6437 | + | |
| 6438 | + | |
6425 | 6439 | | |
6426 | 6440 | | |
6427 | 6441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1820 | 1820 | | |
1821 | 1821 | | |
1822 | 1822 | | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
1823 | 1827 | | |
1824 | 1828 | | |
1825 | 1829 | | |
| |||
9507 | 9511 | | |
9508 | 9512 | | |
9509 | 9513 | | |
| 9514 | + | |
| 9515 | + | |
| 9516 | + | |
| 9517 | + | |
| 9518 | + | |
| 9519 | + | |
| 9520 | + | |
| 9521 | + | |
| 9522 | + | |
| 9523 | + | |
| 9524 | + | |
| 9525 | + | |
| 9526 | + | |
| 9527 | + | |
| 9528 | + | |
| 9529 | + | |
| 9530 | + | |
| 9531 | + | |
| 9532 | + | |
| 9533 | + | |
0 commit comments