Skip to content

Commit

Permalink
[XPU] Fixed the bug in op calib. (#9700)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbn03 committed Nov 16, 2022
1 parent 81413db commit 2ff6f96
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lite/kernels/xpu/calib_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ namespace xpu {
template <typename InType, typename OutType, PrecisionType PType>
void CalibCompute<InType, OutType, PType>::PrepareForRun() {
auto& param = this->template Param<param_t>();
auto& ctx = this->ctx_->template As<XPUContext>();
int max_ptr_size = ctx.GetRawContext()->max_ptr_size();
if (param.scale) {
std::vector<float> cpu_scale = {param.scale};
calib_max_guard_ = TargetWrapperXPU::MallocScratchPad(sizeof(float));
std::vector<float> cpu_scale(max_ptr_size, param.scale);
calib_max_guard_ =
TargetWrapperXPU::MallocScratchPad(max_ptr_size * sizeof(float));
lite::TargetWrapperXPU::MemcpySync(calib_max_guard_->addr_,
cpu_scale.data(),
sizeof(float),
max_ptr_size * sizeof(float),
IoDirection::HtoD);
}
}
Expand Down

0 comments on commit 2ff6f96

Please sign in to comment.