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