Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
eshoguli committed Sep 27, 2023
1 parent 4ca8561 commit 906f45e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/include/openvino/core/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class OPENVINO_API Model : public std::enable_shared_from_this<Model> {
return get_type_info_static();
}

static std::shared_ptr<Model> global_model;

Model(const ov::NodeVector& results, const ov::ParameterVector& parameters, const std::string& name = "");

Model(const ov::OutputVector& results, const ov::ParameterVector& parameters, const std::string& name = "");
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const std::shared_ptr<ov::Node>& verify_node(const std::shared_ptr<ov::Node>& no

} // namespace

std::shared_ptr<ov::Model> ov::Model::global_model;

ov::Model::Model(const ResultVector& results, const ov::ParameterVector& parameters, const std::string& name)
: m_name(name),
m_unique_name("Model" + to_string(m_next_instance_id.fetch_add(1))),
Expand Down
1 change: 1 addition & 0 deletions src/core/src/pass/graph_rewrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ bool ov::pass::GraphRewrite::apply_matcher_passes(std::shared_ptr<Model> f,

// Apply MatcherPass. In case if it returns true no other MatcherPasses will apply
// to this node
ov::Model::global_model = f;
bool status = m_pass->apply(node);

// In case if MatcherPass registered nodes they will be added to the beginning of execution
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_cpu/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ Engine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, const std
auto nGraphFunc = clonedNetwork.getFunction();
Config::ModelType modelType = getModelType(nGraphFunc);
ov::element::Type inferencePrecision = getInferencePrecision(config, engConfig, modelType);
const Config::SnippetsMode snippetsMode = getSnippetsMode(config, engConfig);
const Config::SnippetsMode snippetsMode = getSnippetsMode(config, engConfig);

DEBUG_LOG(PrintableModel(*nGraphFunc, "org_"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
#include "low_precision/convolution_backprop_data.hpp"
#include "low_precision/group_convolution.hpp"
#include "low_precision/multiply_to_group_convolution.hpp"
#include "low_precision/multiply.hpp"
#include "low_precision/multiply_partial.hpp"
#include "low_precision/recurrent_cell.hpp"
#include "low_precision/network_helper.hpp"
#include "low_precision/rt_info/bias_attribute.hpp"
Expand Down Expand Up @@ -123,6 +125,9 @@
#include "dnnl.hpp"
#include <cpu/x64/cpu_isa_traits.hpp>

#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/pass/serialize.hpp"

namespace ov {
namespace intel_cpu {

Expand Down Expand Up @@ -175,6 +180,9 @@ void Transformations::UpToLpt() {
}
}

ngraph::pass::Serialize("svg/cpu.original.xml", "svg/cpu.original.bin").run_on_model(model);
ngraph::pass::VisualizeTree("svg/cpu.original.svg").run_on_model(model);

PreLpt(defaultPrecisions, isLegacyApi);

if (useLpt)
Expand Down Expand Up @@ -438,6 +446,9 @@ void Transformations::PreLpt(const std::vector<ov::element::Type>& defaultPrecis
}

void Transformations::Lpt(const bool hasINT16orINT32Levels, const std::vector<ov::element::Type>& defaultPrecisions) {
ngraph::pass::Serialize("svg/cpu.pre_lpt.xml", "svg/cpu.pre_lpt.bin").run_on_model(model);
ngraph::pass::VisualizeTree("svg/cpu.pre_lpt.svg").run_on_model(model);

CPU_DEBUG_CAP_TRANSFORMATION_SCOPE(this, Lpt);

using namespace ov::pass::low_precision;
Expand Down Expand Up @@ -503,10 +514,15 @@ void Transformations::Lpt(const bool hasINT16orINT32Levels, const std::vector<ov
}

ov::pass::Manager lptManager;
CPU_REGISTER_PASS_COMMON(lptManager, ov::pass::low_precision::LowPrecision,

auto lowPrecisionPass = CPU_REGISTER_PASS_COMMON(lptManager, ov::pass::low_precision::LowPrecision,
supportedPrecisions,
quantizationRestrictions,
LayerTransformation::Params(updatePrecision, ov::element::f32, defaultPrecisions));

auto lowPrecision = std::dynamic_pointer_cast<ov::pass::low_precision::LowPrecision>(lowPrecisionPass);
lowPrecision->add_main<ov::pass::low_precision::MultiplyTransformation>();

CPU_SET_CALLBACK_COMMON(lptManager,
[](const_node_ptr& node) -> bool {
if (const auto mulitply = std::dynamic_pointer_cast<const ov::opset1::Multiply>(node)) {
Expand All @@ -529,8 +545,12 @@ void Transformations::Lpt(const bool hasINT16orINT32Levels, const std::vector<ov

CPU_DISABLE_PASS_ARM(lptManager, ov::pass::low_precision::RecurrentCellTransformation);
CPU_DISABLE_PASS_COMMON(lptManager, ov::pass::low_precision::MultiplyToGroupConvolutionTransformation);
CPU_DISABLE_PASS_COMMON(lptManager, ov::pass::low_precision::MultiplyPartialTransformation);

lptManager.run_passes(model);

ngraph::pass::Serialize("svg/cpu.lpt.xml", "svg/cpu.lpt.bin").run_on_model(model);
ngraph::pass::VisualizeTree("svg/cpu.lpt.svg").run_on_model(model);
}

void Transformations::PostLpt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const std::vector<ngraph::element::Type> netPrecisions = {
const auto precision_for_fused_cases = ov::element::undefined;

const std::vector<LayerTestsDefinitions::MultiplyTestValues> params = {
{
false,
{ 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -1.28f }, { 2.55f }, { -1.28f }, { 2.55f } },
false,
{ 256ul, ngraph::Shape {}, { -1.28f }, { 1.27f }, { -1.28f }, { 1.27f } },
{ 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -1.28f }, { 1.27f }, { -1.28f }, { 1.27f } },
precision_for_fused_cases,
true
},
{
false,
{ 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 2.55f }, { 0.f }, { 2.55f } },
Expand Down

0 comments on commit 906f45e

Please sign in to comment.