mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-04-30 20:55:17 +00:00
* [misc] update pre-commit * [misc] run pre-commit * [misc] remove useless configuration files * [misc] ignore cuda for clang-format
16 lines
434 B
Python
16 lines
434 B
Python
import torch
|
|
|
|
|
|
def bias_dropout_add(x, bias, residual, prob, training):
|
|
# type: (Tensor, Tensor, Tensor, float, bool) -> Tensor
|
|
out = torch.nn.functional.dropout(x + bias, p=prob, training=training)
|
|
out = residual + out
|
|
return out
|
|
|
|
|
|
def get_bias_dropout_add(training):
|
|
def _bias_dropout_add(x, bias, residual, prob):
|
|
return bias_dropout_add(x, bias, residual, prob, training)
|
|
|
|
return _bias_dropout_add
|