Where is the real implementation of codes of Sigmoid_()?

I can not find the real full implemetnation codes of function Sigmoid_()?
Colud you help me ? Thank you!

The CPU implementation should dispatch to this kernel and the CUDA implementation to this one.

1 Like

Thany you very much. And I’m sorry to disturb you once more.
If I want to read other codes of some specific functions, how can I find their implementations?
Besides, as far as I’m concerned, the two codes shared by you are beyond the mathematical meaning of Sigmoid function. It provides more difficulty for me to understand.

Generally, you could either directly search for the function names in the repository and then track the calls to the actual kernel implementation or alternatively you could also start by searching for the operation in native_functions.yaml and then continue with the operation names.

The sigmoid function is used in both kernels as seen in e.g.:

return static_cast<float>(1) / (static_cast<float>(1) + std::exp((-a0)));
...
return scalar_t{1} / (scalar_t{1} + std::exp(-a));
...

However, you are right that e.g. the TensorIterator is used to speed up the code which might not be trivial to understand.

1 Like