mirror of
https://github.com/opencv/opencv.git
synced 2025-07-31 01:47:12 +08:00
handle redundant slice in SliceOp
This commit is contained in:
parent
51a42c0647
commit
aff2c7c43c
@ -10,11 +10,13 @@
|
||||
#include "../csl/stream.hpp"
|
||||
|
||||
#include "../kernels/slice.hpp"
|
||||
#include "../kernels/fill_copy.hpp"
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace cv { namespace dnn { namespace cuda4dnn {
|
||||
@ -43,6 +45,22 @@ namespace cv { namespace dnn { namespace cuda4dnn {
|
||||
auto input_wrapper = inputs[0].dynamicCast<wrapper_type>();
|
||||
auto input = input_wrapper->getView();
|
||||
|
||||
CV_Assert(offsets.size() == outputs.size());
|
||||
|
||||
/* one output with the same shape as the input => direct copy */
|
||||
if (outputs.size() == 1)
|
||||
{
|
||||
auto output_wrapper = outputs[0].dynamicCast<wrapper_type>();
|
||||
auto output = output_wrapper->getSpan();
|
||||
|
||||
if (is_shape_same(output, input))
|
||||
{
|
||||
CV_Assert(std::all_of(std::begin(offsets[0]), std::end(offsets[0]), [] (std::size_t x) { return x == 0; }));
|
||||
kernels::copy<T>(stream, output, input);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < outputs.size(); ++i)
|
||||
{
|
||||
auto output_wrapper = outputs[i].dynamicCast<wrapper_type>();
|
||||
|
Loading…
Reference in New Issue
Block a user