Skip to content

Commit 1bb8474

Browse files
dwildmarkdeveloper-compute
authored andcommitted
Revert "fix: Handle padding updates after configure() in CpuActivation"
This reverts commit 4eec351.
1 parent 4eec351 commit 1bb8474

File tree

7 files changed

+20
-200
lines changed

7 files changed

+20
-200
lines changed

src/cpu/kernels/CpuActivationKernel.cpp

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,17 @@ void init_lut(ActivationLayerInfo::ActivationFunction act_func,
201201
void CpuActivationKernel::configure(const ITensorInfo *src, ITensorInfo *dst, ActivationLayerInfo activation_info)
202202
{
203203
ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuActivationKernel::configure");
204+
ARM_COMPUTE_UNUSED(dst);
204205
ARM_COMPUTE_ERROR_ON_NULLPTR(src);
205206
ARM_COMPUTE_ERROR_THROW_ON(CpuActivationKernel::validate(src, dst, activation_info));
206207

207208
heuristics::CpuActivationKernelHeuristics heuristics(src, dst, activation_info);
208209
_heuristics = std::move(heuristics);
209210

210-
_src_padding = src->padding();
211-
_inplace = (dst == nullptr);
212-
if (!_inplace)
211+
if (dst != nullptr)
213212
{
214213
// dst auto inizialitation if not yet initialized
215214
auto_init_if_empty(*dst, *src->clone());
216-
_dst_padding = dst->padding();
217215
}
218216

219217
const auto *uk = _heuristics.kernel();
@@ -266,35 +264,6 @@ size_t CpuActivationKernel::get_mws(const CPUInfo &platform, size_t thread_count
266264
return _heuristics.mws();
267265
}
268266

269-
void CpuActivationKernel::prepare(ITensorPack &tensors)
270-
{
271-
const ITensor *src = tensors.get_const_tensor(TensorType::ACL_SRC);
272-
ITensor *dst = tensors.get_tensor(TensorType::ACL_DST);
273-
274-
const ITensorInfo *src_info = src->info();
275-
const ITensorInfo *dst_info = dst->info();
276-
277-
const bool src_padding_changed = (src_info->padding() != _src_padding);
278-
const bool dst_padding_changed = (!_inplace && dst_info->padding() != _dst_padding);
279-
280-
if (src_padding_changed || dst_padding_changed)
281-
{
282-
// If padding has changed after configuration, recalculate the heuristics
283-
const auto kernel_before_padding_change = _heuristics.kernel();
284-
heuristics::CpuActivationKernelHeuristics heuristics(src_info, dst_info, _act_info);
285-
_heuristics = std::move(heuristics);
286-
const auto kernel_after_padding_change = _heuristics.kernel();
287-
288-
// We expect only the window and split dimension to change if padding changes.
289-
// This guard is here to prevent future incompliant changes to the heuristic class.
290-
// Thus, the kernel name specific logic in configuration doesn't need to be replicated here.
291-
ARM_COMPUTE_ERROR_ON(kernel_before_padding_change != kernel_after_padding_change);
292-
ARM_COMPUTE_UNUSED(kernel_before_padding_change, kernel_after_padding_change);
293-
294-
ICPPKernel::configure(_heuristics.window());
295-
}
296-
}
297-
298267
void CpuActivationKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info)
299268
{
300269
ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuActivationKernel::run_op");

src/cpu/kernels/CpuActivationKernel.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2025 Arm Limited.
2+
* Copyright (c) 2017-2024 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -24,7 +24,6 @@
2424
#ifndef ACL_SRC_CPU_KERNELS_CPUACTIVATIONKERNEL_H
2525
#define ACL_SRC_CPU_KERNELS_CPUACTIVATIONKERNEL_H
2626

27-
#include "arm_compute/core/Types.h"
2827
#include "arm_compute/function_info/ActivationLayerInfo.h"
2928

3029
#include "src/core/common/Macros.h"
@@ -87,20 +86,10 @@ class CpuActivationKernel : public ICPPKernel
8786
return _heuristics.scheduler_hint().split_dimension();
8887
}
8988

90-
/** Prepare the activation kernel for execution (Only executed once)
91-
*
92-
* @param[in] tensors Pack of input and output tensors
93-
*
94-
*/
95-
void prepare(ITensorPack &tensors);
96-
9789
private:
9890
ActivationLayerInfo _act_info{};
9991
std::string _name{};
10092
heuristics::CpuActivationKernelHeuristics _heuristics{};
101-
PaddingSize _src_padding{};
102-
PaddingSize _dst_padding{};
103-
bool _inplace{};
10493
};
10594
} // namespace kernels
10695
} // namespace cpu

