Commit 75fadde5 authored by Amy Zhuang's avatar Amy Zhuang Committed by Scott Cyphers

Fix debugger tests crash for CODEGEN. (#2582)

* Fix debugger tests crash for CODEGEN.

* Address PR feedback.

* Expect exception for CODEGEN.

* Address PR feedback.
parent b0903fe8
...@@ -129,8 +129,16 @@ bool runtime::cpu::CPU_Debugger::delete_breakpoint(std::shared_ptr<Node> op) ...@@ -129,8 +129,16 @@ bool runtime::cpu::CPU_Debugger::delete_breakpoint(std::shared_ptr<Node> op)
void* runtime::cpu::CPU_Debugger::inspect(std::shared_ptr<Node> op, size_t output_index) void* runtime::cpu::CPU_Debugger::inspect(std::shared_ptr<Node> op, size_t output_index)
{ {
if (m_callframe.m_external_function->is_direct_execution())
{
return m_callframe.m_external_function->get_tensor_data(op->get_name() + "_" + return m_callframe.m_external_function->get_tensor_data(op->get_name() + "_" +
to_string(output_index)); to_string(output_index));
}
else
{
return m_callframe.m_external_function->tensor_data.at(op->get_name() + "_" +
to_string(output_index));
}
} }
bool runtime::cpu::CPU_Debugger::add_tracepoint( bool runtime::cpu::CPU_Debugger::add_tracepoint(
......
...@@ -38,8 +38,26 @@ ...@@ -38,8 +38,26 @@
using namespace ngraph; using namespace ngraph;
using namespace std; using namespace std;
bool static is_codegen_mode()
{
if (std::getenv("NGRAPH_CODEGEN") != nullptr &&
std::string(std::getenv("NGRAPH_CODEGEN")) != "0")
{
return true;
}
return false;
}
// These tests are for DEX mode only.
TEST(debugger, add_breakpoint) TEST(debugger, add_breakpoint)
{ {
if (is_codegen_mode())
{
//TODO change to skip when there is a new release of gtest
NGRAPH_WARN << "This test is skipped for CODEGEN mode.";
return;
}
Shape shape{}; Shape shape{};
auto A = make_shared<op::Parameter>(element::i32, shape); auto A = make_shared<op::Parameter>(element::i32, shape);
auto B = make_shared<op::Parameter>(element::i32, shape); auto B = make_shared<op::Parameter>(element::i32, shape);
...@@ -68,6 +86,7 @@ TEST(debugger, add_breakpoint) ...@@ -68,6 +86,7 @@ TEST(debugger, add_breakpoint)
dbg.add_breakpoint(neg); dbg.add_breakpoint(neg);
dbg.call({result}, {a, b}); dbg.call({result}, {a, b});
ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777);
ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777);
dbg.step(); dbg.step();
...@@ -76,6 +95,13 @@ TEST(debugger, add_breakpoint) ...@@ -76,6 +95,13 @@ TEST(debugger, add_breakpoint)
TEST(debugger, stepping) TEST(debugger, stepping)
{ {
if (is_codegen_mode())
{
//TODO change to skip when there is a new release of gtest
NGRAPH_WARN << "This test is skipped for CODEGEN mode.";
return;
}
Shape shape{}; Shape shape{};
auto A = make_shared<op::Parameter>(element::i32, shape); auto A = make_shared<op::Parameter>(element::i32, shape);
auto B = make_shared<op::Parameter>(element::i32, shape); auto B = make_shared<op::Parameter>(element::i32, shape);
...@@ -104,6 +130,7 @@ TEST(debugger, stepping) ...@@ -104,6 +130,7 @@ TEST(debugger, stepping)
dbg.add_breakpoint(add); dbg.add_breakpoint(add);
dbg.call({result}, {a, b}); dbg.call({result}, {a, b});
ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777);
dbg.step(); dbg.step();
ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777);
...@@ -113,6 +140,13 @@ TEST(debugger, stepping) ...@@ -113,6 +140,13 @@ TEST(debugger, stepping)
TEST(debugger, delete_breakpoint) TEST(debugger, delete_breakpoint)
{ {
if (is_codegen_mode())
{
//TODO change to skip when there is new release of gtest
NGRAPH_WARN << "This test is skipped for CODEGEN mode.";
return;
}
Shape shape{}; Shape shape{};
auto A = make_shared<op::Parameter>(element::i32, shape); auto A = make_shared<op::Parameter>(element::i32, shape);
auto B = make_shared<op::Parameter>(element::i32, shape); auto B = make_shared<op::Parameter>(element::i32, shape);
...@@ -146,6 +180,7 @@ TEST(debugger, delete_breakpoint) ...@@ -146,6 +180,7 @@ TEST(debugger, delete_breakpoint)
dbg.delete_breakpoint(absn); dbg.delete_breakpoint(absn);
dbg.delete_breakpoint(neg); dbg.delete_breakpoint(neg);
dbg.call({result}, {a, b}); dbg.call({result}, {a, b});
ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777);
ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777);
ASSERT_EQ(*static_cast<int*>(dbg.inspect(neg)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(neg)), -777);
...@@ -153,6 +188,13 @@ TEST(debugger, delete_breakpoint) ...@@ -153,6 +188,13 @@ TEST(debugger, delete_breakpoint)
TEST(debugger, while_stepping) TEST(debugger, while_stepping)
{ {
if (is_codegen_mode())
{
//TODO change to skip when there is new release of gtest
NGRAPH_WARN << "This test is skipped for CODEGEN mode.";
return;
}
Shape shape{}; Shape shape{};
auto A = make_shared<op::Parameter>(element::i32, shape); auto A = make_shared<op::Parameter>(element::i32, shape);
auto B = make_shared<op::Parameter>(element::i32, shape); auto B = make_shared<op::Parameter>(element::i32, shape);
...@@ -184,6 +226,7 @@ TEST(debugger, while_stepping) ...@@ -184,6 +226,7 @@ TEST(debugger, while_stepping)
while (dbg.step()) while (dbg.step())
{ {
}; };
ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777);
ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777);
ASSERT_EQ(*static_cast<int*>(dbg.inspect(neg)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(neg)), -777);
...@@ -191,6 +234,13 @@ TEST(debugger, while_stepping) ...@@ -191,6 +234,13 @@ TEST(debugger, while_stepping)
TEST(debugger, resume) TEST(debugger, resume)
{ {
if (is_codegen_mode())
{
//TODO change to skip when there is new release of gtest
NGRAPH_WARN << "This test is skipped for CODEGEN mode.";
return;
}
Shape shape{}; Shape shape{};
auto A = make_shared<op::Parameter>(element::i32, shape); auto A = make_shared<op::Parameter>(element::i32, shape);
auto B = make_shared<op::Parameter>(element::i32, shape); auto B = make_shared<op::Parameter>(element::i32, shape);
...@@ -219,6 +269,7 @@ TEST(debugger, resume) ...@@ -219,6 +269,7 @@ TEST(debugger, resume)
dbg.add_breakpoint(absn); dbg.add_breakpoint(absn);
dbg.call({result}, {a, b}); dbg.call({result}, {a, b});
ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(add)), -777);
dbg.resume(); dbg.resume();
ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777); ASSERT_EQ(*static_cast<int*>(dbg.inspect(absn)), 777);
......
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