Skip to content

Commit

Permalink
Merge pull request #1824 from hedaoyuan/fix_1769
Browse files Browse the repository at this point in the history
Fix ContextProjectionOpTest
  • Loading branch information
luotao1 authored Apr 20, 2017
2 parents 6d6804f + c4ceefa commit 6b058ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 15 additions & 13 deletions paddle/function/ContextProjectionOpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ void testMatrixProjectionForward(int context_start,
std::max(0, (int)(context_start + context_length - 1));
if (pad == 0) is_padding = false;

FunctionCompare test("ContextProjectionForward",
FuncConfig()
.set("context_length", context_length)
.set("context_start", context_start)
.set("begin_pad", std::max(0, -context_start)));
FunctionCompare test(
"ContextProjectionForward",
FuncConfig()
.set("context_length", context_length)
.set("context_start", context_start)
.set("begin_pad", (size_t)std::max(0, -context_start)));

// prepare input arguments
test.addSequence(SequenceIdArg(TensorShape{batch_size}));
Expand All @@ -51,21 +52,22 @@ void testMatrixProjectionForward(int context_start,
}

void testMatrixProjectionBackward(int context_start,
int context_length,
size_t context_length,
bool is_padding,
size_t batch_size,
size_t input_dim) {
size_t pad = std::max(0, -context_start) +
std::max(0, (int)(context_start + context_length - 1));
if (pad == 0) is_padding = false;

FunctionCompare test("ContextProjectionBackward",
FuncConfig()
.set("context_length", context_length)
.set("context_start", context_start)
.set("begin_pad", std::max(0, -context_start))
.set("is_padding", is_padding)
.set("total_pad", pad));
FunctionCompare test(
"ContextProjectionBackward",
FuncConfig()
.set("context_length", context_length)
.set("context_start", context_start)
.set("begin_pad", (size_t)std::max(0, -context_start))
.set("is_padding", is_padding)
.set("total_pad", pad));

// prepare input arguments
test.addSequence(SequenceIdArg(TensorShape{batch_size}));
Expand Down
4 changes: 3 additions & 1 deletion paddle/math/tests/test_matrixCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ TEST(Matrix, unary) {
testMatrixTranspose(height, width);
testMatrixRotate(height, width);
}
// inverse
// inverse
#ifdef PADDLE_USE_LAPACK
testMatrixInverse(height);
#endif
}
}

Expand Down

0 comments on commit 6b058ea

Please sign in to comment.