Skip to content

Commit

Permalink
Merge branch 'dev-0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
tvlenin committed Feb 11, 2020
2 parents 089b694 + eebf456 commit 6dacd6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Initialize autoconf.
AC_PREREQ([2.69])
AC_INIT([RidgeRun inference library],[0.4.1],[https://github.com/RidgeRun/r2inference/issues],[r2inference])
AC_INIT([RidgeRun inference library],[0.4.2],[https://github.com/RidgeRun/r2inference/issues],[r2inference])

# Initialize our build utils
RR_INIT
Expand Down
13 changes: 12 additions & 1 deletion r2i/tflite/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ const int Engine::GetAllowFP16 () {
return this->allow_fp16;
}

int64_t Engine::GetRequiredBufferSize (TfLiteIntArray *dims) {
int64_t size = 1;

/* For each dimension, multiply the amount of entries */
for (int dim = 0; dim < dims->size; ++dim) {
size *= dims->data[dim];
}

return size;
}

std::shared_ptr<r2i::IPrediction> Engine::Predict (std::shared_ptr<r2i::IFrame>
in_frame, r2i::RuntimeError &error) {
ImageFormat in_format;
Expand Down Expand Up @@ -201,7 +212,7 @@ std::shared_ptr<r2i::IPrediction> Engine::Predict (std::shared_ptr<r2i::IFrame>

int output = this->interpreter->outputs()[0];
TfLiteIntArray *output_dims = this->interpreter->tensor(output)->dims;
auto output_size = output_dims->data[output_dims->size - 1] * sizeof(float);
auto output_size = GetRequiredBufferSize(output_dims) * sizeof(float);
auto *tensor_data = this->interpreter->typed_output_tensor<float>(0);
prediction->SetTensorValues(tensor_data, output_size);

Expand Down
1 change: 1 addition & 0 deletions r2i/tflite/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Engine : public IEngine {
const int GetNumberOfThreads ();
RuntimeError SetAllowFP16 (int allow_fp16);
const int GetAllowFP16 ();
int64_t GetRequiredBufferSize (TfLiteIntArray *dims);

~Engine ();

Expand Down

0 comments on commit 6dacd6b

Please sign in to comment.