Skip to content

Commit 408353a

Browse files
committed
feat: Support lvalues in validation functions
Support lvalue expressions passed to - error_on_format_not_in - error_on_data_type_not_in - error_on_data_layout_not_in - error_on_channel_not_in. Partially-resolves: COMPMID-8697 Signed-off-by: Andreas Flöjt <andreas.floejt@arm.com> Change-Id: Ia792500d932f92e2c79338fa537984762b66a258
1 parent d52e297 commit 408353a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

arm_compute/core/Validate.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2021, 2023-2025 Arm Limited.
2+
* Copyright (c) 2016-2021, 2023-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -38,6 +38,9 @@
3838
#include "arm_compute/core/Window.h"
3939

4040
#include <algorithm>
41+
#include <array>
42+
#include <type_traits>
43+
#include <utility>
4144

4245
namespace arm_compute
4346
{
@@ -778,7 +781,7 @@ void error_on_format_not_in(
778781

779782
ARM_COMPUTE_ERROR_ON_LOC(object_format == Format::UNKNOWN, function, file, line);
780783

781-
const std::array<F, sizeof...(Fs)> formats_array{{std::forward<Fs>(formats)...}};
784+
const std::array<std::decay_t<F>, sizeof...(Fs)> formats_array{{std::forward<Fs>(formats)...}};
782785
ARM_COMPUTE_UNUSED(formats_array);
783786

784787
ARM_COMPUTE_ERROR_ON_LOC_MSG(
@@ -810,7 +813,7 @@ inline arm_compute::Status error_on_data_type_not_in(
810813
const DataType &tensor_dt = tensor_info->data_type(); //NOLINT
811814
ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_dt == DataType::UNKNOWN, function, file, line);
812815

813-
const std::array<T, sizeof...(Ts)> dts_array{{std::forward<Ts>(dts)...}};
816+
const std::array<std::decay_t<T>, sizeof...(Ts)> dts_array{{std::forward<Ts>(dts)...}};
814817
ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(
815818
tensor_dt != dt && std::none_of(dts_array.begin(), dts_array.end(), [&](const T &d) { return d == tensor_dt; }),
816819
function, file, line, "ITensor data type %s not supported by this kernel",
@@ -862,7 +865,7 @@ inline arm_compute::Status error_on_data_layout_not_in(
862865
const DataLayout &tensor_dl = tensor_info->data_layout(); //NOLINT
863866
ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_dl == DataLayout::UNKNOWN, function, file, line);
864867

865-
const std::array<T, sizeof...(Ts)> dls_array{{std::forward<Ts>(dls)...}};
868+
const std::array<std::decay_t<T>, sizeof...(Ts)> dls_array{{std::forward<Ts>(dls)...}};
866869
ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(
867870
tensor_dl != dl && std::none_of(dls_array.begin(), dls_array.end(), [&](const T &l) { return l == tensor_dl; }),
868871
function, file, line, "ITensor data layout %s not supported by this kernel",
@@ -1041,7 +1044,7 @@ error_on_channel_not_in(const char *function, const char *file, const int line,
10411044
{
10421045
ARM_COMPUTE_RETURN_ERROR_ON_LOC(cn == Channel::UNKNOWN, function, file, line);
10431046

1044-
const std::array<T, sizeof...(Ts)> channels_array{{std::forward<Ts>(channels)...}};
1047+
const std::array<std::decay_t<T>, sizeof...(Ts)> channels_array{{std::forward<Ts>(channels)...}};
10451048
ARM_COMPUTE_RETURN_ERROR_ON_LOC(channel != cn && std::none_of(channels_array.begin(), channels_array.end(),
10461049
[&](const T &f) { return f == cn; }),
10471050
function, file, line);

0 commit comments

Comments
 (0)