Where to Find torch._C._VariableFunctions module

Hi all,

It took me years to fine the source code about the torch._C._VariableFunctions module but for some reason I just could not find it? I would like to delve into details about the rnn_tanh and want to learn how the computational graph is formed. Any help would be appreciated!

Kol

As quoted from this blogpost on how PyTorch maps C code in Python

Now functions showing up in torch are more interesting - let’s take torch.bilinear - the function behind torch.nn.functional.bilinear - as an example. If you evaluate it (not call) on the IPython prompt, you’ll see <function _VariableFunctions.bilinear> and print (or ? ) says it is built-in, i.e. defined in C. Sure enough, there is a torch._C._VariableFunctions.bilinear . ( Note: That bilinear is exported as torch.bilinear is somewhat accidental . Do use the documented interfaces, here torch.nn.functional.bilinear whenever you can!)

Reference: Lernapparat - Machine Learning

Thank you for your resources. But as far as I know, there is no documented interfaces for torch._C._VariableFunctions.rnn_tanh(), then how could I find the source code of that? Thank you.

The reference actually works in that case, too, as it describes the general wrapping mechanism that also applies to undocumented functions. It leads you to perhaps unsurprisingly named RNN.cpp and RNN.cu. If you don’t care about the wrapping rgrep is usually a way to find things, too.

Best regards

Thomas

1 Like

Thank you for the help.