MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / ReshapeTensor

Method ReshapeTensor

python/mod_cvcuda/nvcv/Tensor.cpp:185–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185std::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
202std::shared_ptr<Tensor> Tensor::Reshape(Shape shape, std::optional<nvcv::TensorLayout> layout)
203{

Callers

nothing calls this directly

Calls 6

CreateNVCVTensorShapeFunction · 0.85
implMethod · 0.80
reshapeMethod · 0.80
layoutMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected