未验证 提交 e0d8b8f5 编写于 作者: L Li Fuchen 提交者: GitHub

use large input size in test_add_position_encoding_op.py (#21962)

* use large input size in test_add_position_encoding_op.py, test=develop

* revert shape_white_list, test=develop
上级 362bfec5
......@@ -53,7 +53,7 @@ class TestAddPositionEncodingTensorOp(OpTest):
"""
self.alpha = 0.6
self.beta = 0.5
self.x = np.random.uniform(0.1, 1, [2, 4, 4]).astype(self.dtype)
self.x = np.random.uniform(0.1, 1, [2, 15, 4]).astype(self.dtype)
self.out = np.copy(self.x)
batch_size = self.x.shape[0]
......@@ -64,7 +64,7 @@ class TestAddPositionEncodingTensorOp(OpTest):
for i in range(batch_size):
for j in range(max_length):
for k in range(half_shape):
val = j / pow(10000.0, k / (
val = j / pow(10000.0, k * 1.0 / (
half_shape - 1)) if half_shape > 1 else j / 10000.0
self.out[i, j, k] = \
self.x[i, j, k] * self.alpha + math.sin(val) * self.beta
......@@ -107,8 +107,8 @@ class TestAddPositionEncodingLoDTensorOp(OpTest):
"""
self.alpha = 0.6
self.beta = 0.5
self.x = np.random.uniform(0.1, 1, [10, 4]).astype(self.dtype)
self.lod = [[3, 7]]
self.x = np.random.uniform(0.1, 1, [20, 6]).astype(self.dtype)
self.lod = [[13, 7]]
self.out = np.copy(self.x)
batch_size = len(self.lod[0])
......@@ -120,7 +120,7 @@ class TestAddPositionEncodingLoDTensorOp(OpTest):
max_length = self.lod[0][i]
for j in range(max_length):
for k in range(half_shape):
val = j / pow(10000.0, k / (
val = j / pow(10000.0, k * 1.0 / (
half_shape - 1)) if half_shape > 1 else j / 10000.0
pos = start + j
self.out[pos, k] = \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册