| 119 | } |
| 120 | |
| 121 | Maybe<void> InplaceView(const std::shared_ptr<Tensor>& input, const Shape& target_shape, |
| 122 | const Stride& target_stride, const int64_t storage_offset) { |
| 123 | Symbol<LocalTensorMeta> new_tensor_meta = |
| 124 | SymbolOf(LocalTensorMeta(target_shape, target_stride, input->dtype()->data_type(), |
| 125 | input->memory_format(), JUST(input->device()))); |
| 126 | |
| 127 | bool requires_grad = (autograd::GradMode::is_enabled() && input->requires_grad()); |
| 128 | std::shared_ptr<EagerLocalTensorImpl> new_tensor_impl = std::make_shared<EagerLocalTensorImpl>( |
| 129 | JUST(input->tensor_storage()), storage_offset, /*requires_grad=*/requires_grad, |
| 130 | /*is_leaf=*/!requires_grad); |
| 131 | JUST(new_tensor_impl->InitEagerBlobObject( |
| 132 | new_tensor_meta, JUST(JUST(input->eager_blob_object())->compute_local_dep_object()))); |
| 133 | JUST(JUST(input->AsLocalTensor())->set_impl(new_tensor_impl)); |
| 134 | return Maybe<void>::Ok(); |
| 135 | } |
| 136 | |
| 137 | Maybe<Tensor> Reshape(const std::shared_ptr<Tensor>& input, const Shape& target_shape) { |
| 138 | Stride target_stride(target_shape); |
no test coverage detected