From 6e67d0fb78b9dd23ced460d6b2bc54fcc5bde438 Mon Sep 17 00:00:00 2001 From: Wu Yi Date: Tue, 4 Dec 2018 14:38:44 +0800 Subject: [PATCH] layer fixes (#14591) * layer fixes test=develop * follow update test=develop --- .../paddle/fluid/layers/layer_function_generator.py | 11 ++++++++++- python/paddle/fluid/layers/tensor.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/layers/layer_function_generator.py b/python/paddle/fluid/layers/layer_function_generator.py index eea0a362a0c..09b1b30216b 100644 --- a/python/paddle/fluid/layers/layer_function_generator.py +++ b/python/paddle/fluid/layers/layer_function_generator.py @@ -20,7 +20,7 @@ import string from six.moves import cStringIO from ..proto import framework_pb2 -from ..framework import OpProtoHolder, Variable +from ..framework import OpProtoHolder, Variable, core, convert_np_dtype_to_dtype_ from ..layer_helper import LayerHelper __all__ = [ @@ -178,6 +178,15 @@ def generate_layer_fn(op_type): "operator {0} must input same dtype. {1} vs {2}".format( op_type, dtype, each.dtype)) + if dtype is None: + arg_dtype = kwargs.get("dtype") + if arg_dtype: + if not isinstance(arg_dtype, core.VarDesc.VarType): + dtype = convert_np_dtype_to_dtype_(arg_dtype) + else: + dtype = arg_dtype + else: + dtype = core.VarDesc.VarType.FP32 return dtype def func(*args, **kwargs): diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index ff32c001041..49a486cf0c3 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -622,7 +622,7 @@ def reverse(x, axis): out = helper.create_variable_for_type_inference(dtype=x.dtype) helper.append_op( type='reverse', - inputs={'Input': x}, + inputs={'X': x}, outputs={'Out': [out]}, attrs={'axis': axis}) return out -- GitLab