| 183 | } |
| 184 | |
| 185 | std::shared_ptr<Tensor> Tensor::ReshapeTensor(Tensor &tensor, Shape shape, std::optional<nvcv::TensorLayout> layout) |
| 186 | { |
| 187 | Tensor::Key key; |
| 188 | Cache::Instance().removeAllNotInUseMatching(key); |
| 189 | |
| 190 | nvcv::Tensor tensor_impl = tensor.impl(); |
| 191 | auto new_tensor_shape = CreateNVCVTensorShape(shape, layout ? *layout : tensor_impl.layout()); |
| 192 | nvcv::Tensor new_tensor_impl = tensor_impl.reshape(std::move(new_tensor_shape)); |
| 193 | auto new_tensor = std::shared_ptr<Tensor>(new Tensor(std::move(new_tensor_impl))); |
| 194 | |
| 195 | // Need to add wrappers to cache so that they don't get destroyed by |
| 196 | // the cuda stream when they're last used, and python script isn't |
| 197 | // holding a reference to them. If we don't do it, things might break. |
| 198 | Cache::Instance().add(*new_tensor); |
| 199 | return new_tensor; |
| 200 | } |
| 201 | |
| 202 | std::shared_ptr<Tensor> Tensor::Reshape(Shape shape, std::optional<nvcv::TensorLayout> layout) |
| 203 | { |
nothing calls this directly
no test coverage detected