From 272055af4e35ceb00d6ea6969a65490c09fb0efe Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Thu, 18 Apr 2024 05:08:24 +0000 Subject: [PATCH] I/Q inference gates on average power. --- grc/iqtlabs_iq_inference.block.yml | 2 +- lib/iq_inference_impl.cc | 14 +++++++------- lib/iq_inference_impl.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/grc/iqtlabs_iq_inference.block.yml b/grc/iqtlabs_iq_inference.block.yml index 5b1ec3a5..af1ca056 100644 --- a/grc/iqtlabs_iq_inference.block.yml +++ b/grc/iqtlabs_iq_inference.block.yml @@ -25,7 +25,7 @@ documentation: |- vlen: length of complex/FFT dB vector. n_vlen: number of vectors aggregate. sample_buffer: size of sample lookback buffer. - min_peak_points: Only run inference on buckets with this minimum dB power. + min_peak_points: Only run inference with this minimum average dB power. model_names: if not empty, comma separated list of model names. model_server: if not empty, do torchserve inference to this address. confidence: Only output inference results where confidence is greater. diff --git a/lib/iq_inference_impl.cc b/lib/iq_inference_impl.cc index 8caf7d8e..13fccb73 100644 --- a/lib/iq_inference_impl.cc +++ b/lib/iq_inference_impl.cc @@ -250,8 +250,8 @@ iq_inference_impl::iq_inference_impl(const std::string &tag, COUNT_T vlen, batch_ = vlen_ * n_vlen_; samples_lookback_.reset(new gr_complex[batch_ * sample_buffer]); unsigned int alignment = volk_get_alignment(); - max_.reset((uint16_t *)volk_malloc(sizeof(uint16_t), alignment)); - total_.reset((float *)volk_malloc(sizeof(float), alignment)); + samples_total_.reset((float *)volk_malloc(sizeof(float), alignment)); + power_total_.reset((float *)volk_malloc(sizeof(float), alignment)); std::vector model_server_parts_; std::vector text_color_parts_; boost::split(model_server_parts_, model_server, boost::is_any_of(":"), @@ -440,16 +440,16 @@ void iq_inference_impl::process_items_(COUNT_T power_in_count, samples_since_tag_ += batch_, sample_clock_ += batch_, consumed += n_vlen_) { COUNT_T j = (power_read + i) % sample_buffer_; - volk_32f_index_max_16u(max_.get(), power_in, batch_); - float power_max = power_in[*max_]; - if (power_max < min_peak_points_) { + // Gate on average power. + volk_32f_accumulator_s32f(power_total_.get(), power_in, batch_); + if (*power_total_ / batch_ < min_peak_points_) { continue; } // We might get all zero samples if squelched externally - though // we will receive non zero power values. const float *in_floats = (const float *)&samples_lookback_[j * batch_]; - volk_32f_accumulator_s32f(total_.get(), in_floats, batch_ * 2); - if (*total_ == 0) { + volk_32f_accumulator_s32f(samples_total_.get(), in_floats, batch_ * 2); + if (*samples_total_ == 0) { continue; } if (n_inference_ > 0 && ++inference_count_ % n_inference_) { diff --git a/lib/iq_inference_impl.h b/lib/iq_inference_impl.h index 4611545f..9108188a 100644 --- a/lib/iq_inference_impl.h +++ b/lib/iq_inference_impl.h @@ -236,8 +236,8 @@ typedef struct output_item { class iq_inference_impl : public iq_inference, base_impl { private: boost::scoped_array samples_lookback_; - boost::scoped_ptr total_; - boost::scoped_ptr max_; + boost::scoped_ptr samples_total_; + boost::scoped_ptr power_total_; pmt::pmt_t tag_; COUNT_T vlen_; COUNT_T n_vlen_;