1
1
/* ******************************************************************************
2
- * Copyright 2023-2024 Arm Ltd. and affiliates
2
+ * Copyright 2023-2025 Arm Ltd. and affiliates
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
#ifndef CPU_AARCH64_ACL_LAYER_NORMALIZATION_HPP
18
18
#define CPU_AARCH64_ACL_LAYER_NORMALIZATION_HPP
19
19
20
+ #include " arm_compute/runtime/experimental/operators/CpuMeanStdDevNormalization.h"
20
21
#include " cpu/aarch64/acl_utils.hpp"
21
22
#include " cpu/cpu_layer_normalization_pd.hpp"
22
23
@@ -26,45 +27,15 @@ namespace cpu {
26
27
namespace aarch64 {
27
28
28
29
struct acl_msdnorm_obj_t {
29
- arm_compute::NEMeanStdDevNormalizationLayer msdNorm;
30
- arm_compute::Tensor src_tensor;
31
- arm_compute::Tensor dst_tensor;
30
+ arm_compute::experimental::op::CpuMeanStdDevNormalization msdNorm;
32
31
};
33
32
34
33
struct acl_msdnorm_conf_t {
35
34
arm_compute::TensorInfo data_info; // src and dst tensors
36
35
};
37
36
38
- struct acl_layer_normalization_resource_t : public resource_t {
39
- acl_layer_normalization_resource_t ()
40
- : acl_obj(utils::make_unique<acl_msdnorm_obj_t >()) {}
41
-
42
- status_t configure (
43
- const acl_msdnorm_conf_t &anp, const layer_normalization_pd_t *pd) {
44
- if (!acl_obj) return status::out_of_memory;
45
-
46
- acl_obj->src_tensor .allocator ()->init (anp.data_info );
47
- acl_obj->dst_tensor .allocator ()->init (anp.data_info );
48
-
49
- // clang-format off
50
- acl_obj->msdNorm .configure (
51
- &acl_obj->src_tensor ,
52
- &acl_obj->dst_tensor ,
53
- pd->desc ()->layer_norm_epsilon );
54
- // clang-format on
55
-
56
- return status::success;
57
- }
58
-
59
- acl_msdnorm_obj_t &get_acl_obj () const { return *acl_obj; }
60
-
61
- DNNL_DISALLOW_COPY_AND_ASSIGN (acl_layer_normalization_resource_t );
62
-
63
- private:
64
- std::unique_ptr<acl_msdnorm_obj_t > acl_obj;
65
- }; // acl_layer_normalization_resource_t
66
-
67
37
struct acl_layer_normalization_fwd_t : public primitive_t {
38
+ using Op = arm_compute::experimental::op::CpuMeanStdDevNormalization;
68
39
struct pd_t : public cpu_layer_normalization_fwd_pd_t {
69
40
using cpu_layer_normalization_fwd_pd_t ::
70
41
cpu_layer_normalization_fwd_pd_t ;
@@ -219,36 +190,23 @@ struct acl_layer_normalization_fwd_t : public primitive_t {
219
190
220
191
}; // pd_t
221
192
222
- acl_layer_normalization_fwd_t (const pd_t *apd) : primitive_t (apd) {}
223
-
224
- status_t create_resource (
225
- engine_t *engine, resource_mapper_t &mapper) const override {
226
- if (mapper.has_resource (this )) return status::success;
227
-
228
- auto r = utils::make_unique<acl_layer_normalization_resource_t >();
229
- if (!r) return status::out_of_memory;
230
-
231
- // Configure the resource based on information from primitive descriptor
232
- CHECK (r->configure (pd ()->anp , pd ()));
233
- mapper.add (this , std::move (r));
234
-
235
- return status::success;
236
- }
193
+ acl_layer_normalization_fwd_t (const pd_t *apd)
194
+ : primitive_t (apd), acl_obj(std::make_unique<acl_msdnorm_obj_t >()) {}
237
195
238
196
status_t execute (const exec_ctx_t &ctx) const override {
239
197
return execute_forward (ctx);
240
198
}
199
+ status_t init (engine_t *engine) override ;
241
200
242
201
private:
243
- // To guard the const execute_forward, the mutex must be 'mutable'
244
- mutable std::mutex mtx;
245
202
status_t execute_forward (const exec_ctx_t &ctx) const ;
246
203
const pd_t *pd () const { return (const pd_t *)primitive_t::pd ().get (); }
247
- }; // acl_layer_normalization_fwd_t
204
+ std::unique_ptr<acl_msdnorm_obj_t > acl_obj;
205
+ };
248
206
249
207
} // namespace aarch64
250
208
} // namespace cpu
251
209
} // namespace impl
252
210
} // namespace dnnl
253
211
254
- #endif // CPU_AARCH64_ACL_LAYER_NORMALIZATION_HPP
212
+ #endif // CPU_AARCH64_ACL_LAYER_NORMALIZATION_HPP
0 commit comments