-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Add silent option to quantization script #17094
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an api mx.quantization.quantize_net, please make sure it's quite by default.
@@ -275,12 +275,15 @@ Graph QuantizeGraph(Graph &&src) { | |||
std::unordered_map<Node*, NodePtr> mirror_map; | |||
std::unordered_map<NodePtr, NodePtr> reverse_mirror_map; | |||
nnvm::NodeEntryMap<NodeEntry> mirror_entry_map; | |||
static int verbose = dmlc::GetEnv("MXNET_QUANTIZATION_VERBOSE", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use default = 0, in script you can set to 1 in non-quiet mode
DFSVisit(src.outputs, [&](const NodePtr& node) { | ||
NodePtr new_node = Node::Create(); | ||
// If the currently visited node needs quantization, insert a quantize op node before the | ||
// current node and replace the current node with the quantized version in the new graph. | ||
if (quantized_node_map.count(node)) { | ||
std::cout << node->attrs.name << " is quantized." << std::endl; | ||
if (verbose) { | ||
std::cout << node->attrs.name << " is quantized." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use LOG(INFO)
@@ -516,15 +520,20 @@ static inline void SetCalibTableForEntry( | |||
out_data_name = out_data_name.substr(prefix.size()); | |||
} | |||
const auto calib_table_iter = calib_table.find(out_data_name); | |||
static int verbose = dmlc::GetEnv("MXNET_QUANTIZATION_VERBOSE", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
<< " : min=" << calib_table_iter->second.first | ||
<< " max=" << calib_table_iter->second.second << std::endl; | ||
if (verbose) { | ||
std::cout << "Set calibration result to " << node->attrs.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG(INFO) instead of std::cout
@zhreshold Code is refactored to be quiet by default. Only when valid logger is passed, then log will be printed. So just make sure you don't pass a logger to this API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@ZhennanQin Please fix lint error before we can merge this change:
|
@zhreshold fixed. You can merge now. |
Description
As title.
The log looks like:
@pengzhao-intel @zhreshold @hetong007
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments