Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions test/legacy_test/test_cumsum_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import tempfile
import unittest

import numpy as np
Expand Down Expand Up @@ -515,8 +513,9 @@ def test_bad_x():
class TestTensorAxis(unittest.TestCase):
def setUp(self):
paddle.seed(2022)
self.temp_dir = tempfile.TemporaryDirectory()
self.save_path = os.path.join(self.temp_dir.name, 'tensor_axis_cumsum')
# self.temp_dir = tempfile.TemporaryDirectory()
# self.save_path = os.path.join(self.temp_dir.name, 'tensor_axis_cumsum')
self.save_path = "./tensor_axis_cumsum"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里后面还是用tempfile比较好吧

self.place = (
paddle.CUDAPlace(0)
if paddle.is_compiled_with_cuda()
Expand Down Expand Up @@ -608,12 +607,21 @@ def test_static(self):
load_program, _, _ = paddle.static.load_inference_model(
self.save_path, exe
)

self.assertEqual(
len(load_program.global_block().ops) + 1,
len(main_prog.global_block().ops),
)

self.assertEqual(
load_program.global_block().ops[8].name(), 'pd_op.cumsum'
)
infer_out = exe.run(
program=load_program,
feed={'x': np_x},
fetch_list=[load_program.global_block().ops[8].result(0)],
)
np.testing.assert_allclose(static_out[0], infer_out[0])


class TestCumSumOpFp16(unittest.TestCase):
@test_with_pir_api
Expand Down