r"""Applies a linear transformation to the input tensor. Refer to :class:`~.module.linear.Linear` for more information. Args: inp: input tensor with shape `(N, in_features)`. weight: weight with shape `(out_features, in_features)`. bias: bias with shape `(out_featur
(
inp: Tensor, weight: Tensor, bias: Optional[Tensor] = None, compute_mode="default",
)
| 130 | |
| 131 | |
| 132 | def linear( |
| 133 | inp: Tensor, weight: Tensor, bias: Optional[Tensor] = None, compute_mode="default", |
| 134 | ) -> Tensor: |
| 135 | r"""Applies a linear transformation to the input tensor. |
| 136 | |
| 137 | Refer to :class:`~.module.linear.Linear` for more information. |
| 138 | |
| 139 | Args: |
| 140 | inp: input tensor with shape `(N, in_features)`. |
| 141 | weight: weight with shape `(out_features, in_features)`. |
| 142 | bias: bias with shape `(out_features,)`. Default: None |
| 143 | """ |
| 144 | compute_mode = _config._get_actual_op_param(compute_mode, _config.__compute_mode) |
| 145 | ret = _matmul(inp, weight, transpose_b=True, compute_mode=compute_mode) |
| 146 | if bias is not None: |
| 147 | if amp._enabled: |
| 148 | bias = bias.astype("float16") |
| 149 | ret += bias |
| 150 | return ret |
| 151 | |
| 152 | |
| 153 | def conv1d( |