diff --git a/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc b/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc index b46c6e0e889834f6dbfe293e1124a353cd0ac55d..070404811f643ac03228bfcf355575a34513ecef 100644 --- a/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc +++ b/tf_adapter/kernels/aicpu/host_queue_dataset_op.cc @@ -597,14 +597,15 @@ class HostQueueDatasetOp : public DatasetOpKernel { ADP_LOG(INFO) << "Slave SendDataThread exit."; } - void RecordMbufQueueBytes(const bool is_hold_type, const uint64_t args_total_bytes) { - if (!is_hold_type) { return; } + void RecordMbufQueueBytes(const bool is_hold, const uint64_t args_total_bytes) { + if (!is_hold) { return; } mbuf_queue_rear_ = (mbuf_queue_rear_ + 1) % kStringTypeDepth; + mbuf_queue_total_bytes_ = mbuf_queue_total_bytes_ - mbuf_queue_bytes_[mbuf_queue_rear_] + args_total_bytes; mbuf_queue_bytes_[mbuf_queue_rear_] = args_total_bytes; } bool IsHoldDataTrans() { - if (!is_hold_type) { return false; } + if (mbuf_queue_total_bytes_ < static_cast(kMaxBytes)) { return false; } size_t mbuf_size; aclError status = acltdtQueryChannelSize(acl_handle_, &mbuf_size); if (status != ACL_SUCCESS) { @@ -629,7 +630,7 @@ class HostQueueDatasetOp : public DatasetOpKernel { Status status = Status::OK(); bool is_need_resend = false; - while(!finish_send_) { + while (!finish_send_) { if (IsHoldDataTrans()) { auto start = std::chrono::high_resolution_clock::now(); auto end = start + std::chrono::microseconds(kSleepDuration); @@ -1039,7 +1040,8 @@ class HostQueueDatasetOp : public DatasetOpKernel { double elapsed_time = 0; uint64_t total_bytes = 0; } data_thread_perf_stat_[static_cast(ThreadType::BUTT)]; - uint64_t mbuf_queue_bytes_[kStringTypeDepth]; + uint64_t mbuf_queue_bytes_[kStringTypeDepth] = { 0 }; + uint64_t mbuf_queue_total_bytes_ = 0; size_t mbuf_queue_rear_ = 0; }; const std::vector inputs_;