Skip to content

Commit

Permalink
fix issue of fill_constant missing dtype (PaddlePaddle#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff41404 authored and jiahy0825 committed May 25, 2023
1 parent 67803a4 commit cb32c88
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cinn/hlir/pass/constant_folding_pass_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ inline void fold_broadcast_to_constant(const FusionHelperBase* helper, Graph* gr
// create constant op.
Node* node_tmp = new Node(Operator::Get("fill_constant"), "fill_constant", common::UniqName("fill_constant"));
// set node attr
node_tmp->attrs.attr_store["dtype"] = constant_op->attrs.attr_store.at("dtype");
node_tmp->attrs.attr_store["shape"] = shape;
node_tmp->attrs.attr_store["value"] = constant_op->attrs.attr_store.at("value");
node_tmp->attrs.attr_store["force_cpu"] = false;
Expand Down Expand Up @@ -61,6 +62,7 @@ inline void fold_reshape_fill_constant(const FusionHelperBase* helper, Graph* gr
// create constant op.
Node* node_tmp = new Node(Operator::Get("fill_constant"), "fill_constant", common::UniqName("fill_constant"));
// set node attr
node_tmp->attrs.attr_store["dtype"] = constant_op->attrs.attr_store.at("dtype");
node_tmp->attrs.attr_store["shape"] = shape;
node_tmp->attrs.attr_store["value"] = constant_op->attrs.attr_store.at("value");
node_tmp->attrs.attr_store["force_cpu"] = false;
Expand Down Expand Up @@ -108,6 +110,7 @@ inline void fold_squeeze_fill_constant(const FusionHelperBase* helper, Graph* gr
}
}

node_tmp->attrs.attr_store["dtype"] = constant_op->attrs.attr_store.at("dtype");
node_tmp->attrs.attr_store["shape"] = n_shape;
node_tmp->attrs.attr_store["value"] = constant_op->attrs.attr_store.at("value");
node_tmp->attrs.attr_store["force_cpu"] = false;
Expand Down Expand Up @@ -158,6 +161,7 @@ inline void fold_expand_dims_fill_constant(const FusionHelperBase* helper, Graph
}

// set node attr
node_tmp->attrs.attr_store["dtype"] = constant_op->attrs.attr_store.at("dtype");
node_tmp->attrs.attr_store["shape"] = n_shape;
node_tmp->attrs.attr_store["value"] = constant_op->attrs.attr_store.at("value");
node_tmp->attrs.attr_store["force_cpu"] = false;
Expand Down

0 comments on commit cb32c88

Please sign in to comment.