They are actually the same, and so should be identical it terms of speed
Is you look at the source, nn.Tanh uses torch.tanh in its forward method.

  
      github.com
  
  
    pytorch/pytorch/blob/master/torch/nn/modules/activation.py#L299 1

.. image:: scripts/activation_images/Tanh.png


Examples::


    >>> m = nn.Tanh()
    >>> input = torch.randn(2)
    >>> output = m(input)
"""


@weak_script_method
def forward(self, input):
    return torch.tanh(input)




@weak_module
class ELU(Module):
r"""Applies the element-wise function:


.. math::
    \text{ELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x) - 1))