Skip to content

Commit

Permalink
fix onesided destination overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
garymm committed Jun 24, 2022
1 parent e27222f commit e6ec47e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions onnxruntime/core/providers/cpu/signal/dft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ static Status fft_radix2(OpKernelContext* /*ctx*/, const Tensor* X, Tensor* Y, s
std::complex<T>* Y_data;
if (is_onesided) {
if (temp_output.size() != dft_length) {
temp_output.clear();
temp_output.resize(dft_length);
}
Y_data = temp_output.data();
Expand All @@ -126,7 +125,6 @@ static Status fft_radix2(OpKernelContext* /*ctx*/, const Tensor* X, Tensor* Y, s

// Create vandermonde matrix V ordered with the bit-reversed permutation
if (V.size() != dft_length) {
V.clear();
V.resize(dft_length);
for (size_t i = 0; i < dft_length; i++) {
size_t bit_reversed_index = bit_reverse(i, significant_bits);
Expand Down Expand Up @@ -172,8 +170,9 @@ static Status fft_radix2(OpKernelContext* /*ctx*/, const Tensor* X, Tensor* Y, s
}

if (is_onesided) {
const size_t output_size = (dft_length >> 1) + 1;
auto destination = reinterpret_cast<std::complex<T>*>(Y->MutableDataRaw()) + Y_offset;
for (size_t i = 0; i < dft_length; i++) {
for (size_t i = 0; i < output_size; i++) {
*(destination + Y_stride * i) = *(Y_data + i * Y_data_stride);
}
}
Expand Down

0 comments on commit e6ec47e

Please sign in to comment.