mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Clean up a c10::optional and fix documentation (#138700)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/138700 Approved by: https://github.com/Skylion007
This commit is contained in:
parent
8aedc649bd
commit
dbd6ada8c3
|
|
@ -878,7 +878,7 @@ Process 87741 stopped
|
||||||
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
|
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
|
||||||
frame #0: 0x00000001024e2628 libtorch_python.dylib`at::indexing::impl::applySelect(self=0x00000001004ee8a8, dim=0, index=(data_ = 3), real_dim=0, (null)=0x000000016fdfe535, self_sizes= Has Value=true ) at TensorIndexing.h:239:7
|
frame #0: 0x00000001024e2628 libtorch_python.dylib`at::indexing::impl::applySelect(self=0x00000001004ee8a8, dim=0, index=(data_ = 3), real_dim=0, (null)=0x000000016fdfe535, self_sizes= Has Value=true ) at TensorIndexing.h:239:7
|
||||||
236 const at::Device& /*self_device*/,
|
236 const at::Device& /*self_device*/,
|
||||||
237 const c10::optional<SymIntArrayRef>& self_sizes) {
|
237 const std::optional<SymIntArrayRef>& self_sizes) {
|
||||||
238 // See NOTE [nested tensor size for indexing]
|
238 // See NOTE [nested tensor size for indexing]
|
||||||
-> 239 if (self_sizes.has_value()) {
|
-> 239 if (self_sizes.has_value()) {
|
||||||
240 auto maybe_index = index.maybe_as_int();
|
240 auto maybe_index = index.maybe_as_int();
|
||||||
|
|
@ -1081,10 +1081,6 @@ Here are a few well known pitfalls and workarounds:
|
||||||
catch all of these problems: stay vigilant to the possibility that
|
catch all of these problems: stay vigilant to the possibility that
|
||||||
your crash is due to a real memory problem.
|
your crash is due to a real memory problem.
|
||||||
|
|
||||||
* (NVCC) `c10::optional` does not work when used from device code. Don't use
|
|
||||||
it from kernels. Upstream issue: https://github.com/akrzemi1/Optional/issues/58
|
|
||||||
and our local issue #10329.
|
|
||||||
|
|
||||||
* `constexpr` generally works less well on MSVC.
|
* `constexpr` generally works less well on MSVC.
|
||||||
|
|
||||||
* The idiom `static_assert(f() == f())` to test if `f` is constexpr
|
* The idiom `static_assert(f() == f())` to test if `f` is constexpr
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ C10_API void warnDeprecatedDataPtr();
|
||||||
// Currently used only for storing a custom error message
|
// Currently used only for storing a custom error message
|
||||||
// used when throwing an exception when data_ptr is accessed.
|
// used when throwing an exception when data_ptr is accessed.
|
||||||
struct C10_API StorageExtraMeta {
|
struct C10_API StorageExtraMeta {
|
||||||
c10::optional<std::string> custom_data_ptr_error_msg_ = c10::nullopt;
|
std::optional<std::string> custom_data_ptr_error_msg_ = c10::nullopt;
|
||||||
StorageExtraMeta() = default;
|
StorageExtraMeta() = default;
|
||||||
StorageExtraMeta(const StorageExtraMeta& other) {
|
StorageExtraMeta(const StorageExtraMeta& other) {
|
||||||
if (other.custom_data_ptr_error_msg_) {
|
if (other.custom_data_ptr_error_msg_) {
|
||||||
|
|
@ -283,7 +283,7 @@ struct C10_API StorageImpl : public c10::intrusive_ptr_target {
|
||||||
[[noreturn]] void throw_data_ptr_access_error() const;
|
[[noreturn]] void throw_data_ptr_access_error() const;
|
||||||
|
|
||||||
void release_data_and_set_meta_custom_data_ptr_error_msg_(
|
void release_data_and_set_meta_custom_data_ptr_error_msg_(
|
||||||
c10::optional<std::string> s) {
|
std::optional<std::string> s) {
|
||||||
throw_on_immutable_data_ptr_ = true;
|
throw_on_immutable_data_ptr_ = true;
|
||||||
get_extra_meta().custom_data_ptr_error_msg_ = std::move(s);
|
get_extra_meta().custom_data_ptr_error_msg_ = std::move(s);
|
||||||
refresh_has_data_ptr_check();
|
refresh_has_data_ptr_check();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user