Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[circle-inspect] Revise to support extended Buffer #13781

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/circle-inspect/driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 17 additions & 12 deletions compiler/circle-inspect/src/Dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> *data)
{
mio::circle::Reader reader(model);
mio::circle::Reader reader(model, data);

const uint32_t subgraph_size = reader.num_subgraph();

Expand Down Expand Up @@ -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;
}
Expand All @@ -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<char> *data)
{
mio::circle::Reader reader(model);
mio::circle::Reader reader(model, data);

const uint32_t subgraph_size = reader.num_subgraph();

Expand Down Expand Up @@ -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<char> *data)
{
std::map<std::string, int32_t> 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);
Expand Down Expand Up @@ -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<char> *data)
{
mio::circle::Reader reader(model);
mio::circle::Reader reader(model, data);

const uint32_t subgraph_size = reader.num_subgraph();

Expand All @@ -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<char> *data)
{
mio::circle::Reader reader(model);
mio::circle::Reader reader(model, data);

const uint32_t subgraph_size = reader.num_subgraph();

Expand All @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions compiler/circle-inspect/src/Dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> *data) = 0;
};

class DumpOperators final : public DumpInterface
Expand All @@ -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<char> *data);
};

class DumpConv2DWeight final : public DumpInterface
Expand All @@ -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<char> *data);
};

class DumpOperatorVersion final : public DumpInterface
Expand All @@ -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<char> *data);
};

class DumpTensorDType final : public DumpInterface
Expand All @@ -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<char> *data);
};

class DumpConstants final : public DumpInterface
Expand All @@ -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<char> *data);
};

} // namespace circleinspect
Expand Down