提交 d52f04b5 编写于 作者: R Ruilong Liu 提交者: GitHub

Merge pull request #831 from xiebaiyuan/develop

add HasAttr() for op_param.h and check "inplace" attr in reshapeOp fixed #818
......@@ -213,6 +213,10 @@ class OpParam {
return ((Attribute)map.at(key)).Get<T>();
}
static const bool HasAttr(const string &key, const AttributeMap &map) {
return map.count(key) > 0;
}
template <typename T>
static T *GetVarValue(const string &key, const VariableNameMap &var_map,
const Scope &scope) {
......@@ -862,7 +866,13 @@ class ReshapeParam : public OpParam {
input_shape_ = InputShapeFrom<GType>(inputs, scope);
out_ = OutFrom<GType>(outputs, scope);
shape_ = GetAttr<vector<int>>("shape", attrs);
inplace_ = GetAttr<bool>("inplace", attrs);
if (HasAttr("inplace", attrs)) {
inplace_ = GetAttr<bool>("inplace", attrs);
} else {
inplace_ = false;
DLOG << "ReshapeParam lost inplace params. maybe fluid updated";
}
}
const RType *InputX() const { return input_x_; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册