static */
| 99 | } |
| 100 | |
| 101 | /* static */ Maybe<LocalTensor> LocalTensor::MakeTensor(const std::shared_ptr<const Shape>& shape, |
| 102 | const std::shared_ptr<const Stride>& stride, |
| 103 | DataType dtype, MemoryFormat memory_format, |
| 104 | const Symbol<Device>& device, bool is_lazy, |
| 105 | bool requires_grad, bool is_leaf) { |
| 106 | const auto& tensor_meta = SymbolOf(LocalTensorMeta(*shape, dtype, memory_format, device)); |
| 107 | if (is_lazy) { |
| 108 | const auto& impl = std::make_shared<LazyLocalTensorImpl>(tensor_meta, requires_grad, is_leaf); |
| 109 | return std::make_shared<LocalTensor>(impl); |
| 110 | } else { |
| 111 | const auto& impl = std::make_shared<EagerLocalTensorImpl>(requires_grad, is_leaf); |
| 112 | const auto& dep_object = NewLocalDepObject(); |
| 113 | JUST(impl->InitEagerBlobObject(tensor_meta, dep_object)); |
| 114 | return std::make_shared<LocalTensor>(impl); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | bool LocalTensor::is_cpu() const { return CHECK_JUST(device())->type() == "cpu"; } |
| 119 | bool LocalTensor::is_cuda() const { return CHECK_JUST(device())->type() == "cuda"; } |
nothing calls this directly
no test coverage detected