Skip to content

Commit

Permalink
resolve inference_pass_test input lodtensor case, test=develop (#25541)
Browse files Browse the repository at this point in the history
* refine infer ir pass tests, test=develop

* commit to change copy_from_cpu input to np array, test=develop
  • Loading branch information
OliverLPH authored Jul 17, 2020
1 parent 0d8545f commit 885e885
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def _get_analysis_outputs(self, config):
shape = tensor_shapes[name]
shape[0] = 1
tensor = predictor.get_input_tensor(name)
tensor.copy_from_cpu(list(self.feeds.values())[i])
feed_data = list(self.feeds.values())[i]
tensor.copy_from_cpu(np.array(feed_data))
if type(feed_data) == fluid.LoDTensor:
tensor.set_lod(feed_data.lod())

predictor.zero_copy_run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def setUp(self):

def test_check_output(self):
if core.is_compiled_with_cuda():
self.check_output_with_option([True])
use_gpu = True
self.check_output_with_option(use_gpu)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def setUp(self):

def test_check_output(self):
if core.is_compiled_with_cuda():
self.check_output_with_option([True])
use_gpu = True
self.check_output_with_option(use_gpu)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def setUp(self):

def test_check_output(self):
if core.is_compiled_with_cuda():
self.check_output_with_option([True])
use_gpu = True
self.check_output_with_option(use_gpu)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def setUp(self):
def test_check_output(self):
# There is no cpu pass for transpose_flatten_concat_fuse
if core.is_compiled_with_cuda():
self.check_output_with_option([True])
use_gpu = True
self.check_output_with_option(use_gpu)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def setUp(self):
def test_check_output(self):
# There is no cpu pass for transpose_flatten_concat_fuse
if core.is_compiled_with_cuda():
self.check_output_with_option([True])
use_gpu = True
self.check_output_with_option(use_gpu)


if __name__ == "__main__":
Expand Down

0 comments on commit 885e885

Please sign in to comment.