dnn: fix to iteration variable scope

This commit is contained in:
Kumataro 2024-03-05 18:33:56 +09:00
parent 1d1faaabef
commit 216c6c3da1
5 changed files with 12 additions and 0 deletions

View File

@ -260,12 +260,14 @@ void Layer::getTypes(const std::vector<MatType>&inputs,
{ {
CV_Assert(inputs.size()); CV_Assert(inputs.size());
for (auto input : inputs) for (auto input : inputs)
{
if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA) if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA)
CV_CheckTypeEQ(input, CV_32F, ""); CV_CheckTypeEQ(input, CV_32F, "");
else if (preferableTarget == DNN_TARGET_OPENCL_FP16) else if (preferableTarget == DNN_TARGET_OPENCL_FP16)
CV_CheckType(input, input == CV_16F || input == CV_8S, ""); CV_CheckType(input, input == CV_16F || input == CV_8S, "");
else else
CV_CheckType(input, input == CV_32F || input == CV_8S, ""); CV_CheckType(input, input == CV_32F || input == CV_8S, "");
}
outputs.assign(requiredOutputs, inputs[0]); outputs.assign(requiredOutputs, inputs[0]);
internals.assign(requiredInternals, inputs[0]); internals.assign(requiredInternals, inputs[0]);

View File

@ -186,12 +186,14 @@ public:
{ {
CV_Assert(inputs.size()); CV_Assert(inputs.size());
for (auto input : inputs) for (auto input : inputs)
{
if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA) if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA)
CV_CheckTypeEQ(input, CV_32F, "Unsupported type"); CV_CheckTypeEQ(input, CV_32F, "Unsupported type");
else if (preferableTarget == DNN_TARGET_OPENCL_FP16) else if (preferableTarget == DNN_TARGET_OPENCL_FP16)
CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S, ""); CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S, "");
else else
CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S, ""); CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S, "");
}
outputs.assign(requiredOutputs, inputs[0]); outputs.assign(requiredOutputs, inputs[0]);
} }

View File

@ -109,12 +109,14 @@ public:
{ {
CV_Assert(inputs.size()); CV_Assert(inputs.size());
for (auto input : inputs) for (auto input : inputs)
{
if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA) if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA)
CV_CheckTypeEQ(input, CV_32F, "Unsupported type for CUDA"); CV_CheckTypeEQ(input, CV_32F, "Unsupported type for CUDA");
else if (preferableTarget == DNN_TARGET_OPENCL_FP16) else if (preferableTarget == DNN_TARGET_OPENCL_FP16)
CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, "");
else else
CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, "");
}
outputs.assign(requiredOutputs, inputs[0]); outputs.assign(requiredOutputs, inputs[0]);
} }

View File

@ -267,12 +267,14 @@ public:
{ {
CV_Assert(inputs.size()); CV_Assert(inputs.size());
for (auto input : inputs) for (auto input : inputs)
{
if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA) if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA)
CV_CheckTypeEQ(input, CV_32F, "Unsupported type"); CV_CheckTypeEQ(input, CV_32F, "Unsupported type");
else if (preferableTarget == DNN_TARGET_OPENCL_FP16) else if (preferableTarget == DNN_TARGET_OPENCL_FP16)
CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, "");
else else
CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, "");
}
outputs.assign(requiredOutputs, inputs[0]); outputs.assign(requiredOutputs, inputs[0]);
} }

View File

@ -286,12 +286,14 @@ public:
{ {
CV_CheckEQ(inputs.size(), (size_t)1, ""); CV_CheckEQ(inputs.size(), (size_t)1, "");
for (auto input : inputs) for (auto input : inputs)
{
if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA) if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA)
CV_CheckEQ(input, CV_32F, "Unsupported type"); CV_CheckEQ(input, CV_32F, "Unsupported type");
else if (preferableTarget == DNN_TARGET_OPENCL_FP16) else if (preferableTarget == DNN_TARGET_OPENCL_FP16)
CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, "");
else else
CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, "");
}
outputs.assign(requiredOutputs, inputs[0]); outputs.assign(requiredOutputs, inputs[0]);
} }
@ -908,12 +910,14 @@ public:
{ {
CV_CheckEQ(inputs.size(), (size_t)2, ""); CV_CheckEQ(inputs.size(), (size_t)2, "");
for (auto input : inputs) for (auto input : inputs)
{
if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA) if (preferableTarget == DNN_TARGET_CUDA_FP16 || preferableTarget == DNN_TARGET_CUDA)
CV_CheckTypeEQ(input, CV_32F, "Unsupported type"); CV_CheckTypeEQ(input, CV_32F, "Unsupported type");
else if (preferableTarget == DNN_TARGET_OPENCL_FP16) else if (preferableTarget == DNN_TARGET_OPENCL_FP16)
CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_16F || input == CV_8S || input == CV_32S || input == CV_64S, "");
else else
CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, ""); CV_CheckType(input, input == CV_32F || input == CV_8S || input == CV_32S || input == CV_64S, "");
}
outputs.assign(requiredOutputs, inputs[0]); outputs.assign(requiredOutputs, inputs[0]);
} }