diff --git a/compiler/luci/export/src/CircleTensorExporter.cpp b/compiler/luci/export/src/CircleTensorExporter.cpp index 70bf202ddc6..c584f145cf6 100644 --- a/compiler/luci/export/src/CircleTensorExporter.cpp +++ b/compiler/luci/export/src/CircleTensorExporter.cpp @@ -346,7 +346,7 @@ flatbuffers::Offset encodeOpBuffer(FlatBufferBuilder &builder, template flatbuffers::Offset -encodeOpBufferByDType(FlatBufferBuilder &builder, SerializedModelData &, luci::CircleConst *c) +encodeOpBufferByDType(FlatBufferBuilder &builder, SerializedModelData &md, luci::CircleConst *c) { using NativeType = typename loco::DataTypeImpl
::Type; @@ -358,6 +358,21 @@ encodeOpBufferByDType(FlatBufferBuilder &builder, SerializedModelData &, luci::C raw_data.push_back(c->at
(i)); } const size_t raw_size = size * sizeof(NativeType); + + if (md._ext_buffer) + { + // TODO optimize this if this operation takes long or much memory + SerializedModelData::BufferData buffer_data; + buffer_data.resize(raw_size); + std::memcpy(buffer_data.data(), raw_data.data(), raw_size); + + int32_t buffer_index = md._buffers.size(); + md._buffer_data_map.emplace(buffer_index, buffer_data); + + // create fake indicator buffer + return circle::CreateBuffer(builder, 0 /* data */, 1 /* offset */, 1 /* size */); + } + auto array_offset = builder.CreateVector(reinterpret_cast(raw_data.data()), raw_size); return CreateBuffer(builder, array_offset); }