-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Update torch::stable::Tensor() default constructor #159507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh/mikaylagawarecki/330/base
Are you sure you want to change the base?
Changes from all commits
5635bca
6808f0f
daef220
20ee0fb
7eeb740
5b28d27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -29,7 +29,15 @@ class Tensor { | |||||||||||||||||
std::shared_ptr<AtenTensorOpaque> ath_; | ||||||||||||||||||
|
||||||||||||||||||
public: | ||||||||||||||||||
Tensor() = delete; | ||||||||||||||||||
// Construct a stable::Tensor with an uninitialized AtenTensorHandle (ATH) | ||||||||||||||||||
// Steals ownership from the ATH | ||||||||||||||||||
Tensor() { | ||||||||||||||||||
AtenTensorHandle ret; | ||||||||||||||||||
TORCH_ERROR_CODE_CHECK(aoti_torch_new_uninitialized_tensor(&ret)); | ||||||||||||||||||
ath_ = std::shared_ptr<AtenTensorOpaque>(ret, [](AtenTensorHandle ath) { | ||||||||||||||||||
TORCH_ERROR_CODE_CHECK(aoti_torch_delete_tensor_object(ath)); | ||||||||||||||||||
}); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// Construct a stable::Tensor from an AtenTensorHandle (ATH) | ||||||||||||||||||
// Steals ownership from the ATH | ||||||||||||||||||
|
@@ -115,6 +123,12 @@ class Tensor { | |||||||||||||||||
return size; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
bool defined() const { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same semantic as the one in TensorBase.h right? And to make sure I'm understanding correctly: an undefined tensor is an uninitialized tensor which I know has no memory but is it basically a nullptr? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes to the first pytorch/torch/csrc/inductor/aoti_torch/shim_common.cpp Lines 759 to 764 in 5f5f508
pytorch/aten/src/ATen/templates/TensorBody.h Line 103 in 5f5f508
pytorch/aten/src/ATen/core/TensorBase.h Line 95 in 5f5f508
My understanding is I think there is a special case where |
||||||||||||||||||
bool defined; | ||||||||||||||||||
TORCH_ERROR_CODE_CHECK(aoti_torch_is_defined(ath_.get(), &defined)); | ||||||||||||||||||
return defined; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// ============================================================================= | ||||||||||||||||||
// END of C-shimified TensorBase APIs | ||||||||||||||||||
// ============================================================================= | ||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.