Commit df6a0cc2 authored by Yixing Lao's avatar Yixing Lao Committed by GitHub

Merge pull request #117 from NervanaSystems/yixing/namespace-collision

fix namespace collision in runtime test
parents 953b8c59 c92198fb
...@@ -22,15 +22,15 @@ ...@@ -22,15 +22,15 @@
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
using namespace ngraph::runtime; using namespace ngraph::runtime;
using namespace ngraph::runtime::eigen; namespace ngeigen = ngraph::runtime::eigen;
TEST(runtime, test_add) TEST(runtime, test_add)
{ {
auto x = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto x = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
*x = std::vector<float>{1, 2, 3, 4}; *x = std::vector<float>{1, 2, 3, 4};
auto y = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto y = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
*y = std::vector<float>{5, 6, 7, 8}; *y = std::vector<float>{5, 6, 7, 8};
auto z = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto z = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
add(*x, *y, *z); add(*x, *y, *z);
ASSERT_EQ((vector<float>{6, 8, 10, 12}), z->get_vector()); ASSERT_EQ((vector<float>{6, 8, 10, 12}), z->get_vector());
} }
...@@ -58,25 +58,26 @@ TEST(runtime, test_add_multiply) ...@@ -58,25 +58,26 @@ TEST(runtime, test_add_multiply)
// 4: t0 // 4: t0
auto instructions = make_shared<std::vector<std::shared_ptr<ngraph::runtime::Instruction>>>(); auto instructions = make_shared<std::vector<std::shared_ptr<ngraph::runtime::Instruction>>>();
// a + b -> t0 // a + b -> t0
instructions->push_back(make_shared<AddInstruction<element::Float32>>(0, 1, 4)); instructions->push_back(make_shared<ngeigen::AddInstruction<element::Float32>>(0, 1, 4));
// t0 * c -> result // t0 * c -> result
instructions->push_back(make_shared<MultiplyInstruction<element::Float32>>(4, 2, 3)); instructions->push_back(make_shared<ngeigen::MultiplyInstruction<element::Float32>>(4, 2, 3));
instructions->push_back(make_shared<ReturnInstruction>()); instructions->push_back(make_shared<ngeigen::ReturnInstruction>());
runtime::CallFrame cf{3, runtime::CallFrame cf{
1, 3,
PTVs{make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2})}, 1,
0, PTVs{make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2})},
instructions}; 0,
instructions};
// Create some tensors for input/output // Create some tensors for input/output
auto a = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto a = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
*a = vector<float>{1, 2, 3, 4}; *a = vector<float>{1, 2, 3, 4};
auto b = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto b = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
*b = vector<float>{5, 6, 7, 8}; *b = vector<float>{5, 6, 7, 8};
auto c = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto c = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
*c = vector<float>{9, 10, 11, 12}; *c = vector<float>{9, 10, 11, 12};
auto result = make_shared<PrimaryTensorView<element::Float32>>(Shape{2, 2}); auto result = make_shared<ngeigen::PrimaryTensorView<element::Float32>>(Shape{2, 2});
cf(PTVs{a, b, c}, PTVs{result}); cf(PTVs{a, b, c}, PTVs{result});
ASSERT_EQ((vector<float>{54, 80, 110, 144}), result->get_vector()); ASSERT_EQ((vector<float>{54, 80, 110, 144}), result->get_vector());
......
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