Logarithm approximation CUDA intrinsics

Hello, community!

I’m writing pytorch code that uses a lot of logarithms, and it’s slower than ideal. When writing raw CUDA code, I’ve been able to speed things up using CUDA intrinsics, which gives approximate logarithms at the cost of a small amount of accuracy:

Is there any way to use these approximations within pytorch? I couldn’t see any options for torch.log, but maybe the functionality is elsewhere.

You could create a custom CUDA extension as described here and use it in your PyTorch model.

1 Like