From d5c8e9961e7cd49bff9ccb37902b127bfa80f616 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Tue, 18 Feb 2020 19:40:20 +0800 Subject: [PATCH] fix output --- core/general-server/op/general_response_op.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/general-server/op/general_response_op.cpp b/core/general-server/op/general_response_op.cpp index f2fdcedd..c4785002 100644 --- a/core/general-server/op/general_response_op.cpp +++ b/core/general-server/op/general_response_op.cpp @@ -106,10 +106,18 @@ int GeneralResponseOp::inference() { } } } else { - for (int j = 0; j < batch_size; ++j) { - for (int k = j * cap; k < (j + 1) * cap; ++k) { + int var_size = in->at(idx).shape[0]; + if (var_size == batch_size) { + for (int j = 0; j < batch_size; ++j) { + for (int k = j * cap; k < (j + 1) * cap; ++k) { + res->mutable_insts(j)->mutable_tensor_array(var_idx)->add_data( + reinterpret_cast(&(data_ptr[k])), sizeof(float)); + } + } + } else { + for (int j = 0; j < batch_size; ++j) { res->mutable_insts(j)->mutable_tensor_array(var_idx)->add_data( - reinterpret_cast(&(data_ptr[k])), sizeof(float)); + reinterpret_cast(&(data_ptr[0])), sizeof(float)); } } } -- GitLab