mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #12264 from dkurt:dnn_remove_forward_method
* Remove a forward method in dnn::Layer * Add a test * Fix tests * Mark multiple dnn::Layer::finalize methods as deprecated * Replace back dnn's inputBlobs to vector of pointers * Remove Layer::forward_fallback from CV_OCL_RUN scopes
This commit is contained in:
committed by
Alexander Alekhin
parent
8e8315abfd
commit
d486204a0d
@@ -40,8 +40,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs) CV_OVERRIDE
|
||||
virtual void finalize(InputArrayOfArrays inputs_arr, OutputArrayOfArrays) CV_OVERRIDE
|
||||
{
|
||||
std::vector<Mat> inputs;
|
||||
inputs_arr.getMatVector(inputs);
|
||||
hasWeights = blobs.size() == 2 || (blobs.size() == 1 && !hasBias);
|
||||
CV_Assert(inputs.size() == 2 && blobs.empty() || blobs.size() == (int)hasWeights + (int)hasBias);
|
||||
}
|
||||
@@ -57,20 +59,23 @@ public:
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
Layer::forward_fallback(inputs_arr, outputs_arr, internals_arr);
|
||||
}
|
||||
if (inputs_arr.depth() == CV_16S)
|
||||
{
|
||||
forward_fallback(inputs_arr, outputs_arr, internals_arr);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Mat> inputs, outputs;
|
||||
inputs_arr.getMatVector(inputs);
|
||||
outputs_arr.getMatVector(outputs);
|
||||
|
||||
void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals) CV_OVERRIDE
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
CV_Assert_N(outputs.size() == 1, !blobs.empty() || inputs.size() == 2);
|
||||
|
||||
Mat &inpBlob = *inputs[0];
|
||||
Mat &inpBlob = inputs[0];
|
||||
Mat &outBlob = outputs[0];
|
||||
// There is a mode when we multiply a first blob by a second one
|
||||
// instead of trainable weights.
|
||||
Mat weights = blobs.empty() ? *inputs[1] : (hasWeights ? blobs[0] : Mat());
|
||||
Mat weights = blobs.empty() ? inputs[1] : (hasWeights ? blobs[0] : Mat());
|
||||
Mat bias = hasBias ? blobs.back().reshape(1, 1) : Mat();
|
||||
if (!weights.empty())
|
||||
weights = weights.reshape(1, 1);
|
||||
|
||||
Reference in New Issue
Block a user