src/cpu/kernels/activation/heuristics/CpuActivationKernelHeuristics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2025 Arm Limited.
2+
* Copyright (c) 2017-2024 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -318,6 +318,8 @@ CpuActivationKernelHeuristics::CpuActivationKernelHeuristics(const ITensorInfo
318318
const ITensorInfo *dst,
319319
const ActivationLayerInfo &activation_info)
320320
{
321+
ARM_COMPUTE_UNUSED(dst);
322+
321323
// Set kernel
322324
const DataType dtype = src->data_type();
323325
ActivationDataTypeISASelectorData selector{dtype, CPUInfo::get().get_cpu_model(), CPUInfo::get().get_isa(),
@@ -327,8 +329,7 @@ CpuActivationKernelHeuristics::CpuActivationKernelHeuristics(const ITensorInfo
327329

328330
// Set window and scheduling hint
329331
int split_dim;
330-
std::tie(_window, split_dim) =
331-
dst == nullptr ? calculate_squashed_or_max_window(*src) : calculate_squashed_or_max_window(*src, *dst);
332+
std::tie(_window, split_dim) = calculate_squashed_or_max_window(*src);
332333

333334
// Collapse window with SME kernels in Y-Dim
334335
if (std::string(_kernel->name) == "sme2_fp32_logistic")

src/cpu/operators/CpuActivation.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ void CpuActivation::configure(const ITensorInfo *input, ITensorInfo *output, con
4040
{
4141
ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuActivation::configure");
4242
ARM_COMPUTE_LOG_PARAMS(input, output, activation_info);
43-
44-
_is_prepared = false;
45-
auto k = std::make_unique<kernels::CpuActivationKernel>();
43+
auto k = std::make_unique<kernels::CpuActivationKernel>();
4644
k->configure(input, output, activation_info);
4745
_kernel = std::move(k);
4846
}
@@ -58,15 +56,7 @@ void CpuActivation::run(ITensorPack &tensors)
5856
{
5957
ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuActivation::run");
6058
ARM_COMPUTE_ERROR_ON_MSG(tensors.empty(), "No inputs provided");
61-
62-
auto kernel_casted = static_cast<kernels::CpuActivationKernel *>(_kernel.get());
63-
if (!_is_prepared)
64-
{
65-
kernel_casted->prepare(tensors);
66-
_is_prepared = true;
67-
}
68-
69-
const size_t split_dimension = kernel_casted->get_split_dimension_hint();
59+
auto split_dimension = static_cast<kernels::CpuActivationKernel *>(_kernel.get())->get_split_dimension_hint();
7060
NEScheduler::get().schedule_op(_kernel.get(), split_dimension, _kernel->window(), tensors);
7161
}
7262

src/cpu/operators/CpuActivation.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2023, 2025 Arm Limited.
2+
* Copyright (c) 2021-2023 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -21,8 +21,8 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
2323
*/
24-
#ifndef ACL_SRC_CPU_OPERATORS_CPUACTIVATION_H
25-
#define ACL_SRC_CPU_OPERATORS_CPUACTIVATION_H
24+
#ifndef ARM_COMPUTE_CPU_ACTIVATION_H
25+
#define ARM_COMPUTE_CPU_ACTIVATION_H
2626

2727
#include "arm_compute/function_info/ActivationLayerInfo.h"
2828

@@ -53,10 +53,7 @@ class CpuActivation : public ICpuOperator
5353

5454
// Inherited methods overridden:
5555
void run(ITensorPack &tensors) override;
56-
57-
private:
58-
bool _is_prepared{};
5956
};
6057
} // namespace cpu
6158
} // namespace arm_compute
62-
#endif // ACL_SRC_CPU_OPERATORS_CPUACTIVATION_H
59+
#endif /* ARM_COMPUTE_CPU_ACTIVATION_H */

tests/validation/NEON/ActivationLayer.cpp

Lines changed: 4 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ namespace test
5050
{
5151
namespace validation
5252
{
53-
using framework::dataset::make;
5453
namespace
5554
{
5655

@@ -63,11 +62,6 @@ const auto NeonActivationFunctionsDataset = concat(datasets::ActivationFunctions
6362

6463
/** Input data sets. */
6564
const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), NeonActivationFunctionsDataset), framework::dataset::make("AlphaBeta", { 0.5f, 1.f }));
66-
const auto ActivationDatasetForPaddingAfterConfigure = combine(
67-
make("InPlace", { false, true }),
68-
NeonActivationFunctionsDataset,
69-
make("AlphaBeta", { 0.5f })
70-
);
7165

7266
template <typename T, ARM_COMPUTE_REQUIRES_TA(arm_compute::utils::traits::is_floating_point<T>::value)>
7367
void test_float_sqrt_boundary_value()
@@ -187,8 +181,6 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
187181

188182
template <typename T>
189183
using NEActivationLayerFixture = ActivationValidationFixture<Tensor, Accessor, NEActivationLayer, T>;
190-
template <typename T>
191-
using NEActivationLayerWithPaddingFixture = ActivationWithPaddingValidationFixture<Tensor, Accessor, NEActivationLayer, T>;
192184

193185
TEST_SUITE(Float)
194186
#ifdef ARM_COMPUTE_ENABLE_FP16
@@ -212,25 +204,6 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture<half>, framework::Data
212204
framework::ARM_COMPUTE_PRINT_INFO();
213205
}
214206
}
215-
216-
FIXTURE_DATA_TEST_CASE(PaddingAfterConfigure, NEActivationLayerWithPaddingFixture<half>, framework::DatasetMode::ALL,
217-
combine(
218-
make("Shape", TensorShape{ 7U, 7U, 17U, 2U }),
219-
ActivationDatasetForPaddingAfterConfigure,
220-
make("DataType", DataType::F16))
221-
)
222-
{
223-
if(CPUInfo::get().has_fp16())
224-
{
225-
// Validate output
226-
validate(Accessor(_target), _reference, helper::relative_tolerance(_data_type, _function), 0.f, helper::absolute_tolerance(_data_type, _function));
227-
}
228-
else
229-
{
230-
ARM_COMPUTE_TEST_INFO("Device does not support fp16 vector operations. Test SKIPPED.");
231-
framework::ARM_COMPUTE_PRINT_INFO();
232-
}
233-
}
234207
TEST_SUITE_END() // FP16
235208
#endif /* ARM_COMPUTE_ENABLE_FP16 */
236209

