Commit bbf66498 authored by shssf's avatar shssf Committed by Scott Cyphers

IntelGPU backend: Add graph dump ability (#1925)

parent 4e08d9aa
...@@ -25,6 +25,7 @@ set(SRC ...@@ -25,6 +25,7 @@ set(SRC
intelgpu_op_softmax.cpp intelgpu_op_softmax.cpp
intelgpu_op_custom_func_call.cpp intelgpu_op_custom_func_call.cpp
code_writer.cpp code_writer.cpp
visualize_tree.cpp
) )
if (NGRAPH_INTELGPU_ENABLE) if (NGRAPH_INTELGPU_ENABLE)
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp" #include "ngraph/runtime/intelgpu/intelgpu_op_custom_kernels.hpp"
#include "ngraph/runtime/intelgpu/intelgpu_op_softmax.hpp" #include "ngraph/runtime/intelgpu/intelgpu_op_softmax.hpp"
#include "ngraph/runtime/intelgpu/intelgpu_tensor_view.hpp" #include "ngraph/runtime/intelgpu/intelgpu_tensor_view.hpp"
#include "ngraph/runtime/intelgpu/visualize_tree.hpp"
#include "ngraph/function.hpp" #include "ngraph/function.hpp"
#include "ngraph/node.hpp" #include "ngraph/node.hpp"
...@@ -328,6 +329,12 @@ runtime::intelgpu::IntelGPUBackend::IntelGPUBackend() ...@@ -328,6 +329,12 @@ runtime::intelgpu::IntelGPUBackend::IntelGPUBackend()
m_disable_backend_optimizations = true; m_disable_backend_optimizations = true;
} }
// Dumps the input Function into Graphviz format
if (getenv("NGRAPH_INTELGPU_DUMP_FUNCTION") != nullptr)
{
m_dump_graph_enable = true;
}
cldnn::engine_configuration cldnn_configuration(profiling); cldnn::engine_configuration cldnn_configuration(profiling);
ocl_engine = make_shared<cldnn::engine>(cldnn_configuration); ocl_engine = make_shared<cldnn::engine>(cldnn_configuration);
} }
...@@ -356,6 +363,11 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func) ...@@ -356,6 +363,11 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
cldnn::topology topology; cldnn::topology topology;
if (m_dump_graph_enable)
{
visualize_tree(func, "intelgpu_", "_orig");
}
if (!m_disable_backend_optimizations) if (!m_disable_backend_optimizations)
{ {
ngraph::pass::Manager pass_manager; ngraph::pass::Manager pass_manager;
...@@ -369,6 +381,11 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func) ...@@ -369,6 +381,11 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
pass_manager.register_pass<ngraph::pass::GetOutputElementElimination>(); pass_manager.register_pass<ngraph::pass::GetOutputElementElimination>();
pass_manager.run_passes(func); pass_manager.run_passes(func);
if (m_dump_graph_enable)
{
visualize_tree(func, "intelgpu_", "_opt");
}
} }
for (shared_ptr<Node> op : func->get_ops()) for (shared_ptr<Node> op : func->get_ops())
......
...@@ -82,5 +82,6 @@ private: ...@@ -82,5 +82,6 @@ private:
bool m_profile_enable = false; bool m_profile_enable = false;
long m_profile_lines_limit_count = 10; long m_profile_lines_limit_count = 10;
bool m_dump_graph_enable = false;
std::string delim = std::string(":"); std::string delim = std::string(":");
}; };
This diff is collapsed.
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/function.hpp"
namespace ngraph
{
namespace runtime
{
namespace intelgpu
{
// This function writes the input func into file in Graphviz format.
// On large graphs, the "dot" utility requires lot of time to visualize the input.
// Example: dot -Tpdf intelgpu_Function_0_orig.dot -o intelgpu_Function_0_orig.pdf
void visualize_tree(const std::shared_ptr<Function>& func,
const std::string& file_prefix,
const std::string& file_suffix);
}
}
}
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