Skip to content

Commit

Permalink
Merge pull request #248 from anarkiwi/avg
Browse files Browse the repository at this point in the history
I/Q inference gates on average power.
  • Loading branch information
anarkiwi committed Apr 18, 2024
2 parents dc4553d + 272055a commit ab7de9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion grc/iqtlabs_iq_inference.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions lib/iq_inference_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> model_server_parts_;
std::vector<std::string> text_color_parts_;
boost::split(model_server_parts_, model_server, boost::is_any_of(":"),
Expand Down Expand Up @@ -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_) {
Expand Down
4 changes: 2 additions & 2 deletions lib/iq_inference_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ typedef struct output_item {
class iq_inference_impl : public iq_inference, base_impl {
private:
boost::scoped_array<gr_complex> samples_lookback_;
boost::scoped_ptr<float> total_;
boost::scoped_ptr<uint16_t> max_;
boost::scoped_ptr<float> samples_total_;
boost::scoped_ptr<float> power_total_;
pmt::pmt_t tag_;
COUNT_T vlen_;
COUNT_T n_vlen_;
Expand Down

0 comments on commit ab7de9a

Please sign in to comment.