From e8d633995ea6c0f1fddafd0d35f17de32493cb30 Mon Sep 17 00:00:00 2001 From: parap1uie-s Date: Mon, 24 Oct 2022 15:33:15 +0800 Subject: [PATCH] Fix hAPI bug of not compatible with LayerHook (#47001) (#47283) * Fix hAPI bug of not compatible with LayerHook --- python/paddle/hapi/model.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/python/paddle/hapi/model.py b/python/paddle/hapi/model.py index 3534614cce5..8dc5b347e2b 100644 --- a/python/paddle/hapi/model.py +++ b/python/paddle/hapi/model.py @@ -720,11 +720,9 @@ class DynamicGraphAdapter(object): **self._amp_custom_lists, level=self._amp_level): if self._nranks > 1: - outputs = self.ddp_model.forward( - *[to_variable(x) for x in inputs]) + outputs = self.ddp_model(*[to_variable(x) for x in inputs]) else: - outputs = self.model.network.forward( - *[to_variable(x) for x in inputs]) + outputs = self.model.network(*[to_variable(x) for x in inputs]) losses = self.model._loss(*(to_list(outputs) + labels)) losses = to_list(losses) @@ -759,7 +757,7 @@ class DynamicGraphAdapter(object): labels = labels or [] labels = [to_variable(l) for l in to_list(labels)] - outputs = self.model.network.forward(*[to_variable(x) for x in inputs]) + outputs = self.model.network(*[to_variable(x) for x in inputs]) # Transfrom data to expected device expected_device = paddle.device.get_device() @@ -814,7 +812,7 @@ class DynamicGraphAdapter(object): self.mode = 'test' inputs = [to_variable(x) for x in to_list(inputs)] self._input_info = _update_input_info(inputs) - outputs = self.model.network.forward(*inputs) + outputs = self.model.network(*inputs) if self._nranks > 1 and isinstance(self.model._place, fluid.CUDAPlace): outputs = [_all_gather(o, self._nranks) for o in to_list(outputs)] -- GitLab