mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: As GoogleTest `TEST` macro is non-compliant with it as well as `DEFINE_DISPATCH` All changes but the ones to `.clang-tidy` are generated using following script: ``` for i in `find . -type f -iname "*.c*" -or -iname "*.h"|xargs grep cppcoreguidelines-avoid-non-const-global-variables|cut -f1 -d:|sort|uniq`; do sed -i "/\/\/ NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)/d" $i; done ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/62008 Reviewed By: driazati, r-barnes Differential Revision: D29838584 Pulled By: malfet fbshipit-source-id: 1b2f8602c945bd4ce50a9bfdd204755556e31d13
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#include <c10/core/UndefinedTensorImpl.h>
|
|
#include <c10/util/Exception.h>
|
|
|
|
namespace c10 {
|
|
|
|
// should this use the globalContext? Can it get a context passed in somehow?
|
|
UndefinedTensorImpl::UndefinedTensorImpl()
|
|
: TensorImpl(DispatchKey::Undefined, caffe2::TypeMeta(), c10::nullopt) {
|
|
set_storage_access_should_throw();
|
|
}
|
|
|
|
int64_t UndefinedTensorImpl::size(int64_t d) const {
|
|
TORCH_CHECK(false, "size(dim) called on an undefined Tensor");
|
|
}
|
|
|
|
int64_t UndefinedTensorImpl::stride(int64_t d) const {
|
|
TORCH_CHECK(false, "stride(dim) called on an undefined Tensor");
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
bool UndefinedTensorImpl::has_storage() const {
|
|
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(
|
|
!storage_, "UndefinedTensorImpl assumes that storage_ is never set");
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
void UndefinedTensorImpl::set_storage_offset(int64_t) {
|
|
TORCH_CHECK(false, "set_storage_offset() called on an undefined Tensor");
|
|
}
|
|
|
|
IntArrayRef UndefinedTensorImpl::strides() const {
|
|
TORCH_CHECK(false, "strides() called on undefined Tensor");
|
|
}
|
|
|
|
const char* UndefinedTensorImpl::tensorimpl_type_name() const {
|
|
return "UndefinedTensorImpl";
|
|
}
|
|
|
|
UndefinedTensorImpl UndefinedTensorImpl::_singleton;
|
|
|
|
} // namespace c10
|