Query numerical infos for ScalarType

I have been trying without success to query the numerical information of torch::ScalarTypes, e.g. maximum representable value, epsilon etc.

I would like to do something like what std::numeric_limits does for cpp type, e.g.
std::numeric_limits. Does anyone have a good way to do that?

The PyTorch finfo object used as:

torch.finfo(torch.float32)
finfo(resolution=1e-06, min=-3.40282e+38, max=3.40282e+38, eps=1.19209e-07, smallest_normal=1.17549e-38, tiny=1.17549e-38, dtype=float32)

would internally call into these methods, so you should be able to use the same in your C++ application. I.e.:

std::numeric_limits<at::scalar_value_type<scalar_t>::type>::epsilon());

etc. should work.

Thank you for your answer.
I tried it out and I’m a bit confused by how to pass a torch::ScalarType to the at::scalar_value_type method.

If I try to insert a torch::ScalarType in place of the the scalar_t above, I get:

[build] …/torchOps/torchOps.cpp:165:64: error: template argument for template type parameter must be a type
[build] auto f32_espilon = std::numeric_limits<at::scalar_value_type< torch::kF32>::type>::epsilon();
[build] ^~~~~~~~~~~
[build] …/libtorch/include/c10/util/complex_utils.h:21:20: note: template parameter is declared here
[build] template < typename T>
[build] ^
[build] 1 error generated.

I’m not experienced with cpp very much, so that could be the source of my confusion. But I can see from the definition of at::scalar_value_type that indeed it expects a type.

Any idea what I’m doing wrong?