Skip to content

Commit 3aa01ea

Browse files
committed
Fix ContextProjectionOpTest
1 parent 6d6804f commit 3aa01ea

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
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}));

0 commit comments

Comments
 (0)