Merge pull request #25218 from alexlyulkov:al/int64-tile

Allowed int types in Tile and Reduce layers #25218

Allowed any Mat type in Tile layer.
Allowed int64 type in Reduce layer.

ONNX tests with int32 and int64 inputs will be added later in a separate PR


### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
pull/25415/head
alexlyulkov 8 months ago committed by GitHub
parent a33de44b0b
commit f0323fdd1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      modules/dnn/src/layers/reduce_layer.cpp
  2. 9
      modules/dnn/src/layers/tile_layer.cpp

@ -131,6 +131,16 @@ public:
return false;
}
virtual void getTypes(const std::vector<MatType>& inputs,
const int requiredOutputs,
const int requiredInternals,
std::vector<MatType>& outputs,
std::vector<MatType>& internals) const CV_OVERRIDE
{
CV_CheckType(inputs[0], inputs[0] == CV_32F || inputs[0] == CV_32S || inputs[0] == CV_64S || inputs[0] == CV_16F || inputs[0] == CV_8U, "");
outputs.assign(1, inputs[0]);
}
template <typename T>
class ReduceBase {
public:
@ -491,6 +501,7 @@ public:
switch (type) {
case CV_8U: opDispatch<uint8_t>(std::forward<Args>(args)...); break;
case CV_32S: opDispatch<int32_t>(std::forward<Args>(args)...); break;
case CV_64S: opDispatch<int64_t>(std::forward<Args>(args)...); break;
case CV_32F: opDispatch<float>(std::forward<Args>(args)...); break;
default: CV_Error(cv::Error::BadDepth, "DNN/Reduce: Unsupported type.");
}

@ -53,6 +53,15 @@ public:
return false;
}
void getTypes(const std::vector<MatType>& inputs,
const int requiredOutputs,
const int requiredInternals,
std::vector<MatType>& outputs,
std::vector<MatType>& internals) const CV_OVERRIDE
{
outputs.assign(requiredOutputs, inputs[0]);
}
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
{
CV_TRACE_FUNCTION();

Loading…
Cancel
Save