mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix TODO in make_tensor_for_subclass_helper (#162336)
The constructor does accept a DataPtr (had to fix the DataPtr variant not accepting a SymInt, though). Pull Request resolved: https://github.com/pytorch/pytorch/pull/162336 Approved by: https://github.com/ezyang ghstack dependencies: #162298
This commit is contained in:
committed by
PyTorch MergeBot
parent
c9485f8ff3
commit
a63221a335
@ -61,6 +61,22 @@ struct C10_API Storage {
|
|||||||
allocator,
|
allocator,
|
||||||
resizable)) {}
|
resizable)) {}
|
||||||
|
|
||||||
|
// Creates storage with pre-allocated memory buffer. Allocator is given for
|
||||||
|
// potential future reallocations, however it can be nullptr if the storage
|
||||||
|
// is non-resizable
|
||||||
|
Storage(
|
||||||
|
use_byte_size_t /*use_byte_size*/,
|
||||||
|
SymInt size_bytes,
|
||||||
|
at::DataPtr data_ptr,
|
||||||
|
at::Allocator* allocator = nullptr,
|
||||||
|
bool resizable = false)
|
||||||
|
: storage_impl_(c10::make_intrusive<StorageImpl>(
|
||||||
|
StorageImpl::use_byte_size_t(),
|
||||||
|
std::move(size_bytes),
|
||||||
|
std::move(data_ptr),
|
||||||
|
allocator,
|
||||||
|
resizable)) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Storage(unsafe_borrow_t, const Storage& rhs)
|
explicit Storage(unsafe_borrow_t, const Storage& rhs)
|
||||||
: storage_impl_(c10::intrusive_ptr<c10::StorageImpl>::reclaim(
|
: storage_impl_(c10::intrusive_ptr<c10::StorageImpl>::reclaim(
|
||||||
|
@ -660,10 +660,9 @@ static Tensor make_tensor_for_subclass_helper(
|
|||||||
Storage storage{
|
Storage storage{
|
||||||
Storage::use_byte_size_t{},
|
Storage::use_byte_size_t{},
|
||||||
size_bytes,
|
size_bytes,
|
||||||
|
at::DataPtr{nullptr, options.device()},
|
||||||
/*allocator=*/c10::GetAllocator(c10::kMeta),
|
/*allocator=*/c10::GetAllocator(c10::kMeta),
|
||||||
/*resizable=*/true};
|
/*resizable=*/true};
|
||||||
// TODO: constructor should probably accept data pointer
|
|
||||||
storage.set_data_ptr_noswap(at::DataPtr{nullptr, options.device()});
|
|
||||||
|
|
||||||
auto keys = c10::DispatchKeySet({options.computeDispatchKey()});
|
auto keys = c10::DispatchKeySet({options.computeDispatchKey()});
|
||||||
if (extra_dispatch_keys.has_value()) {
|
if (extra_dispatch_keys.has_value()) {
|
||||||
|
Reference in New Issue
Block a user