@@ -239,45 +212,28 @@ TEST_CASE(SqrtBoundaryValue, framework::DatasetMode::ALL)
239212
{
240213
test_float_sqrt_boundary_value<float>();
241214
}
242-
FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), ActivationDataset), make("DataType",
215+
FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType",
243216
DataType::F32)))
244217

245218
{
246219
// Validate output
247220
validate(Accessor(_target), _reference, helper::relative_tolerance(_data_type, _function), 0.f, helper::absolute_tolerance(_data_type, _function));
248221
}
249-
250-
FIXTURE_DATA_TEST_CASE(PaddingAfterConfigure, NEActivationLayerWithPaddingFixture<float>, framework::DatasetMode::ALL,
251-
combine(
252-
make("Shape", TensorShape{ 7U, 7U, 17U, 2U }),
253-
ActivationDatasetForPaddingAfterConfigure,
254-
make("DataType", DataType::F32))
255-
)
256-
{
257-
validate(Accessor(_target), _reference, helper::relative_tolerance(_data_type, _function), 0.f, helper::absolute_tolerance(_data_type, _function));
258-
}
259222
// Run only on SME Devices to stress Logistic SME kernel
260223
#ifdef ARM_COMPUTE_ENABLE_SME2
261224
TEST_SUITE(SME)
262-
const auto LogisticDataset = combine(make("InPlace", { false }), make("Function", ActivationLayerInfo::ActivationFunction::LOGISTIC), make("AlphaBeta", { 1.f }));
263-
FIXTURE_DATA_TEST_CASE(RunLogistic5D, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::Tiny5dShapes(), LogisticDataset, make("DataType",
225+
const auto LogsisticDataset = combine(framework::dataset::make("InPlace", { false }), framework::dataset::make("Function", ActivationLayerInfo::ActivationFunction::LOGISTIC), framework::dataset::make("AlphaBeta", { 1.f }));
226+
FIXTURE_DATA_TEST_CASE(RunLogistic5D, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::Tiny5dShapes(), LogsisticDataset, framework::dataset::make("DataType",
264227
DataType::F32)))
265228

266229
{
267230
// Validate output
268231
validate(Accessor(_target), _reference, helper::relative_tolerance(_data_type, _function), 0.f, helper::absolute_tolerance(_data_type, _function));
269232
}
270233

271-
FIXTURE_DATA_TEST_CASE(RunLogisticSME, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::LogisticSMEStressShapesFp32(), LogisticDataset, make("DataType",
234+
FIXTURE_DATA_TEST_CASE(RunLogisticSME, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::LogisticSMEStressShapesFp32(), LogsisticDataset, framework::dataset::make("DataType",
272235
DataType::F32)))
273236

274-
{
275-
// Validate output
276-
validate(Accessor(_target), _reference, helper::relative_tolerance(_data_type, _function), 0.f, helper::absolute_tolerance(_data_type, _function));
277-
}
278-
FIXTURE_DATA_TEST_CASE(PaddingAfterConfigure, NEActivationLayerWithPaddingFixture<float>, framework::DatasetMode::ALL,
279-
combine(datasets::LogisticSMEStressShapesFp32(), LogisticDataset, make("DataType", DataType::F32)))
280-
281237
{
282238
// Validate output
283239
validate(Accessor(_target), _reference, helper::relative_tolerance(_data_type, _function), 0.f, helper::absolute_tolerance(_data_type, _function));
@@ -289,8 +245,6 @@ TEST_SUITE_END() // Float
289245

290246
template <typename T>
291247
using NEActivationLayerQuantizedFixture = ActivationValidationQuantizedFixture<Tensor, Accessor, NEActivationLayer, T>;
292-
template <typename T>
293-
using NEActivationLayerWithPaddingQuantizedFixture = ActivationWithPaddingValidationQuantizedFixture<Tensor, Accessor, NEActivationLayer, T>;
294248

295249
/** Input data sets. */
296250
const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationFunction",
@@ -309,13 +263,6 @@ const auto QuantizedActivationFunctionsDataset = framework::dataset::make("Activ
309263
const auto QuantizedActivationDataset = combine(combine(framework::dataset::make("InPlace", { false }),
310264
concat(QuantizedActivationFunctionsDataset, framework::dataset::make("ActivationFunction", ActivationLayerInfo::ActivationFunction::HARD_SWISH))),
311265
framework::dataset::make("AlphaBeta", { 0.5f, 1.f }));
312-
const auto QuantizedActivationDatasetForPaddingAfterConfigure = combine(
313-
make("InPlace", { false }),
314-
concat(QuantizedActivationFunctionsDataset,
315-
make("ActivationFunction", ActivationLayerInfo::ActivationFunction::HARD_SWISH)
316-
),
317-
make("AlphaBeta", { 0.5f})
318-
);
319266

320267
TEST_SUITE(Quantized)
321268
TEST_SUITE(QASYMM8)
@@ -327,17 +274,6 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<uint8_t>, fra
327274
// Validate output
328275
validate(Accessor(_target), _reference, helper::tolerance_qasymm8(_function));
329276
}
330-
FIXTURE_DATA_TEST_CASE(PaddingAfterConfigure, NEActivationLayerWithPaddingQuantizedFixture<uint8_t>, framework::DatasetMode::ALL,
331-
combine(
332-
make("Shape", TensorShape{ 7U, 7U, 17U, 2U }),
333-
QuantizedActivationDatasetForPaddingAfterConfigure,
334-
make("DataType", DataType::QASYMM8),
335-
make("QuantizationInfo", { QuantizationInfo(0.1f, 128.0f) }
336-
)))
337-
{
338-
// Validate output
339-
validate(Accessor(_target), _reference, helper::tolerance_qasymm8(_function));
340-
}
341277
TEST_SUITE_END() // QASYMM8
342278

343279
TEST_SUITE(QASYMM8_SIGNED)
@@ -349,17 +285,6 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<int8_t>, fram
349285
// Validate output
350286
validate(Accessor(_target), _reference, helper::tolerance_qasymm8(_function));
351287
}
352-
FIXTURE_DATA_TEST_CASE(PaddingAfterConfigure, NEActivationLayerWithPaddingQuantizedFixture<int8_t>, framework::DatasetMode::ALL,
353-
combine(
354-
make("Shape", TensorShape{ 7U, 7U, 17U, 2U }),
355-
QuantizedActivationDatasetForPaddingAfterConfigure,
356-
make("DataType", DataType::QASYMM8_SIGNED),
357-
make("QuantizationInfo", { QuantizationInfo(0.5f, 10.0f) }
358-
)))
359-
{
360-
// Validate output
361-
validate(Accessor(_target), _reference, helper::tolerance_qasymm8(_function));
362-
}
363288
TEST_SUITE_END() // QASYMM8_SIGNED
364289

365290
/** Input data sets. */
@@ -372,12 +297,6 @@ const auto Int16QuantizedActivationFunctionsDataset = framework::dataset::make("
372297
const auto Int16QuantizedActivationDataset = combine(combine(framework::dataset::make("InPlace", { false }), Int16QuantizedActivationFunctionsDataset),
373298
framework::dataset::make("AlphaBeta", { 0.5f, 1.f }));
374299

375-
const auto Int16QuantizedActivationDatasetForPaddingAfterConfigure = combine(
376-
make("InPlace", { false }),
377-
Int16QuantizedActivationFunctionsDataset,
378-
make("AlphaBeta", { 0.5f })
379-
);
380-
381300
TEST_SUITE(QSYMM16)
382301
FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallShapes(), Int16QuantizedActivationDataset),
383302
framework::dataset::make("DataType",
@@ -387,17 +306,6 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<int16_t>, fra
387306
// Validate output
388307
validate(Accessor(_target), _reference, tolerance_qsymm16);
389308
}
390-
FIXTURE_DATA_TEST_CASE(PaddingAfterConfigure, NEActivationLayerWithPaddingQuantizedFixture<int16_t>, framework::DatasetMode::ALL,
391-
combine(
392-
make("Shape", TensorShape{ 7U, 7U, 17U, 2U }),
393-
Int16QuantizedActivationDatasetForPaddingAfterConfigure,
394-
make("DataType", DataType::QSYMM16),
395-
make("QuantizationInfo", { QuantizationInfo(1.f / 32768.f, 0.f) }))
396-
)
397-
{
398-
// Validate output
399-
validate(Accessor(_target), _reference, tolerance_qsymm16);
400-
}
401309
TEST_SUITE_END() // QSYMM16
402310
TEST_SUITE_END() // Quantized
403311

0 commit comments

Comments
 (0)