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

Function HistogramInto

python/mod_cvcuda/operators/OpHistogram.cpp:30–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28namespace {
29
30Tensor HistogramInto(Tensor &histogram, Tensor &input, std::optional<Tensor> mask, std::optional<Stream> pstream)
31{
32 if (!pstream)
33 {
34 pstream = Stream::Current();
35 }
36
37 if (mask)
38 {
39 if (mask->shape() != input.shape())
40 {
41 throw std::invalid_argument("Mask must have the same shape as input");
42 }
43 }
44
45 auto op = CreateOperator<cvcuda::Histogram>();
46
47 ResourceGuard guard(*pstream);
48 guard.add(LockMode::LOCK_MODE_READ, {input});
49 guard.add(LockMode::LOCK_MODE_WRITE, {histogram});
50 guard.add(LockMode::LOCK_MODE_NONE, {*op});
51
52 if (mask)
53 {
54 guard.add(LockMode::LOCK_MODE_READ, {*mask});
55 op->submit(pstream->cudaHandle(), input, *mask, histogram);
56 }
57 else
58 {
59 op->submit(pstream->cudaHandle(), input, nvcv::NullOpt, histogram);
60 }
61 return std::move(histogram);
62}
63
64Tensor Histogram(Tensor &input, std::optional<Tensor> mask, std::optional<Stream> pstream)
65{

Callers 1

HistogramFunction · 0.85

Calls 4

cudaHandleMethod · 0.80
shapeMethod · 0.45
addMethod · 0.45
submitMethod · 0.45

Tested by

no test coverage detected