From da9752fee15c6502eb480631df6a9fd151228cad Mon Sep 17 00:00:00 2001 From: Yi Liu Date: Mon, 25 Nov 2019 15:08:25 +0800 Subject: [PATCH] fix bug of issue #21259 (#21331) * fix bug of issue #21259 (#21287) pass the argument `allow_out_of_range` of one_hot op to c++ back end. --- python/paddle/fluid/input.py | 6 +++--- python/paddle/fluid/layers/nn.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/fluid/input.py b/python/paddle/fluid/input.py index ba84d221b1d..68d145ca467 100644 --- a/python/paddle/fluid/input.py +++ b/python/paddle/fluid/input.py @@ -104,16 +104,16 @@ def one_hot(input, depth, allow_out_of_range=False): if in_dygraph_mode(): inputs = {'X': input} - attrs = {'depth': depth} + attrs = {'depth': depth, 'allow_out_of_range': allow_out_of_range} else: if not isinstance(depth, Variable): # user attribute inputs = {'X': input} - attrs = {'depth': depth} + attrs = {'depth': depth, 'allow_out_of_range': allow_out_of_range} else: depth.stop_gradient = True inputs = {'X': input, 'depth_tensor': depth} - attrs = {} + attrs = {'allow_out_of_range': allow_out_of_range} helper.append_op( type="one_hot_v2", inputs=inputs, diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index a975ca5b609..1234c6f83de 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -8731,16 +8731,16 @@ def one_hot(input, depth, allow_out_of_range=False): if in_dygraph_mode(): inputs = {'X': input} - attrs = {'depth': depth} + attrs = {'depth': depth, 'allow_out_of_range': allow_out_of_range} else: if not isinstance(depth, Variable): # user attribute inputs = {'X': input} - attrs = {'depth': depth} + attrs = {'depth': depth, 'allow_out_of_range': allow_out_of_range} else: depth.stop_gradient = True inputs = {'X': input, 'depth_tensor': depth} - attrs = {} + attrs = {'allow_out_of_range': allow_out_of_range} helper.append_op( type="one_hot", inputs=inputs, -- GitLab