1 | #include <c10/core/UndefinedTensorImpl.h> |
---|---|
2 | #include <c10/util/Exception.h> |
3 | |
4 | namespace c10 { |
5 | |
6 | // should this use the globalContext? Can it get a context passed in somehow? |
7 | UndefinedTensorImpl::UndefinedTensorImpl() |
8 | : TensorImpl(DispatchKey::Undefined, caffe2::TypeMeta(), c10::nullopt) { |
9 | set_storage_access_should_throw(); |
10 | // TODO: accessing the sizes on an undefined tensor is not meaningful |
11 | // and should error too, but empirically it does not! |
12 | set_custom_sizes_strides(SizesStridesPolicy::CustomStrides); |
13 | } |
14 | |
15 | bool UndefinedTensorImpl::is_contiguous_custom(MemoryFormat format) const { |
16 | return is_contiguous_default(format); |
17 | } |
18 | IntArrayRef UndefinedTensorImpl::strides_custom() const { |
19 | TORCH_CHECK(false, "strides() called on an undefined Tensor"); |
20 | } |
21 | SymIntArrayRef UndefinedTensorImpl::sym_strides_custom() const { |
22 | TORCH_CHECK(false, "sym_strides() called on an undefined Tensor"); |
23 | } |
24 | |
25 | #ifdef DEBUG |
26 | bool UndefinedTensorImpl::has_storage() const { |
27 | TORCH_INTERNAL_ASSERT_DEBUG_ONLY( |
28 | !storage_, "UndefinedTensorImpl assumes that storage_ is never set"); |
29 | return false; |
30 | } |
31 | #endif |
32 | |
33 | void UndefinedTensorImpl::set_storage_offset(int64_t) { |
34 | TORCH_CHECK(false, "set_storage_offset() called on an undefined Tensor"); |
35 | } |
36 | |
37 | const char* UndefinedTensorImpl::tensorimpl_type_name() const { |
38 | return "UndefinedTensorImpl"; |
39 | } |
40 | |
41 | UndefinedTensorImpl UndefinedTensorImpl::_singleton; |
42 | |
43 | } // namespace c10 |
44 |