How to convert numpy.linalg.norm to LibTorch codes

Dear all,

I have tried to convert numpy.linalg.norm to LibTorch, not PyTorch.
I mange to find the LibTorch API [1]-[2], but I cannot apply the LibTorch API because I don’t know some required specific data type of the parameter (e.g. const optional &opt_ord in [1]).

If you are familiar with the LibTorch or know the above API usage, could you explain how to convert below numpy codes to the corresponding LibTorch codes?
I attach some Python3 and Cpp-LibTorch codes below.

import numpy as np


if __name__=='__main__:
    ndarr_temp = np.asarray([[1, 2], [3, 4]])
    ndarr_norm = np.linalg.norm(ndarr_temp, axis=0) 
    print(ndarr_norm) # array([3.16227766, 4.47213595])
#include <iostream>
#include <torch/torch.h>
#include <torch/script.h>
#include <ATen/ATen.h>
#include <ATen/Functions.h>


int main(int argc, const char* argv[]) {
    torch::Tensor tensor_temp = torch::tensor({{1, 2}, {3, 4}});
    
    // torch::Tensor tensor_norm = torch::linalg::norm(tensor_temp, 0); // This code is wrong.
    // Todo: Please implement the LibTorch codes corresponding to the above python codes.

    std::cout << tensor_norm << std::endl;

    return 0;
}

Best regards,
Vujadeyoon

[1] Function torch::linalg::norm(const Tensor&, const optional<Scalar>&, OptionalIntArrayRef, bool, optional<ScalarType>) — PyTorch master documentation

[2] Function torch::linalg::norm(const Tensor&, std::string, OptionalIntArrayRef, bool, optional<ScalarType>) — PyTorch master documentation

Dear all,

Unfortunately, I haven’t been able to find the solution that I hope.
However, I make a function, linalg_norm that does exactly the same thing as the numpy.linalg.norm.
Thus, the entire Cpp-LibTorch codes using it are as follows:

#include <iostream>
#include <torch/torch.h>
#include <torch/script.h>
#include <ATen/ATen.h>
#include <ATen/Functions.h>


torch::Tensor linalg_norm(torch::Tensor *ptr_tensor, int dim = 0, bool keepdim = false) {
    return torch::sqrt(torch::sum(torch::pow(*ptr_tensor, 2), {dim}, keepdim));
}


int main(int argc, const char* argv[]) {
    torch::Tensor tensor_temp = torch::tensor({{1, 2}, {3, 4}});
    torch::Tensor tensor_norm = linalg_norm(&tensor_temp, 0, true);
    std::cout << tensor_norm << std::endl;
    /*
    3.1623  4.4721
    [ CPUFloatType{1,2} ]
    */

    return 0;
}

Best regards,
Vujadeyoon