Commit 5fbd5bd
authored
Keep synthesized layer_norm gamma/beta at normalized_shape (#55)
When elementwise_affine=False, replace_layer_norm built the identity
gamma/beta as a flat numel-element vector, so a layer_norm over
normalized_shape (4, 8) produced a composite taking tensor<32xf32>
gamma/beta while its declaration said axes = [1, 2]. The body reshaped
them back before broadcasting, so numerics were correct, but the
composite boundary was inconsistent with the declared axes and differed
from the elementwise_affine=True case, where ATen's real params arrive
already shaped (4, 8). A consumer that implements the composite from its
declaration instead of inlining the body sees a rank-1 gamma against two
normalized axes.
Build the constants with np.ones/np.zeros at normalized_shape so both
paths present the same interface, and drop the now-dead reshape.1 parent 46d15b7 commit 5fbd5bd
2 files changed
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1970 | 1970 | | |
1971 | 1971 | | |
1972 | 1972 | | |
1973 | | - | |
| 1973 | + | |
1974 | 1974 | | |
1975 | | - | |
| 1975 | + | |
1976 | 1976 | | |
1977 | | - | |
| 1977 | + | |
1978 | 1978 | | |
1979 | 1979 | | |
1980 | 1980 | | |
| |||
2022 | 2022 | | |
2023 | 2023 | | |
2024 | 2024 | | |
2025 | | - | |
2026 | | - | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
| 2025 | + | |
2030 | 2026 | | |
2031 | 2027 | | |
2032 | 2028 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6052 | 6052 | | |
6053 | 6053 | | |
6054 | 6054 | | |
| 6055 | + | |
| 6056 | + | |
| 6057 | + | |
| 6058 | + | |
| 6059 | + | |
| 6060 | + | |
| 6061 | + | |
| 6062 | + | |
| 6063 | + | |
| 6064 | + | |
| 6065 | + | |
| 6066 | + | |
| 6067 | + | |
| 6068 | + | |
| 6069 | + | |
| 6070 | + | |
| 6071 | + | |
| 6072 | + | |
| 6073 | + | |
| 6074 | + | |
| 6075 | + | |
| 6076 | + | |
| 6077 | + | |
| 6078 | + | |
| 6079 | + | |
| 6080 | + | |
| 6081 | + | |
| 6082 | + | |
| 6083 | + | |
| 6084 | + | |
| 6085 | + | |
| 6086 | + | |
| 6087 | + | |
6055 | 6088 | | |
6056 | 6089 | | |
6057 | 6090 | | |
| |||
0 commit comments