mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 00:17:25 +08:00
[Model Runner] Refactor execute_model for GPU async scheduling (#6176)
This commit is contained in:
@@ -68,7 +68,7 @@ __global__ void update_inputs_kernel(bool* not_need_stop,
|
||||
}
|
||||
|
||||
void UpdateInputs(const paddle::Tensor& stop_flags,
|
||||
const paddle::Tensor& not_need_stop, // only on cpu
|
||||
const paddle::Tensor& not_need_stop, // on gpu
|
||||
const paddle::Tensor& seq_lens_this_time,
|
||||
const paddle::Tensor& seq_lens_encoder,
|
||||
const paddle::Tensor& seq_lens_decoder,
|
||||
@@ -86,9 +86,8 @@ void UpdateInputs(const paddle::Tensor& stop_flags,
|
||||
const int max_bsz = stop_flags.shape()[0];
|
||||
const int now_bsz = seq_lens_this_time.shape()[0];
|
||||
const int input_ids_stride = input_ids.shape()[1];
|
||||
auto not_need_stop_gpu = not_need_stop.copy_to(stop_flags.place(), false);
|
||||
update_inputs_kernel<1024><<<1, 1024, 0, cu_stream>>>(
|
||||
const_cast<bool*>(not_need_stop_gpu.data<bool>()),
|
||||
const_cast<bool*>(not_need_stop.data<bool>()),
|
||||
const_cast<int*>(seq_lens_this_time.data<int>()),
|
||||
const_cast<int*>(seq_lens_encoder.data<int>()),
|
||||
const_cast<int*>(seq_lens_decoder.data<int>()),
|
||||
@@ -99,10 +98,6 @@ void UpdateInputs(const paddle::Tensor& stop_flags,
|
||||
now_bsz,
|
||||
max_bsz,
|
||||
input_ids_stride);
|
||||
auto not_need_stop_cpu =
|
||||
not_need_stop_gpu.copy_to(not_need_stop.place(), false);
|
||||
bool* not_need_stop_data = const_cast<bool*>(not_need_stop.data<bool>());
|
||||
not_need_stop_data[0] = not_need_stop_cpu.data<bool>()[0];
|
||||
}
|
||||
|
||||
PD_BUILD_STATIC_OP(update_inputs)
|
||||
|
||||
Reference in New Issue
Block a user