| 119 | __constants__ = ['bias'] |
| 120 | |
| 121 | def __init__(self, in_features, out_features, weights, biases, act='gelu', bias=True): |
| 122 | super(LinearActivation, self).__init__() |
| 123 | self.in_features = in_features |
| 124 | self.out_features = out_features |
| 125 | self.fused_gelu = False |
| 126 | self.fused_tanh = False |
| 127 | if isinstance(act, str): |
| 128 | if bias and act == 'gelu': |
| 129 | self.fused_gelu = True |
| 130 | elif bias and act == 'tanh': |
| 131 | self.fused_tanh = True |
| 132 | else: |
| 133 | self.act_fn = ACT2FN[act] |
| 134 | else: |
| 135 | self.act_fn = act |
| 136 | #self.weight = Parameter(torch.Tensor(out_features, in_features)) |
| 137 | self.weight = weights[5] |
| 138 | self.bias = biases[5] |
| 139 | #if bias: |
| 140 | # self.bias = Parameter(torch.Tensor(out_features)) |
| 141 | #else: |
| 142 | # self.register_parameter('bias', None) |
| 143 | #self.reset_parameters() |
| 144 | |
| 145 | def reset_parameters(self): |
| 146 | init.kaiming_uniform_(self.weight, a=math.sqrt(5)) |