Shortcuts

Class TensorMaker

Page Contents

Class Documentation

class at::TensorMaker

Provides a fluent API to construct tensors from external data.

The fluent API can be used instead of from_blob functions in case the required set of parameters does not align with the existing overloads.

at::Tensor tensor = at::for_blob(data, sizes)
        .strides(strides)
        .context(context, [](void *ctx) { delete static_cast<Ctx*>(ctx); })
        .options(...)
        .make_tensor();

Public Types

using ContextDeleter = DeleterFnPtr

Public Functions

TensorMaker &strides(optional<IntArrayRef> value) noexcept
TensorMaker &deleter(std::function<void(void*)> value) noexcept
TensorMaker &context(void *value, ContextDeleter deleter = nullptr) noexcept
TensorMaker &target_device(optional<Device> value) noexcept
TensorMaker &options(TensorOptions value) noexcept
Tensor make_tensor()

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources