Skip to content

Commit

Permalink
[circledump] Resive to support Buffer offsset (#13728)
Browse files Browse the repository at this point in the history
This will revise to support Buffer offset for file size > 2G.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored Aug 21, 2024
1 parent 2158eb7 commit 01c23cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
6 changes: 5 additions & 1 deletion compiler/circledump/driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ int entry(int argc, char **argv)

std::cout << "Dump: " << circle_path << std::endl << std::endl;

std::cout << circlemodel << std::endl;
circledump::ModelEx modelex;
modelex.model = circlemodel;
modelex.rawdata = &modelData;

std::cout << modelex << std::endl;

return 0;
}
10 changes: 8 additions & 2 deletions compiler/circledump/include/circledump/Dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
namespace circledump
{

void dump_model(std::ostream &os, const circle::Model *model);
struct ModelEx
{
const circle::Model *model;
const std::vector<char> *rawdata;
};

void dump_model(std::ostream &os, const circledump::ModelEx &model);

} // namespace circledump

std::ostream &operator<<(std::ostream &os, const circle::Model *model);
std::ostream &operator<<(std::ostream &os, const circledump::ModelEx &model);

#endif // __CIRCLEDUMP_DUMP_H__
18 changes: 11 additions & 7 deletions compiler/circledump/src/Dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ void dump_sub_graph(std::ostream &os, mio::circle::Reader &reader)
os << std::endl;
}

void dump_model(std::ostream &os, const circle::Model *model)
void dump_model(std::ostream &os, const circle::Model *model, const std::vector<char> *rawdata)
{
mio::circle::Reader reader(model);
mio::circle::Reader reader(model, rawdata);

uint32_t num_subgraph = reader.num_subgraph();

Expand Down Expand Up @@ -378,13 +378,17 @@ void dump_model(std::ostream &os, const circle::Model *model)
os << std::endl;

// dump buffer
os << "Buffers: B(index) (length) values, if any" << std::endl;
os << "Buffers: B(index) (length) values, if any; (length *) for ext_offset" << std::endl;
for (uint32_t i = 0; i < buffers->size(); ++i)
{
bool ext_offset = false;
const uint8_t *buff_data;
size_t size = reader.buffer_info(i, &buff_data);
size_t size = reader.buffer_info(i, &buff_data, ext_offset);

os << "B(" << i << ") (" << size << ") ";
os << "B(" << i << ") (" << size;
if (ext_offset)
os << " *";
os << ") ";
if (buff_data != nullptr)
{
dump_buffer(os, buff_data, size, 16);
Expand Down Expand Up @@ -460,8 +464,8 @@ void dump_model(std::ostream &os, const circle::Model *model)

} // namespace circledump

std::ostream &operator<<(std::ostream &os, const circle::Model *model)
std::ostream &operator<<(std::ostream &os, const circledump::ModelEx &modelex)
{
circledump::dump_model(os, model);
circledump::dump_model(os, modelex.model, modelex.rawdata);
return os;
}

0 comments on commit 01c23cb

Please sign in to comment.