spragian commited on
Commit
8946843
·
verified ·
1 Parent(s): ad11173

Preserve the existing branch matrix axis

Browse files
Files changed (1) hide show
  1. token_operations.py +2 -1
token_operations.py CHANGED
@@ -72,7 +72,8 @@ def install(model,*,linears,moe):
72
  if module.weight.dtype!=torch.bfloat16 or (is_output and value.ndim==2):
73
  return original(value,*args,**kwargs)
74
  shape=value.shape
75
- result=batched_linear(value.reshape(1,-1,shape[-1]),module.weight,module.bias)
 
76
  return result.reshape(*shape[:-1],module.weight.shape[0])
77
  return forward
78
  if linears:
 
72
  if module.weight.dtype!=torch.bfloat16 or (is_output and value.ndim==2):
73
  return original(value,*args,**kwargs)
74
  shape=value.shape
75
+ matrices=value if value.ndim==3 else value.reshape(1,-1,shape[-1])
76
+ result=batched_linear(matrices,module.weight,module.bias)
77
  return result.reshape(*shape[:-1],module.weight.shape[0])
78
  return forward
79
  if linears: