@@ -68,17 +68,24 @@ class MaxUnpoolLayerImpl CV_FINAL : public MaxUnpoolLayer
6868return false ;
6969 }
7070
71+ virtual void getTypes (const std::vector<MatType>& inputs,
72+ const int requiredOutputs,
73+ const int requiredInternals,
74+ std::vector<MatType>& outputs,
75+ std::vector<MatType>& internals)const
76+ {
77+ CV_Assert (inputs.size () >=2 );
78+ CV_Assert (inputs[0 ] == CV_32F || inputs[0 ] == CV_16S);
79+ CV_Assert (inputs[1 ] == CV_64S || inputs[1 ] == CV_32S);
80+ outputs.assign (1 , inputs[0 ]);
81+ }
82+
83+
7184void forward (InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
7285 {
7386CV_TRACE_FUNCTION ();
7487CV_TRACE_ARG_VALUE (name," name" , name.c_str ());
7588
76- if (inputs_arr.depth () == CV_16S)
77- {
78- forward_fallback (inputs_arr, outputs_arr, internals_arr);
79- return ;
80- }
81-
8289 std::vector<Mat> inputs, outputs;
8390 inputs_arr.getMatVector (inputs);
8491 outputs_arr.getMatVector (outputs);
@@ -87,6 +94,19 @@ class MaxUnpoolLayerImpl CV_FINAL : public MaxUnpoolLayer
8794 Mat& input = inputs[0 ];
8895 Mat& indices = inputs[1 ];
8996
97+ if (input.type () == CV_32F && indices.type () == CV_32S)
98+ run<float ,int32_t >(input, indices, outputs);
99+ else if (input.type () == CV_32F && indices.type () == CV_64S)
100+ run<float ,int64_t >(input, indices, outputs);
101+ else if (input.type () == CV_16S && indices.type () == CV_32S)
102+ run<int16_t ,int32_t >(input, indices, outputs);
103+ else if (input.type () == CV_16S && indices.type () == CV_64S)
104+ run<int16_t ,int64_t >(input, indices, outputs);
105+ }
106+
107+ template <typename T,typename INDEX_TYPE>
108+ void run (cv::Mat& input, cv::Mat& indices, std::vector<cv::Mat>& outputs)
109+ {
90110CV_Assert (input.total () == indices.total ());
91111CV_Assert (input.size [0 ] ==1 );
92112CV_Assert (input.isContinuous ());
@@ -102,9 +122,9 @@ class MaxUnpoolLayerImpl CV_FINAL : public MaxUnpoolLayer
102122 {
103123 Mat outPlane =getPlane (outBlob,0 , i_c);
104124int wh_area = input.size [2 ]*input.size [3 ];
105- const float * inptr = input.ptr <float >(0 , i_c);
106- const float * idxptr = indices.ptr <float >(0 , i_c);
107- float * outptr = outPlane.ptr <float >();
125+ const T * inptr = input.ptr <T >(0 , i_c);
126+ const INDEX_TYPE * idxptr = indices.ptr <INDEX_TYPE >(0 , i_c);
127+ T * outptr = outPlane.ptr <T >();
108128
109129for (int i_wh =0 ; i_wh < wh_area; i_wh++)
110130 {
@@ -125,6 +145,7 @@ class MaxUnpoolLayerImpl CV_FINAL : public MaxUnpoolLayer
125145 }
126146 }
127147
148+
128149#ifdef HAVE_CUDA
129150 Ptr<BackendNode>initCUDA (
130151void *context_,