diff options
author | 2018-09-24 15:54:32 -0700 | |
---|---|---|
committer | 2018-09-24 16:02:13 -0700 | |
commit | 1ff157d82dac29f5a3a3197b2664208f6ed6ba06 (patch) | |
tree | c751f5a665a27c660809c4884eb07f69b4983244 /tensorflow/contrib/lite/model.cc | |
parent | 9c58005ec86297a1d0a17dc4f7ad7cbae9c47e4b (diff) |
Portability preparation for more cross-platform prototyping.
PiperOrigin-RevId: 214346240
Diffstat (limited to 'tensorflow/contrib/lite/model.cc')
-rw-r--r-- | tensorflow/contrib/lite/model.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tensorflow/contrib/lite/model.cc b/tensorflow/contrib/lite/model.cc index 6311d60b91..ea2817beec 100644 --- a/tensorflow/contrib/lite/model.cc +++ b/tensorflow/contrib/lite/model.cc @@ -189,6 +189,13 @@ std::vector<int> FlatBufferIntArrayToVector(T* flat_array) { return ret; } +// Used to determine how the op data parsing function creates its working space. +class MallocDataAllocator : public BuiltinDataAllocator { + public: + void* Allocate(size_t size) override { return malloc(size); } + void Deallocate(void* data) override { free(data); } +}; + } // namespace TfLiteStatus InterpreterBuilder::ParseNodes( @@ -234,8 +241,9 @@ TfLiteStatus InterpreterBuilder::ParseNodes( op->custom_options()->size(), nullptr, registration); } else { void* builtin_data = nullptr; - TF_LITE_ENSURE_STATUS( - ParseOpData(op, op_type, error_reporter_, &builtin_data)); + MallocDataAllocator malloc_allocator; + TF_LITE_ENSURE_STATUS(ParseOpData(op, op_type, error_reporter_, + &malloc_allocator, &builtin_data)); interpreter->AddNodeWithParameters( FlatBufferIntArrayToVector(op->inputs()), FlatBufferIntArrayToVector(op->outputs()), nullptr, 0, builtin_data, |