I understand the C++ API is in beta so the documentation is sparse, but I am curious what the best way to cast from a tensor to/from a standard C type is?
What I have currently is:
To tensor:
#define N_FEATURES 2

...

    float x[N_FEATURES] = {5, 4};
    std::vector<torch::jit::IValue> inputs;
    auto ones = torch::ones({1, N_FEATURES});
    for (int i = 0; i < N_FEATURES; i++) {
        ones[0][i] = x[i];
    }
    inputs.push_back(ones);

Then, for output:
     // output is [1, 1] vector
     auto output = module->forward(inputs).toTensor();
     float y = *(float*)(output[0][0].data_ptr());

These seem a bit ugly so I was wondering what the standard way is? I’ve looked through some of the Tensor.h template functions like .data() but couldn’t get it working. data_ptr() seems to work fine though.
Cheers,
Miles