| 169 | : tensor_ptr_(std::make_shared<Tensor>(std::move(tensor))) {} |
| 170 | |
| 171 | Tensor TensorLeaf::eval_impl() const { |
| 172 | // Materialize non-contiguous or offset tensors |
| 173 | if (tensor_ptr_->storage_offset() != 0 || !tensor_ptr_->is_contiguous()) { |
| 174 | return tensor_ptr_->contiguous(); |
| 175 | } |
| 176 | return *tensor_ptr_; |
| 177 | } |
| 178 | |
| 179 | const TensorShape& TensorLeaf::shape_impl() const { return tensor_ptr_->shape(); } |
| 180 | Device TensorLeaf::device_impl() const { return tensor_ptr_->device(); } |