Skip to content

Commit

Permalink
with _slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Qazalin committed May 24, 2024
1 parent 630f367 commit a3afa3a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion extra/onnx_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def Attention(x:Tensor, weights, bias:Optional[Tensor]=None, mask_index:Optional
if unidirectional: # gpt-style
assert hidden_size == v_hidden_size
xqkv = x.linear(weights, bias)
xq, xk, xv = [xqkv.slice([None, None, (i*hidden_size, (i+1)*hidden_size)]) for i in range(3)]
xq, xk, xv = [xqkv._slice([None, None, (i*hidden_size, (i+1)*hidden_size)]) for i in range(3)]
else: # bert-style
wq, wk, wv = weights[:,:hidden_size], weights[:,hidden_size:hidden_size+v_hidden_size], weights[:,hidden_size+v_hidden_size:]
bq, bk, bv = (bias[:hidden_size], bias[hidden_size:hidden_size+v_hidden_size], bias[hidden_size+v_hidden_size]) if bias is not None else None
Expand Down

0 comments on commit a3afa3a

Please sign in to comment.