How to normalize data with libtorch?

hello, everyone. i have a question about normalization with libtorch. In Pytorch help document, there shows
"
torch.nn.functional. normalize ( input , p=2 , dim=1 , eps=1e-12 , out=None )

but in libotrch, it shows there is no function in libtorch.

auto datases_input_normalize = torch::nn::functional::normalize(datasets_input, 2, 1,1e-12, None);

how to solve this problem? Or is there any function can be used to normalize in libtorch?

Thanks very much!

Which PyTorch version are you using?
This dummy code snippet works in the latest stable release:

cpp_source = """
    torch::Tensor my_norm(torch::Tensor input){
    
      auto out = torch::nn::functional::normalize(input);
      return out;
    }
    
"""

module = torch.utils.cpp_extension.load_inline(
    name="my_norm",
    cpp_sources=cpp_source,
    functions="my_norm",
    verbose=True,
)

x = torch.randn(10, 10)
out = module.my_norm(x)

Thanks for your reply, but i have problem with
“auto out = torch::nn::functional::normalize(input);”

it shows no normalize in torch::nn::functional.

Do you know why?

Have you solved this problem?

auto mean = torch::tensor({ 0.485, 0.456, 0.406 }, torch::kFloat32).unsqueeze(1).unsqueeze(2).to(device);
auto std = torch::tensor({ 0.229, 0.224, 0.225 }, torch::kFloat32).unsqueeze(1).unsqueeze(2).to(device);
image_tensor = image_tensor.sub(mean).div(std);