Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backends/cortex_m/ops/cortex_m_ops_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ using KernelRuntimeContext = torch::executor::KernelRuntimeContext;
#define ARM_NN_Q31_MAX ((int32_t)(0x7FFFFFFFL))
#define ARM_NN_Q31_MIN ((int32_t)(0x80000000L))

// 16-byte alignment for MVE vector operations.
constexpr size_t kCortexMMveAlignment = 16;

// Basic tensor type / layout validation and dimension order checking
inline void validate_cmsis_nn_tensor_requirements(
const Tensor& input1,
Expand Down
2 changes: 1 addition & 1 deletion backends/cortex_m/ops/op_quantized_conv2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Tensor& quantized_conv2d_out(
arm_convolve_s8_get_buffer_size(&input_dims, &filter_dims));
if (buffer_bytes > 0) {
auto buffer_or_error =
context.allocate_temp(buffer_bytes, alignof(int16_t));
context.allocate_temp(buffer_bytes, kCortexMMveAlignment);
if (!buffer_or_error.ok()) {
if (buffer_or_error.error() != Error::NotFound) {
ET_LOG(
Expand Down
2 changes: 1 addition & 1 deletion backends/cortex_m/ops/op_quantized_depthwise_conv2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Tensor& quantized_depthwise_conv2d_out(
}

auto buffer_or_error = context.allocate_temp(
static_cast<size_t>(buffer_bytes), alignof(int16_t));
static_cast<size_t>(buffer_bytes), kCortexMMveAlignment);
if (!buffer_or_error.ok()) {
ET_LOG(
Error,
Expand Down
4 changes: 2 additions & 2 deletions backends/cortex_m/ops/op_quantized_transpose_conv2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Tensor& quantized_transpose_conv2d_out(
const int32_t buffer_bytes = arm_transpose_conv_s8_get_buffer_size(
&transpose_conv_params, &input_dims, &filter_dims, &output_dims);
auto buffer_or_error = context.allocate_temp(
static_cast<size_t>(buffer_bytes), alignof(int16_t));
static_cast<size_t>(buffer_bytes), kCortexMMveAlignment);
if (!buffer_or_error.ok()) {
ET_LOG(
Error,
Expand All @@ -209,7 +209,7 @@ Tensor& quantized_transpose_conv2d_out(
arm_transpose_conv_s8_get_reverse_conv_buffer_size(
&transpose_conv_params, &input_dims, &filter_dims);
auto output_buffer_or_error = context.allocate_temp(
static_cast<size_t>(output_buffer_bytes), alignof(int16_t));
static_cast<size_t>(output_buffer_bytes), kCortexMMveAlignment);
if (!output_buffer_or_error.ok()) {
ET_LOG(
Error,
Expand Down
Loading