Commit 3bbc26ac authored by Robert Kimball's avatar Robert Kimball Committed by Scott Cyphers

nbench statistics update (#2795)

* constant/io sizes

* add sizes and counts for all data io in a json

* Add details to model sizing

* change filemode

* change filemode

* fix filemode
parent 91a7e8ac
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -80,6 +80,14 @@ namespace ngraph
std::string to_upper(const std::string& s);
std::string trim(const std::string& s);
std::vector<std::string> split(const std::string& s, char delimiter, bool trim = false);
template <typename T>
std::string locale_string(T x)
{
std::stringstream ss;
ss.imbue(std::locale(""));
ss << x;
return ss.str();
}
class stopwatch
{
......
......@@ -27,7 +27,9 @@
#include "ngraph/except.hpp"
#include "ngraph/file_util.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/pass/liveness.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/memory_layout.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/serializer.hpp"
......@@ -132,10 +134,7 @@ void print_times(const multimap<size_t, string>& timing)
for (const pair<size_t, string>& p : timing)
{
name_width = max(name_width, static_cast<int>(p.second.size()));
stringstream ss;
ss.imbue(locale(""));
ss << p.first;
time_width = max(time_width, static_cast<int>(ss.str().size()));
time_width = max(time_width, static_cast<int>(locale_string(p.first).size()));
}
for (auto it = timing.rbegin(); it != timing.rend(); it++)
{
......@@ -356,13 +355,30 @@ OPTIONS
{
shared_ptr<Function> f = deserialize(model);
pass::Manager pass_manager;
pass_manager.register_pass<pass::Liveness>();
pass_manager.register_pass<pass::MemoryLayout>();
pass_manager.run_passes(f);
cout << "\n---- Source Graph Statistics ----\n";
cout << "Total nodes: " << f->get_ops().size() << endl;
cout << "Total nodes: " << locale_string(f->get_ops().size()) << endl;
size_t total_constant_bytes = 0;
size_t total_parameter_bytes = 0;
size_t total_result_bytes = 0;
size_t total_temporary_bytes = 0;
size_t total_constant_count = 0;
size_t total_parameter_count = 0;
size_t total_result_count = 0;
size_t total_temporary_count = 0;
unordered_map<string, size_t> op_list;
set<string> type_list;
for (shared_ptr<Node> node : f->get_ordered_ops())
{
for (descriptor::Tensor* tensor : node->liveness_new_list)
{
total_temporary_bytes += tensor->size();
total_temporary_count++;
}
string name = node->get_name();
string op_name = name.substr(0, name.find('_'));
string shape_name = "{" + join(node->output(0).get_shape()) + "}";
......@@ -373,6 +389,7 @@ OPTIONS
if (op_name == "Constant")
{
total_constant_count++;
const Shape& shape = node->output(0).get_shape();
size_t const_size = node->output(0).get_element_type().size();
if (shape.size() == 0)
......@@ -385,9 +402,32 @@ OPTIONS
(const_size * shape_size(node->output(0).get_shape()));
}
}
else if (op_name == "Parameter")
{
total_parameter_count++;
const Shape& shape = node->output(0).get_shape();
size_t size = node->output(0).get_element_type().size() * shape_size(shape);
total_parameter_bytes += size;
}
else if (op_name == "Result")
{
total_result_count++;
const Shape& shape = node->input(0).get_shape();
size_t size = node->input(0).get_element_type().size() * shape_size(shape);
total_result_bytes += size;
}
}
cout << "--\n";
cout << "Total Constant size: " << total_constant_bytes << " bytes\n";
cout << "Total Constant size: " << locale_string(total_constant_bytes)
<< " bytes in " << total_constant_count << " constants\n";
cout << "Total Parameter size: " << locale_string(total_parameter_bytes)
<< " bytes in " << total_parameter_count << " parameters\n";
cout << "Total Result size: " << locale_string(total_result_bytes) << " bytes in "
<< total_result_count << " results\n";
cout << "Total Temporary size: " << locale_string(total_temporary_bytes)
<< " bytes in " << total_temporary_count << " temporaries\n";
cout << "Temporary size with reuse : "
<< locale_string(f->get_temporary_pool_size()) << " bytes\n";
cout << "--\n";
cout << "Types used:\n";
for (const string& type : type_list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment