Skip to content

Commit

Permalink
[compute] Remove variable length array (#14389)
Browse files Browse the repository at this point in the history
This commit changes variable length array to vector in cker and ruy.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored Dec 2, 2024
1 parent e1d9220 commit 3a751b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
17 changes: 3 additions & 14 deletions compute/cker/include/cker/operation/Conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,9 @@ class Conv
}

int im2col_size = _need_im2col ? _im2col_shape.FlatSize() : 1;

// Use heap if size is larger than 8MB
if (im2col_size > 8 * 1024 * 1024)
{
std::unique_ptr<uint8_t[]> im2col_data = std::make_unique<uint8_t[]>(im2col_size);
optimized::Conv(params, input_shape, input_data, filter_shape, filter_data, bias_shape,
bias_data, output_shape, output_data, _im2col_shape, im2col_data.get());
}
else
{
uint8_t im2col_data[im2col_size];
optimized::Conv(params, input_shape, input_data, filter_shape, filter_data, bias_shape,
bias_data, output_shape, output_data, _im2col_shape, im2col_data);
}
std::vector<uint8_t> im2col_data(im2col_size);
optimized::Conv(params, input_shape, input_data, filter_shape, filter_data, bias_shape,
bias_data, output_shape, output_data, _im2col_shape, im2col_data.data());
}

void operator()(const ConvParams &params, const Shape &input_shape, const uint8_t *input_data,
Expand Down
14 changes: 3 additions & 11 deletions compute/ruy/include/ruy/operation/Conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,11 @@ class Conv
}

int im2col_size = _need_im2col ? _im2col_shape.FlatSize() : 0;

// Use heap if size is larger than 8MB
if (im2col_size > 2 * 1024 * 1024)
{
std::unique_ptr<float[]> im2col_data = std::make_unique<float[]>(im2col_size);
ConvFloat(params, input_shape, input_data, filter_shape, filter_data, bias_shape, bias_data,
output_shape, output_data, _im2col_shape, im2col_data.get(), ruy_context);
}
else if (im2col_size > 0)
std::vector<float> im2col_data(im2col_size);
if (im2col_size > 0)
{
float im2col_data[im2col_size];
ConvFloat(params, input_shape, input_data, filter_shape, filter_data, bias_shape, bias_data,
output_shape, output_data, _im2col_shape, im2col_data, ruy_context);
output_shape, output_data, _im2col_shape, im2col_data.data(), ruy_context);
}
else
{
Expand Down

0 comments on commit 3a751b3

Please sign in to comment.