Skip to content

Commit

Permalink
[xpu] fix scope new tensor, max weight is unchanged (#9641)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitliuyf authored Nov 9, 2022
1 parent 9993e36 commit 4dc658b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,8 @@ class XPUSingleEncoderFuser : public FuseBase {
weight_max.push_back(127 * weight_scales[j]);
}
// create max tensor
weight_max_tensor = scope->NewTensor(weight_max_tensor_name[i]);
weight_max_tensor =
scope->MutableParent()->NewTensor(weight_max_tensor_name[i]);
weight_max_tensor->Resize({weight_scale_size});
memcpy(weight_max_tensor->mutable_data<float>(),
weight_max.data(),
Expand Down Expand Up @@ -1322,7 +1323,7 @@ class XPUMultiEncoderFuser {
weight_tensor_vec[0]->Resize({weight_dim1_acc, weight_dims_vec[0][0]});
float max_f =
paddle::lite::xpu::math::FindMaxAbs(weight_qkv_trans.get(), qkv_len);
auto max_tensor = scope->NewTensor(max_tensor_name);
auto max_tensor = scope->MutableParent()->NewTensor(max_tensor_name);
max_tensor->mutable_data<float>(TargetType::kHost, 1)[0] = max_f;
VLOG(3) << "Lite find max: " << start << "th fc , weight_max:" << max_f;
VLOG(3) << "Set " << max_tensor_name << " " << max_f;
Expand Down

0 comments on commit 4dc658b

Please sign in to comment.