Skip to content

Commit

Permalink
Reduce stack size for QuantizeWu (C++).
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 576903498
  • Loading branch information
Material Eng authored and copybara-github committed Oct 26, 2023
1 parent 6e0f5e1 commit bec7bab
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cpp/quantize/wu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@

#include <stdlib.h>

#include <array>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <ostream>
#include <vector>

#include "cpp/utils/utils.h"
Expand Down Expand Up @@ -51,8 +48,8 @@ constexpr int kIndexCount = ((1 << kIndexBits) + 1);
constexpr int kTotalSize = (kIndexCount * kIndexCount * kIndexCount);
constexpr int kMaxColors = 256;

using IntArray = std::array<int64_t, kTotalSize>;
using DoubleArray = std::array<double, kTotalSize>;
using IntArray = std::vector<int64_t>;
using DoubleArray = std::vector<double>;

int GetIndex(int r, int g, int b) {
return (r << (kIndexBits * 2)) + (r << (kIndexBits + 1)) + (g << kIndexBits) +
Expand Down Expand Up @@ -298,11 +295,11 @@ std::vector<Argb> QuantizeWu(const std::vector<Argb>& pixels,
return std::vector<Argb>();
}

IntArray weights = {};
IntArray moments_red = {};
IntArray moments_green = {};
IntArray moments_blue = {};
DoubleArray moments = {};
IntArray weights(kTotalSize, 0);
IntArray moments_red(kTotalSize, 0);
IntArray moments_green(kTotalSize, 0);
IntArray moments_blue(kTotalSize, 0);
DoubleArray moments(kTotalSize, 0.0);
ConstructHistogram(pixels, weights, moments_red, moments_green, moments_blue,
moments);
ComputeMoments(weights, moments_red, moments_green, moments_blue, moments);
Expand Down

0 comments on commit bec7bab

Please sign in to comment.