提交 8f9bbc28 编写于 作者: T tangwei12

add unit test

上级 ca225868
......@@ -18,6 +18,9 @@ import unittest
import numpy as np
from op_test import OpTest
import paddle.fluid.core as core
from paddle.fluid.op import Operator
class TestFillConstantOp1(OpTest):
def setUp(self):
......@@ -47,5 +50,27 @@ class TestFillConstantOp2(OpTest):
self.check_output()
class TestFillConstantOpWithSelectedRows(OpTest):
def check_with_place(self, place):
scope = core.Scope()
# create Out Variable
out = scope.var('Out').get_selected_rows()
# create and run fill_constant_op operator
fill_constant_op = Operator(
"fill_constant", shape=[123, 92], value=3.8, Out='Out')
fill_constant_op.run(scope, place)
# get result from Out
result_array = np.array(out)
self.assertEqual(result_array, np.full((123, 92), 3.8))
def test_fill_constant_with_selected_rows(self):
places = [core.CPUPlace()]
# currently only support CPU
for place in places:
self.check_with_place(place)
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册