From 6576c0a4d8099f6082a50f4c47feff6f6d6af5e6 Mon Sep 17 00:00:00 2001 From: SaeHie Park Date: Tue, 27 Aug 2024 06:38:50 +0000 Subject: [PATCH] [circle-inspect] Revise to support extended Buffer This will revise to support extended Buffer correctly show file size > 2G. ONE-DCO-1.0-Signed-off-by: SaeHie Park --- compiler/circle-inspect/driver/Driver.cpp | 2 +- compiler/circle-inspect/src/Dump.cpp | 29 +++++++++++++---------- compiler/circle-inspect/src/Dump.h | 12 +++++----- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/compiler/circle-inspect/driver/Driver.cpp b/compiler/circle-inspect/driver/Driver.cpp index 4fa6069c896..6371261db87 100644 --- a/compiler/circle-inspect/driver/Driver.cpp +++ b/compiler/circle-inspect/driver/Driver.cpp @@ -85,7 +85,7 @@ int entry(int argc, char **argv) for (auto &dump : dumps) { - dump->run(std::cout, circleModel); + dump->run(std::cout, circleModel, &modelData); } return 0; diff --git a/compiler/circle-inspect/src/Dump.cpp b/compiler/circle-inspect/src/Dump.cpp index 373ac67a2cf..9d363e1ffa9 100644 --- a/compiler/circle-inspect/src/Dump.cpp +++ b/compiler/circle-inspect/src/Dump.cpp @@ -24,9 +24,9 @@ namespace circleinspect { -void DumpOperators::run(std::ostream &os, const circle::Model *model) +void DumpOperators::run(std::ostream &os, const circle::Model *model, const std::vector *data) { - mio::circle::Reader reader(model); + mio::circle::Reader reader(model, data); const uint32_t subgraph_size = reader.num_subgraph(); @@ -82,8 +82,9 @@ size_t tensor_buffer_size(mio::circle::Reader &reader, const int32_t tensor_id) auto tensor = tensors->Get(tensor_id); auto buffer_id = tensor->buffer(); + bool ext_offset = false; - size_t size = reader.buffer_info(buffer_id, nullptr); + size_t size = reader.buffer_info(buffer_id, nullptr, ext_offset); return size; } @@ -93,9 +94,10 @@ size_t tensor_buffer_size(mio::circle::Reader &reader, const int32_t tensor_id) namespace circleinspect { -void DumpConv2DWeight::run(std::ostream &os, const circle::Model *model) +void DumpConv2DWeight::run(std::ostream &os, const circle::Model *model, + const std::vector *data) { - mio::circle::Reader reader(model); + mio::circle::Reader reader(model, data); const uint32_t subgraph_size = reader.num_subgraph(); @@ -145,11 +147,12 @@ void DumpConv2DWeight::run(std::ostream &os, const circle::Model *model) namespace circleinspect { -void DumpOperatorVersion::run(std::ostream &os, const circle::Model *model) +void DumpOperatorVersion::run(std::ostream &os, const circle::Model *model, + const std::vector *data) { std::map op_version_map; - mio::circle::Reader reader(model); + mio::circle::Reader reader(model, data); // This assert is subject to be changed later assert(reader.num_subgraph() == 1); @@ -181,9 +184,10 @@ void DumpOperatorVersion::run(std::ostream &os, const circle::Model *model) namespace circleinspect { -void DumpTensorDType::run(std::ostream &os, const circle::Model *model) +void DumpTensorDType::run(std::ostream &os, const circle::Model *model, + const std::vector *data) { - mio::circle::Reader reader(model); + mio::circle::Reader reader(model, data); const uint32_t subgraph_size = reader.num_subgraph(); @@ -206,9 +210,9 @@ void DumpTensorDType::run(std::ostream &os, const circle::Model *model) namespace circleinspect { -void DumpConstants::run(std::ostream &os, const circle::Model *model) +void DumpConstants::run(std::ostream &os, const circle::Model *model, const std::vector *data) { - mio::circle::Reader reader(model); + mio::circle::Reader reader(model, data); const uint32_t subgraph_size = reader.num_subgraph(); @@ -224,8 +228,9 @@ void DumpConstants::run(std::ostream &os, const circle::Model *model) continue; auto const buffer_id = tensor->buffer(); + bool ext_offset = false; - auto const buffer_size = reader.buffer_info(buffer_id, nullptr); + auto const buffer_size = reader.buffer_info(buffer_id, nullptr, ext_offset); if (buffer_size == 0) continue; diff --git a/compiler/circle-inspect/src/Dump.h b/compiler/circle-inspect/src/Dump.h index 7ab1ebca9dd..12a43a71001 100644 --- a/compiler/circle-inspect/src/Dump.h +++ b/compiler/circle-inspect/src/Dump.h @@ -30,7 +30,7 @@ class DumpInterface virtual ~DumpInterface() = default; public: - virtual void run(std::ostream &os, const circle::Model *model) = 0; + virtual void run(std::ostream &os, const circle::Model *model, const std::vector *data) = 0; }; class DumpOperators final : public DumpInterface @@ -39,7 +39,7 @@ class DumpOperators final : public DumpInterface DumpOperators() = default; public: - void run(std::ostream &os, const circle::Model *model); + void run(std::ostream &os, const circle::Model *model, const std::vector *data); }; class DumpConv2DWeight final : public DumpInterface @@ -48,7 +48,7 @@ class DumpConv2DWeight final : public DumpInterface DumpConv2DWeight() = default; public: - void run(std::ostream &os, const circle::Model *model); + void run(std::ostream &os, const circle::Model *model, const std::vector *data); }; class DumpOperatorVersion final : public DumpInterface @@ -57,7 +57,7 @@ class DumpOperatorVersion final : public DumpInterface DumpOperatorVersion() = default; public: - void run(std::ostream &os, const circle::Model *model); + void run(std::ostream &os, const circle::Model *model, const std::vector *data); }; class DumpTensorDType final : public DumpInterface @@ -66,7 +66,7 @@ class DumpTensorDType final : public DumpInterface DumpTensorDType() = default; public: - void run(std::ostream &os, const circle::Model *model); + void run(std::ostream &os, const circle::Model *model, const std::vector *data); }; class DumpConstants final : public DumpInterface @@ -75,7 +75,7 @@ class DumpConstants final : public DumpInterface DumpConstants() = default; public: - void run(std::ostream &os, const circle::Model *model); + void run(std::ostream &os, const circle::Model *model, const std::vector *data); }; } // namespace circleinspect