(beta)torch_npu.fast_gelu
接口原型
torch_npu.fast_gelu(self) -> Tensor
功能描述
计算输入张量中fast_gelu的梯度。支持FakeTensor模式。
参数说明
self (Tensor) - 数据类型:float16、float32。
支持的型号
Atlas 训练系列产品 Atlas A2 训练系列产品 Atlas A3 训练系列产品 Atlas 推理系列产品
调用示例
示例一:
1 2 3 4 5 | >>> x = torch.rand(2).npu() >>> x tensor([0.5991, 0.4094], device='npu:0') >>> torch_npu.fast_gelu(x) tensor([0.4403, 0.2733], device='npu:0') |
示例二:
1 2 3 4 5 6 | //FakeTensor模式 >>> from torch._subclasses.fake_tensor import FakeTensorMode >>> with FakeTensorMode(): ... x = torch.rand(2).npu() ... torch_npu.fast_gelu(x) >>> FakeTensor(..., device='npu:0', size=(2,)) |
父主题: torch_npu