Skip to content

Commit 6b058ea

Browse files
authored
Merge pull request #1824 from hedaoyuan/fix_1769
Fix ContextProjectionOpTest
2 parents 6d6804f + c4ceefa commit 6b058ea

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

paddle/function/ContextProjectionOpTest.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ void testMatrixProjectionForward(int context_start,
2828
std::max(0, (int)(context_start + context_length - 1));
2929
if (pad == 0) is_padding = false;
3030

31-
FunctionCompare test("ContextProjectionForward",
32-
FuncConfig()
33-
.set("context_length", context_length)
34-
.set("context_start", context_start)
35-
.set("begin_pad", std::max(0, -context_start)));
31+
FunctionCompare test(
32+
"ContextProjectionForward",
33+
FuncConfig()
34+
.set("context_length", context_length)
35+
.set("context_start", context_start)
36+
.set("begin_pad", (size_t)std::max(0, -context_start)));
3637

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

5354
void testMatrixProjectionBackward(int context_start,
54-
int context_length,
55+
size_t context_length,
5556
bool is_padding,
5657
size_t batch_size,
5758
size_t input_dim) {
5859
size_t pad = std::max(0, -context_start) +
5960
std::max(0, (int)(context_start + context_length - 1));
6061
if (pad == 0) is_padding = false;
6162

62-
FunctionCompare test("ContextProjectionBackward",
63-
FuncConfig()
64-
.set("context_length", context_length)
65-
.set("context_start", context_start)
66-
.set("begin_pad", std::max(0, -context_start))
67-
.set("is_padding", is_padding)
68-
.set("total_pad", pad));
63+
FunctionCompare test(
64+
"ContextProjectionBackward",
65+
FuncConfig()
66+
.set("context_length", context_length)
67+
.set("context_start", context_start)
68+
.set("begin_pad", (size_t)std::max(0, -context_start))
69+
.set("is_padding", is_padding)
70+
.set("total_pad", pad));
6971

7072
// prepare input arguments
7173
test.addSequence(SequenceIdArg(TensorShape{batch_size}));

paddle/math/tests/test_matrixCompare.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ TEST(Matrix, unary) {
235235
testMatrixTranspose(height, width);
236236
testMatrixRotate(height, width);
237237
}
238-
// inverse
238+
// inverse
239+
#ifdef PADDLE_USE_LAPACK
239240
testMatrixInverse(height);
241+
#endif
240242
}
241243
}
242244

0 commit comments

Comments
 (0)