36 storage_offset_ = value;
42 deleter_ = std::move(value);
48 ctx_ = std::unique_ptr<void, ContextDeleter>{
49 value, deleter !=
nullptr ? deleter : detail::noopDelete};
69 explicit TensorMaker(
void* data, IntArrayRef sizes) noexcept
70 : data_{data}, sizes_{sizes} {}
72 std::size_t computeStorageSize() const noexcept;
74 DataPtr makeDataPtrFromDeleter() const;
76 DataPtr makeDataPtrFromContext() noexcept;
78 IntArrayRef makeTempSizes() const noexcept;
82 OptionalIntArrayRef strides_{};
83 optional<int64_t> storage_offset_{};
84 std::function<void(
void*)> deleter_{};
85 std::unique_ptr<void, ContextDeleter> ctx_{
nullptr, detail::noopDelete};
86 optional<Device> device_{};
87 TensorOptions opts_{};
98 const std::function<
void(
void*)>& deleter,
99 const TensorOptions& options = {},
113 int64_t storage_offset,
114 const std::function<
void(
void*)>& deleter,
115 const TensorOptions& options = {},
129 const std::function<
void(
void*)>& deleter,
130 const TensorOptions& options = {}) {
141 const TensorOptions& options = {}) {
151 const TensorOptions& options = {}) {
Definition: TensorBody.h:90
Provides a fluent API to construct tensors from external data.
Definition: from_blob.h:23
TensorMaker & target_device(optional< Device > value) noexcept
Definition: from_blob.h:54
TensorMaker & context(void *value, ContextDeleter deleter=nullptr) noexcept
Definition: from_blob.h:47
DeleterFnPtr ContextDeleter
Definition: from_blob.h:27
TensorMaker & strides(OptionalIntArrayRef value) noexcept
Definition: from_blob.h:29
TensorMaker & options(TensorOptions value) noexcept
Definition: from_blob.h:60
TensorMaker & deleter(std::function< void(void *)> value) noexcept
Definition: from_blob.h:41
TensorMaker & storage_offset(optional< int64_t > value) noexcept
Definition: from_blob.h:35
Definition: Optional.h:549
TORCH_API void noopDelete(void *)
Definition: from_blob.h:8
Definition: TensorBase.h:34
Tensor from_blob(void *data, IntArrayRef sizes, IntArrayRef strides, const std::function< void(void *)> &deleter, const TensorOptions &options={}, const c10::optional< Device > target_device=c10::nullopt)
Definition: from_blob.h:94
TensorMaker for_blob(void *data, IntArrayRef sizes) noexcept
Definition: from_blob.h:90
constexpr nullopt_t nullopt
Definition: Optional.h:163