Skip to content

No docs for torch::from_blob #14000

@Suhail

Description

@Suhail

📚 Documentation

Hi there, I was searching for documentation regarding torch::from_blob which is loosely demonstrated but I don't understand the API. I looked here: https://pytorch.org/cppdocs/api/namespace_torch.html#functions

but it's not listed.

I am trying to convert a vector that's {1, 3, 28, 28} to something I can pass to from_blob. I cannot tell if from_blob will take an array or if the array needs to flat somehow. If it's flat, how will it shape a list of floats into that shape?

Code:

    auto blob = j.get<vector<vector<vector<vector<float>>>>>();

    cout << blob << endl;

    at::TensorOptions options(at::ScalarType::Byte);
    at::Tensor t = torch::from_blob(blob, {1, 3, 28, 28});

I get an error:

error: no matching function for call to ‘from_blob(std::vector<std::vector<std::vector<std::vector<float, std::allocator<float> > > > >&, <brace-enclosed initializer list>)’
     at::Tensor t = torch::from_blob(blob, {1, 3, 28, 28});

Here's the actual json of the image: https://gist.github.com/Suhail/81ef7a763fbd0e5329b25fa41d31ad41

Documentation would help me :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions