Skip to content

Commit

Permalink
TF Lite API related fix.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 539797484
Change-Id: I6a19f9330e5db6fa97bbdce10206b11d0769a66c
  • Loading branch information
ssjhv authored and copybara-github committed Jun 12, 2023
1 parent 0abd2bc commit 0859a8f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tensorflow_compression/cc/tflite/range_coder_kernels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ TfLiteStatus CheckOutputTypes(TfLiteContext* context, TfLiteNode* node) {
return CheckOutputTypesImpl<t...>(context, node, 0);
}

struct TfLiteIntArrayDeleter {
void operator()(TfLiteIntArray* p) {
if (p) TfLiteIntArrayFree(p);
}
};

// REQUIRES: tensor->type == kTfLiteInt32
// REQUIRES: NumDimensions(tensor) == 1
std::unique_ptr<TfLiteIntArray, tflite::TfLiteIntArrayDeleter> MakeShape(
std::unique_ptr<TfLiteIntArray, TfLiteIntArrayDeleter> MakeShape(
const TfLiteTensor* tensor) {
const int dims = SizeOfDimension(tensor, 0);
std::unique_ptr<TfLiteIntArray, tflite::TfLiteIntArrayDeleter> shape(
std::unique_ptr<TfLiteIntArray, TfLiteIntArrayDeleter> shape(
TfLiteIntArrayCreate(dims));
std::copy_n(GetTensorData<int32_t>(tensor), dims, shape->data);
return shape;
Expand Down

0 comments on commit 0859a8f

Please sign in to comment.