From c99c4b7f16b59fe5f3cfdd7fb9651e86e420d7f4 Mon Sep 17 00:00:00 2001 From: xiaying Date: Thu, 28 May 2020 14:54:41 +0800 Subject: [PATCH] Fix bug for sub swap error --- source/backend/cpu/CPUBinary.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/backend/cpu/CPUBinary.cpp b/source/backend/cpu/CPUBinary.cpp index 13611723..e83627ce 100644 --- a/source/backend/cpu/CPUBinary.cpp +++ b/source/backend/cpu/CPUBinary.cpp @@ -327,6 +327,15 @@ struct BinaryNotEqual : std::binary_function<_Arg1, _Arg2, _ErrorCode> { } }; +static void callEleFunc(void(*proc)(float* C, const float* A, const float* B, size_t width, size_t cStride, size_t aStride, size_t bStride, size_t height), + float* C, const float* A, const float* B, size_t size, bool swap) { + if (swap) { + proc(C, B, A, size, 0, 0, 0, 1); + } else { + proc(C, A, B, size, 0, 0, 0, 1); + } +} + ErrorCode CPUBinaryFloat::onExecute(const std::vector& inputs, const std::vector& outputs) { auto input = inputs[0]; auto input1 = inputs[1]; @@ -365,7 +374,7 @@ ErrorCode CPUBinaryFloat::onExecute(const std::vector& inputs, const st } else { MNN_CONCURRENCY_BEGIN(tId, numberThread) { for (int y = tId; y < mOutside; y+=numberThread) { - mElementProc(output->host() + y * mAxis, input->host() + y * mAxis, input1->host(), mAxis, 0, 0, 0, 1); + callEleFunc(mElementProc, output->host() + y * mAxis, input->host() + y * mAxis, input1->host(), mAxis, swap); } } MNN_CONCURRENCY_END();