Commit 5ef1bd1
committed
Keep synthesized layer_norm gamma/beta at normalized_shape
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 c89f6a4 commit 5ef1bd1
2 files changed
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1956 | 1956 | | |
1957 | 1957 | | |
1958 | 1958 | | |
1959 | | - | |
| 1959 | + | |
1960 | 1960 | | |
1961 | | - | |
| 1961 | + | |
1962 | 1962 | | |
1963 | | - | |
| 1963 | + | |
1964 | 1964 | | |
1965 | 1965 | | |
1966 | 1966 | | |
| |||
2008 | 2008 | | |
2009 | 2009 | | |
2010 | 2010 | | |
2011 | | - | |
2012 | | - | |
2013 | | - | |
2014 | | - | |
2015 | | - | |
| 2011 | + | |
2016 | 2012 | | |
2017 | 2013 | | |
2018 | 2014 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6015 | 6015 | | |
6016 | 6016 | | |
6017 | 6017 | | |
| 6018 | + | |
| 6019 | + | |
| 6020 | + | |
| 6021 | + | |
| 6022 | + | |
| 6023 | + | |
| 6024 | + | |
| 6025 | + | |
| 6026 | + | |
| 6027 | + | |
| 6028 | + | |
| 6029 | + | |
| 6030 | + | |
| 6031 | + | |
| 6032 | + | |
| 6033 | + | |
| 6034 | + | |
| 6035 | + | |
| 6036 | + | |
| 6037 | + | |
| 6038 | + | |
| 6039 | + | |
| 6040 | + | |
| 6041 | + | |
| 6042 | + | |
| 6043 | + | |
| 6044 | + | |
| 6045 | + | |
| 6046 | + | |
| 6047 | + | |
| 6048 | + | |
| 6049 | + | |
| 6050 | + | |
6018 | 6051 | | |
6019 | 6052 | | |
6020 | 6053 | | |
| |||
0 commit comments