Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

update tests for grad_req change #134

Merged
merged 1 commit into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ngraph/ngraph_nnvm_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <functional>
#include <vector>

#include <mxnet/op_attr_types.h>
#include "ngraph_sgcompiler_utils.h"

namespace ngraph_bridge {
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp/ngraph/test_ngraph_imperative.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TEST_F(NGRAPH_IMPERATIVE, INVOKE_OP) {
EXPECT_TRUE(op_ng);
EXPECT_TRUE(test.op_ngraph_->ngraph_forward);
EXPECT_EQ(vec3, std::vector<float>({0, 0}));
compute_forward(opctx, op_ng, inputs, outputs);
compute_forward(opctx, op_ng, inputs, req, outputs);
EXPECT_EQ(vec3, std::vector<float>({2, 6}));
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cpp/ngraph/test_ngraph_imperative.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "../../src/ngraph/ngraph_imperative.h"
#include "../../src/ngraph/ngraph_nnvm_utils.h"
#include "test_util.h"

namespace ngraph_bridge {

class NGRAPH_IMPERATIVE : public ::testing::Test {
Expand All @@ -39,6 +40,7 @@ class NGRAPH_IMPERATIVE : public ::testing::Test {
std::vector<float> vec3{0, 0};
std::vector<mxnet::TBlob> inputs;
std::vector<mxnet::TBlob> outputs;
std::vector<mxnet::OpReqType> req{mxnet::kWriteTo};
};

class testImperative : public NGImperative {
Expand Down
11 changes: 7 additions & 4 deletions tests/cpp/ngraph/test_ngraph_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,20 @@ TEST(NGRAPH_NNVM, copy_TBlobs) {
/* placeholders[1]) */
/* ->get_vector<float>()); */
std::vector<float> vec3{0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
std::vector<float> vec4{0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
std::vector<float> vec4{1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
mxnet::TBlob TBlob3(vec3.data(), shape, 0);
mxnet::TBlob TBlob4(vec4.data(), shape, 0);
std::vector<mxnet::TBlob> outblobs;
outblobs.push_back(TBlob3);
outblobs.push_back(TBlob4);

result_to_TBlob(placeholders[0], outblobs, 0);
result_to_TBlob(placeholders[1], outblobs, 1);
// test 1: kWriteTo - vec3 = vec1
// test 2: kAddTo - vec4 += vec2
std::vector<mxnet::OpReqType> req{mxnet::kWriteTo, mxnet::kAddTo};
result_to_TBlob(placeholders, req, outblobs);
EXPECT_EQ(vec1, vec3);
EXPECT_EQ(vec2, vec4);
std::vector<float> vec4_plus_vec2{12, 13, 14, 15, 16, 17, 18, 19, 20, 11};
EXPECT_EQ(vec4_plus_vec2, vec4);
}

} // namespace ngraph_bridge