Skip to content

Commit

Permalink
Update ENABLE_OPENVINO_DEBUG macro (#25473)
Browse files Browse the repository at this point in the history
### Details:
According to the testing, this PR reduces LoadTIme of LLMs (llama2,
llama3, qwen) to 7 - 16%

 - update OPENVINO_DEBUG, _ERR, _WARN, _INFO macros
 - fix OPENVINO_DEBUG, _ERR, _WARN, _INFO macros in all OpenVINO

### Tickets:
 - 143185
  • Loading branch information
evkotov committed Jul 11, 2024
1 parent 4a40acd commit 70a8ab6
Show file tree
Hide file tree
Showing 73 changed files with 441 additions and 268 deletions.
2 changes: 1 addition & 1 deletion src/bindings/python/src/pyopenvino/graph/node_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NodeFactory {
"Currently NodeFactory doesn't support Constant node: ",
op_type_name);

OPENVINO_WARN << "Empty op created! Please assign inputs and attributes and run validate() before op is used.";
OPENVINO_WARN("Empty op created! Please assign inputs and attributes and run validate() before op is used.");

return op_node;
}
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/python/src/pyopenvino/graph/ops/if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void regclass_graph_op_If(py::module m) {
if (MultiSubgraphHelpers::is_constant_or_parameter(execution_condition)) {
return std::make_shared<ov::op::v8::If>(execution_condition->output(0));
} else {
OPENVINO_WARN << "Please specify execution_condition as Constant or Parameter. Default If() "
"constructor was applied.";
OPENVINO_WARN("Please specify execution_condition as Constant or Parameter. Default If() "
"constructor was applied.");
return std::make_shared<ov::op::v8::If>();
}
}),
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ bool AddTransformation::transform(TransformationContext& context, ov::pass::patt
NetworkHelper::foldDequantization(node, fullPathIndex, defaultPrecisions);
}

