Skip to content

Commit

Permalink
Model_zoo CN label_ids wrong NODE_ASSERT and cleanup after allocation…
Browse files Browse the repository at this point in the history
… failure (openvinotoolkit#1037)

* fix

* changed types
  • Loading branch information
mkuczyns11 authored Nov 25, 2021
1 parent f0179c2 commit 9501149
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ bool copy_images_into_output(struct CustomNodeTensor* output, const std::vector<

bool copy_coordinates_into_output(struct CustomNodeTensor* output, const std::vector<cv::Vec4f>& detections) {
const uint64_t outputBatch = detections.size();
uint64_t byteSize = sizeof(int32_t) * 4 * outputBatch;
uint64_t byteSize = sizeof(float) * 4 * outputBatch;

int32_t* buffer = (int32_t*)malloc(byteSize);
float* buffer = (float*)malloc(byteSize);
NODE_ASSERT(buffer != nullptr, "malloc has failed");
if (buffer == nullptr) {
return false;
Expand Down Expand Up @@ -130,9 +130,9 @@ bool copy_confidences_into_output(struct CustomNodeTensor* output, const std::ve

bool copy_label_ids_into_output(struct CustomNodeTensor* output, const std::vector<int>& labelIds) {
const uint64_t outputBatch = labelIds.size();
uint64_t byteSize = sizeof(float) * outputBatch;
uint64_t byteSize = sizeof(int32_t) * outputBatch;

float* buffer = (float*)malloc(byteSize);
int32_t* buffer = (int32_t*)malloc(byteSize);
NODE_ASSERT(buffer != nullptr, "malloc has failed");
std::memcpy(buffer, labelIds.data(), byteSize);

Expand Down Expand Up @@ -302,7 +302,7 @@ int execute(const struct CustomNodeTensor* inputs, int inputsCount, struct Custo
if (!copy_label_ids_into_output(&labelIdsTensor, labelIds)) {
cleanup(imagesTensor);
cleanup(coordinatesTensor);
cleanup(labelIdsTensor);
cleanup(confidencesTensor);
free(*outputs);
return 1;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ int getOutputsInfo(struct CustomNodeTensorInfo** info, int* infoCount, const str
(*info)[3].name = OUTPUT_LABEL_IDS_TENSOR_NAME;
(*info)[3].dimsCount = 3;
(*info)[3].dims = (uint64_t*)malloc((*info)->dimsCount * sizeof(uint64_t));
NODE_ASSERT(((*info)[2].dims) != nullptr, "malloc has failed");
NODE_ASSERT(((*info)[3].dims) != nullptr, "malloc has failed");
(*info)[3].dims[0] = 0;
(*info)[3].dims[1] = 1;
(*info)[3].dims[2] = 1;
Expand Down

0 comments on commit 9501149

Please sign in to comment.