From 70cb9f7f55b068e3cc0fe3654031b011ca9fd3b1 Mon Sep 17 00:00:00 2001 From: xiebaiyuan Date: Fri, 24 Aug 2018 16:49:23 +0800 Subject: [PATCH] add HasAttr() for op_param.h and check "inplace" attr in reshapeOp --- src/operators/op_param.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/operators/op_param.h b/src/operators/op_param.h index 6fe851b31d..8acfac3618 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -204,6 +204,10 @@ class OpParam { return ((Attribute)map.at(key)).Get(); } + static const bool HasAttr(const string &key, const AttributeMap &map) { + return map.count(key) > 0; + } + template static T *GetVarValue(const string &key, const VariableNameMap &var_map, const Scope &scope) { @@ -833,7 +837,13 @@ class ReshapeParam : public OpParam { input_shape_ = InputShapeFrom(inputs, scope); out_ = OutFrom(outputs, scope); shape_ = GetAttr>("shape", attrs); - inplace_ = GetAttr("inplace", attrs); + + if (HasAttr("inplace", attrs)) { + inplace_ = GetAttr("inplace", attrs); + } else { + inplace_ = false; + DLOG << "ReshapeParam lost inplace params. maybe fluid updated"; + } } const RType *InputX() const { return input_x_; } -- GitLab