OPENVINO_DEBUG << "LPT: done: " << newAddOrSubtract;
OPENVINO_DEBUG("LPT: done: ", newAddOrSubtract);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/avg_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool AvgPoolTransformation::transform(TransformationContext& context, ov::pass::
const bool updatePrecision = isPrecisionPreserved(pooling);
const auto newOperation = moveDequantizationAfter(context, pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions), updatePrecision);

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool BatchToSpaceTransformation::transform(TransformationContext& context, ov::p
const std::shared_ptr<Node> op = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool ClampTransformation::transform(TransformationContext& context, ov::pass::pa
dequantization.subtract->get_output_element_type(0);
ov::pass::low_precision::NetworkHelper::setOutDataPrecision(replacement, outputClampType);

OPENVINO_DEBUG << "LPT: done: " << replacement;
OPENVINO_DEBUG("LPT: done: ", replacement);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/concat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool ConcatTransformation::transform(TransformationContext& context, ov::pass::p
NetworkHelper::copyInfo(concat, newConcat);
updateOutput(context, lastDequantization, newConcat);

OPENVINO_DEBUG << "LPT: done: " << newConcat;
OPENVINO_DEBUG("LPT: done: ", newConcat);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool ConvertTransformation::transform(TransformationContext& context, ov::pass::

subtract->set_friendly_name(convert->get_friendly_name());

OPENVINO_DEBUG << "LPT: done: " << subtract;
OPENVINO_DEBUG("LPT: done: ", subtract);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ bool ConvolutionTransformation::transform(TransformationContext &context, ov::pa
ov::disable_constant_folding(onWeights);
}

OPENVINO_DEBUG << "LPT: done: " << convolution;
OPENVINO_DEBUG("LPT: done: ", convolution);
return true;
}
} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ bool ConvolutionBackpropDataTransformation::transform(TransformationContext &con
ov::disable_constant_folding(onWeights);
}

OPENVINO_DEBUG << "LPT: done: " << convolutionBackpropData;
OPENVINO_DEBUG("LPT: done: ", convolutionBackpropData);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ bool FakeQuantizeDecompositionTransformation::transform(TransformationContext& c
precisionsAttribute.value() = { dataPrecision.precision };
}

OPENVINO_DEBUG << "LPT: done: " << newFakeQuantize;
OPENVINO_DEBUG("LPT: done: ", newFakeQuantize);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool GatherTransformation::transform(TransformationContext& context, ov::pass::p

const auto newOperation = moveDequantizationAfter(context, gather, NetworkHelper::getDequantization(gather, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool InterpolateTransformation::transform(TransformationContext &context, ov::pa
interpolate = NetworkHelper::separateInStandaloneBranch(interpolate, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, interpolate, NetworkHelper::getDequantization(interpolate, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ bool LayerTransformation::canBeTransformedStatic(const std::shared_ptr<Node>& la

bool LayerTransformation::canBeTransformedSpatialDimension(const TransformationContext& context, std::shared_ptr<Node> layer) const {
if (!isQuantized(layer, defaultPrecisions)) {
OPENVINO_DEBUG << "LPT: early exit: not quantized";
OPENVINO_DEBUG("LPT: early exit: not quantized");
return false;
}
const auto outputs = layer->outputs();
if (std::any_of(outputs.begin(), outputs.end(),
[](const Output<Node>& out) { return out.get_partial_shape().rank().is_dynamic(); })) {
OPENVINO_DEBUG << "LPT: early exit: rank is dynamic";
OPENVINO_DEBUG("LPT: early exit: rank is dynamic");
return false;
}
return true;
Expand Down Expand Up @@ -479,10 +479,10 @@ void LayerTransformation::addPattern(ov::pass::GraphRewrite& pass, Transformatio
m->get_name(),
m,
[m, internal_callback](const std::shared_ptr<Node>& node) -> bool {
OPENVINO_DEBUG << "Running matcher " << m->get_name() << " on " << node;
OPENVINO_DEBUG("Running matcher ", m->get_name(), " on ", node);
OV_PASS_CALLBACK(m);
if (std::dynamic_pointer_cast<ov::pass::pattern::Matcher>(m)->match(node->output(0))) {
OPENVINO_DEBUG << "Matcher " << m->get_name() << " matched " << node;
OPENVINO_DEBUG("Matcher ", m->get_name(), " matched ", node);
bool status = internal_callback(*m.get());
// explicitly clear Matcher state because it holds pointers to matched nodes
m->clear_state();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ void make_matcher_type_relaxed(ov::pass::GraphRewrite* transformation) {
m->get_name(),
m,
[m, callback](const std::shared_ptr<Node>& node) -> bool {
OPENVINO_DEBUG << "Running matcher " << m->get_name() << " on " << node;
OPENVINO_DEBUG("Running matcher ", m->get_name(), " on ", node);
if (std::dynamic_pointer_cast<ov::pass::pattern::Matcher>(m)->match(node->output(0))) {
OPENVINO_DEBUG << "Matcher " << m->get_name() << " matched " << node;
OPENVINO_DEBUG("Matcher ", m->get_name(), " matched ", node);
OV_PASS_CALLBACK(m);
bool status = callback(*m.get());
// explicitly clear Matcher state because it holds pointers to matched nodes
Expand Down
6 changes: 3 additions & 3 deletions src/common/low_precision_transformations/src/mat_mul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool MatMulTransformation::transform(TransformationContext &context, ov::pass::p

updateOutput(context, newMultiply, newMatMul);

OPENVINO_DEBUG << "LPT: done: " << newMatMul;
OPENVINO_DEBUG("LPT: done: ", newMatMul);
return true;
}

Expand All @@ -191,14 +191,14 @@ bool MatMulTransformation::canBeTransformed(const TransformationContext& context

std::shared_ptr<ov::opset1::MatMul> matMul = ov::as_type_ptr<ov::opset1::MatMul>(layer);
if (matMul == nullptr) {
OPENVINO_DEBUG << "LPT: early exit: not MatMul";
OPENVINO_DEBUG("LPT: early exit: not MatMul");
return false;
}

const auto dequantization1 = NetworkHelper::getDequantization(layer, defaultPrecisions, 0);
if (!dequantization1.empty()) {
if (updatePrecisions && !dequantization1.isLowPrecision()) {
OPENVINO_DEBUG << "LPT: early exit: dequantization before is not in low precision";
OPENVINO_DEBUG("LPT: early exit: dequantization before is not in low precision");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/max_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool MaxPoolTransformation::transform(TransformationContext& context, ov::pass::
const std::shared_ptr<Node> pooling = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool MultiplyPartialTransformation::transform(TransformationContext& context, ov
NetworkHelper::foldDequantization(newMultiply, fullPathIndex, defaultPrecisions);
}

OPENVINO_DEBUG << "LPT: done: " << newMultiply;
OPENVINO_DEBUG("LPT: done: ", newMultiply);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/mvn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool MVNTransformation::transform(TransformationContext &context, ov::pass::patt

updateOutput(context, newMultiply, newMVN);

OPENVINO_DEBUG << "LPT: done: " << newMVN;
OPENVINO_DEBUG("LPT: done: ", newMVN);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ bool NormalizeL2Transformation::transform(TransformationContext &context, ov::pa

updateOutput(context, newMultiply, newNormalize);

OPENVINO_DEBUG << "LPT: done: " << newNormalize;
OPENVINO_DEBUG("LPT: done: ", newNormalize);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ bool PadTransformation::transform(TransformationContext& context, ov::pass::patt

const auto newOperation = moveDequantizationAfter(context, pad, dequantization);

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/prelu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool PReluTransformation::transform(TransformationContext& context, ov::pass::pa
const FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(prelu, defaultPrecisions, 0);
const auto newOperation = moveDequantizationAfter(context, prelu, dequantization, false, false);

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool ReduceBaseTransformation::transform(TransformationContext& context, ov::pas
const bool updatePrecision = getUpdatePrecision(reduce);
const auto newOperation = moveDequantizationAfter(context, reduce, dequantization, updatePrecision);

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/relu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool ReluTransformation::transform(TransformationContext& context, ov::pass::pat
const FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(relu, defaultPrecisions, 0);
const auto newOperation = moveDequantizationAfter(context, relu, dequantization);

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ bool ReshapeTransformation::transform(TransformationContext& context, ov::pass::
reshapeDequantizationConstant(reshape, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, reshape, NetworkHelper::getDequantization(reshape, defaultPrecisions, 0));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool ShuffleChannelsTransformation::transform(TransformationContext& context, ov

const auto newOperation = moveDequantizationAfter(context, shuffleChannels, dequantization);

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool SpaceToBatchTransformation::transform(TransformationContext& context, ov::p
const std::shared_ptr<Node> op = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool SplitTransformation::transform(TransformationContext& context, ov::pass::pa

updateOutputs(context, lastNodes, newSplit);

OPENVINO_DEBUG << "LPT: done: " << newSplit;
OPENVINO_DEBUG("LPT: done: ", newSplit);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/squeeze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool SqueezeTransformation::transform(TransformationContext& context, ov::pass::

const auto newOperation = moveDequantizationAfter(context, squeeze, NetworkHelper::getDequantization(squeeze, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool StridedSliceTransformation::transform(TransformationContext& context, ov::p

const auto newOperation = moveDequantizationAfter(context, strided_slice, NetworkHelper::getDequantization(strided_slice, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool TransparentBaseTransformation::transform(TransformationContext& context, ov
op = NetworkHelper::separateInStandaloneBranch(op, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool TransposeTransformation::transform(TransformationContext& context, ov::pass
transposeDequantizationConstant(transpose, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, transpose, NetworkHelper::getDequantization(transpose, defaultPrecisions, 0));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/unsqueeze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool UnsqueezeTransformation::transform(TransformationContext& context, ov::pass

const auto newOperation = moveDequantizationAfter(context, unsqueeze, NetworkHelper::getDequantization(unsqueeze, defaultPrecisions));

OPENVINO_DEBUG << "LPT: done: " << newOperation;
OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/common/offline_transformations/include/mask_attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ class Mask : public std::vector<std::set<uint64_t>>, public std::enable_shared_f
}

bool add_callback(const std::function<bool(Mask::Ptr)>& receive_callback, Mask::Ptr mask) {
#ifdef ENABLE_OPENVINO_DEBUG
if (m_callbacks.find(mask.get()) != m_callbacks.end())
OPENVINO_DEBUG << "Attempt to rewrite callback, could lead to unexpected behaviour";

OPENVINO_DEBUG("Attempt to rewrite callback, could lead to unexpected behaviour");
#endif
m_callbacks[mask.get()] = receive_callback;
m_dependencies.push_back(mask.get());
return true;
Expand Down
15 changes: 10 additions & 5 deletions src/common/offline_transformations/src/pruning/init_const_mask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ ov::pass::InitConstMask::InitConstMask(const ov::AxisSet& dims,

for (const auto& dim : dims) {
if (dim >= shape.size()) {
OPENVINO_DEBUG << "[WARNING] Attempt to initialize masks on " << dim
<< " dimension which is out of shape " << shape << " for node ("
<< const_node->get_friendly_name() << ")";
OPENVINO_DEBUG("[WARNING] Attempt to initialize masks on ",
dim,
" dimension which is out of shape ",
shape,
" for node (",
const_node->get_friendly_name(),
")");
continue;
}

Expand Down Expand Up @@ -61,10 +65,11 @@ ov::pass::InitConstMask::InitConstMask(const ov::AxisSet& dims,
setMask(const_node, mask);
#ifdef ENABLE_OPENVINO_DEBUG
setInitMask(const_node, mask);
#endif

if (!mask->all_dims_are_empty()) {
OPENVINO_DEBUG << "MASK (" << const_node->get_friendly_name() << ") " << *mask << std::endl;
OPENVINO_DEBUG("MASK (", const_node->get_friendly_name(), ") ", *mask, "\n");
}
#endif

return false;
};
Expand Down
Loading

0 comments on commit 70a8ab6

Please sign in to comment.