1818#include " acl_utils.hpp"
1919#include " cpu_memory.h"
2020#include " memory_desc/cpu_memory_desc.h"
21- #include " nodes/executors/interpolate.hpp"
2221#include " openvino/core/except.hpp"
2322#include " utils/debug_capabilities.h"
2423#include " utils/general_utils.h"
2524
26- bool ov::intel_cpu::ACLInterpolateExecutor::init (const InterpolateAttrs& interpolateAttrs,
27- const std::vector<MemoryDescPtr>& srcDescs,
28- const std::vector<MemoryDescPtr>& dstDescs,
29- const dnnl::primitive_attr& attr) {
30- aclInterpolateAttrs = interpolateAttrs;
31- InterpolateExecutor::init (aclInterpolateAttrs, srcDescs, dstDescs, attr);
25+ bool ov::intel_cpu::AclInterpolateExecutor::update (const MemoryArgs& memory) {
26+ std::vector<MemoryDescPtr> srcDescs{memory.at (ARG_SRC)->getDescPtr ()};
27+ std::vector<MemoryDescPtr> dstDescs{memory.at (ARG_DST)->getDescPtr ()};
3228 acl_coord = arm_compute::SamplingPolicy::TOP_LEFT;
3329 const auto & out_shape = dstDescs[0 ]->getShape ().getDims ();
3430
3531 static const size_t index_h = 2 ;
3632 static const size_t index_w = 3 ;
37- if ((aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::pytorch_half_pixel &&
33+ if ((aclInterpolateAttrs.coordTransMode == ov::intel_cpu:: InterpolateCoordTransMode::pytorch_half_pixel &&
3834 out_shape[index_h] > 1 && out_shape[index_w] > 1 ) ||
39- aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::half_pixel) {
35+ aclInterpolateAttrs.coordTransMode == ov::intel_cpu:: InterpolateCoordTransMode::half_pixel) {
4036 acl_coord = arm_compute::SamplingPolicy::CENTER;
4137 }
4238
4339 switch (aclInterpolateAttrs.mode ) {
44- case InterpolateMode::linear:
45- case InterpolateMode::linear_onnx:
40+ case ov::intel_cpu:: InterpolateMode::linear:
41+ case ov::intel_cpu:: InterpolateMode::linear_onnx:
4642 acl_policy = arm_compute::InterpolationPolicy::BILINEAR;
4743 break ;
48- case InterpolateMode::nearest:
44+ case ov::intel_cpu:: InterpolateMode::nearest:
4945 acl_policy = arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR;
5046 break ;
5147 default :
@@ -77,7 +73,7 @@ bool ov::intel_cpu::ACLInterpolateExecutor::init(const InterpolateAttrs& interpo
7773 arm_compute::PixelValue (),
7874 acl_coord,
7975 false ,
80- aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::align_corners,
76+ aclInterpolateAttrs.coordTransMode == ov::intel_cpu:: InterpolateCoordTransMode::align_corners,
8177 getAclDataLayoutByMemoryDesc (srcDescs[0 ])));
8278 if (!status) {
8379 DEBUG_LOG (" NEScale validation failed: " , status.error_description ());
@@ -97,29 +93,26 @@ bool ov::intel_cpu::ACLInterpolateExecutor::init(const InterpolateAttrs& interpo
9793 arm_compute::PixelValue (),
9894 acl_coord,
9995 false ,
100- aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::align_corners,
96+ aclInterpolateAttrs.coordTransMode == ov::intel_cpu:: InterpolateCoordTransMode::align_corners,
10197 getAclDataLayoutByMemoryDesc (srcDescs[0 ])));
10298 });
10399 return true ;
104100}
105101
106- void ov::intel_cpu::ACLInterpolateExecutor::exec (const std::vector<MemoryCPtr>& src,
107- const std::vector<MemoryPtr>& dst,
108- [[maybe_unused]] const void * post_ops_data_) {
109- const auto * in_ptr_ = padPreprocess (src, dst);
110- srcTensor.allocator ()->import_memory (const_cast <void *>(reinterpret_cast <const void *>(in_ptr_)));
111- dstTensor.allocator ()->import_memory (dst[0 ]->getData ());
102+ void ov::intel_cpu::AclInterpolateExecutor::execute (const MemoryArgs& memory) {
103+ srcTensor.allocator ()->import_memory (const_cast <void *>(memory.at (ARG_SRC)->getData ()));
104+ dstTensor.allocator ()->import_memory (memory.at (ARG_DST)->getData ());
112105
113106 acl_scale->run ();
114107
115108 srcTensor.allocator ()->free ();
116109 dstTensor.allocator ()->free ();
117110}
118111
119- bool ov::intel_cpu::ACLInterpolateExecutorBuilder:: isSupportedConfiguration (
112+ static bool isSupportedConfiguration (
120113 const ov::intel_cpu::InterpolateAttrs& interpolateAttrs,
121- const std::vector<MemoryDescPtr>& srcDescs,
122- const std::vector<MemoryDescPtr>& dstDescs) {
114+ const std::vector<ov::intel_cpu:: MemoryDescPtr>& srcDescs,
115+ const std::vector<ov::intel_cpu:: MemoryDescPtr>& dstDescs) {
123116 OPENVINO_ASSERT (srcDescs[0 ]->getShape ().getDims ().size () == 4 );
124117
125118 const auto & inp_shape = srcDescs[0 ]->getShape ().getDims ();
@@ -134,30 +127,32 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupportedConfiguration(
134127 const auto & coord_mode = interpolateAttrs.coordTransMode ;
135128 const auto & nearest_mode = interpolateAttrs.nearestMode ;
136129
137- if (coord_mode == InterpolateCoordTransMode::align_corners &&
138- nearest_mode == InterpolateNearestMode::round_prefer_ceil) {
130+ if (coord_mode == ov::intel_cpu:: InterpolateCoordTransMode::align_corners &&
131+ nearest_mode == ov::intel_cpu:: InterpolateNearestMode::round_prefer_ceil) {
139132 DEBUG_LOG (" InterpolateCoordTransMode::align_corners with InterpolateNearestMode::round_prefer_ceil supported" );
140133 return true ;
141134 }
142135
143- if (coord_mode == InterpolateCoordTransMode::half_pixel &&
144- (nearest_mode == InterpolateNearestMode::simple || nearest_mode == InterpolateNearestMode::round_prefer_ceil)) {
136+ if (coord_mode == ov::intel_cpu::InterpolateCoordTransMode::half_pixel &&
137+ (nearest_mode == ov::intel_cpu::InterpolateNearestMode::simple ||
138+ nearest_mode == ov::intel_cpu::InterpolateNearestMode::round_prefer_ceil)) {
145139 DEBUG_LOG (" InterpolateCoordTransMode half_pixel is not supported for InterpolateNearestMode simple and "
146140 " round_prefer_ceil" );
147141 return false ;
148142 }
149143
150- if (coord_mode == InterpolateCoordTransMode::asymmetric &&
151- (nearest_mode == InterpolateNearestMode::simple || nearest_mode == InterpolateNearestMode::floor)) {
144+ if (coord_mode == ov::intel_cpu::InterpolateCoordTransMode::asymmetric &&
145+ (nearest_mode == ov::intel_cpu::InterpolateNearestMode::simple ||
146+ nearest_mode == ov::intel_cpu::InterpolateNearestMode::floor)) {
152147 DEBUG_LOG (" asymmetric && (simple || floor) mode with upsample: " , is_upsample);
153148 return is_upsample;
154149 }
155150
156151 if (is_upsample) {
157152 bool int_factor = (scale_h == std::floor (scale_h)) && (scale_w == std::floor (scale_w));
158- if (int_factor && coord_mode != InterpolateCoordTransMode::asymmetric &&
159- (nearest_mode == InterpolateNearestMode::round_prefer_ceil ||
160- nearest_mode == InterpolateNearestMode::round_prefer_floor)) {
153+ if (int_factor && coord_mode != ov::intel_cpu:: InterpolateCoordTransMode::asymmetric &&
154+ (nearest_mode == ov::intel_cpu:: InterpolateNearestMode::round_prefer_ceil ||
155+ nearest_mode == ov::intel_cpu:: InterpolateNearestMode::round_prefer_floor)) {
161156 DEBUG_LOG (
162157 " upsample && int_factor && !asymmetric && (round_prefer_ceil || round_prefer_floor) case is supported" );
163158 return true ;
@@ -167,15 +162,15 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupportedConfiguration(
167162 float down_scale_w = static_cast <float >(inp_shape[index_w]) / out_shape[index_w];
168163 bool int_factor = (down_scale_h == std::floor (down_scale_h)) && (down_scale_w == std::floor (down_scale_w));
169164
170- if (int_factor && coord_mode != InterpolateCoordTransMode::align_corners &&
171- nearest_mode == InterpolateNearestMode::simple) {
165+ if (int_factor && coord_mode != ov::intel_cpu:: InterpolateCoordTransMode::align_corners &&
166+ nearest_mode == ov::intel_cpu:: InterpolateNearestMode::simple) {
172167 DEBUG_LOG (" !upsample && int_factor && !align_corners && simple case is supported" );
173168 return true ;
174169 }
175170
176- if (int_factor && nearest_mode == InterpolateNearestMode::round_prefer_ceil &&
171+ if (int_factor && nearest_mode == ov::intel_cpu:: InterpolateNearestMode::round_prefer_ceil &&
177172 ((out_shape[index_h] > 1 && out_shape[index_w] > 1 ) ||
178- coord_mode != InterpolateCoordTransMode::half_pixel)) {
173+ coord_mode != ov::intel_cpu:: InterpolateCoordTransMode::half_pixel)) {
179174 DEBUG_LOG (
180175 " !upsample && int_factor && round_prefer_ceil && (out_shape > 1 || half_pixel) case is supported" );
181176 return true ;
@@ -194,9 +189,10 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupportedConfiguration(
194189 return false ;
195190}
196191
197- bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupported (const ov::intel_cpu::InterpolateAttrs& interpolateAttrs,
198- const std::vector<MemoryDescPtr>& srcDescs,
199- const std::vector<MemoryDescPtr>& dstDescs) const {
192+ bool ov::intel_cpu::AclInterpolateExecutor::supports (const ov::intel_cpu::InterpolateConfig& config) {
193+ const auto & interpolateAttrs = config.attrs ;
194+ std::vector<MemoryDescPtr> srcDescs{config.descs .at (ARG_SRC)};
195+ std::vector<MemoryDescPtr> dstDescs{config.descs .at (ARG_DST)};
200196 if (srcDescs[0 ]->getShape ().getDims ().size () != 4U ) {
201197 DEBUG_LOG (" ACL Interpolate does not support src shape rank: " , srcDescs[0 ]->getShape ().getDims ().size ());
202198 return false ;
@@ -218,34 +214,37 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupported(const ov::intel_c
218214 }
219215
220216 if (interpolateAttrs.antialias ||
221- interpolateAttrs.coordTransMode == InterpolateCoordTransMode::tf_half_pixel_for_nn ||
222- interpolateAttrs.nearestMode == InterpolateNearestMode::ceil) {
217+ interpolateAttrs.coordTransMode == ov::intel_cpu:: InterpolateCoordTransMode::tf_half_pixel_for_nn ||
218+ interpolateAttrs.nearestMode == ov::intel_cpu:: InterpolateNearestMode::ceil) {
223219 DEBUG_LOG (" ACL Interpolate does not support antialias, tf_half_pixel_for_nn, ceil modes" );
224220 return false ;
225221 }
226222
227- if (interpolateAttrs.mode == InterpolateMode::cubic || interpolateAttrs.mode == InterpolateMode::bilinear_pillow ||
228- interpolateAttrs.mode == InterpolateMode::bicubic_pillow) {
223+ if (interpolateAttrs.mode == ov::intel_cpu::InterpolateMode::cubic ||
224+ interpolateAttrs.mode == ov::intel_cpu::InterpolateMode::bilinear_pillow ||
225+ interpolateAttrs.mode == ov::intel_cpu::InterpolateMode::bicubic_pillow) {
229226 DEBUG_LOG (" ACL Interpolate does not support cubic, bilinear_pillow, bicubic_pillow modes" );
230227 return false ;
231228 }
232229
233- if (interpolateAttrs.shapeCalcMode == InterpolateShapeCalcMode::scales &&
230+ if (interpolateAttrs.shapeCalcMode == ov::intel_cpu:: InterpolateShapeCalcMode::scales &&
234231 any_of (interpolateAttrs.coordTransMode ,
235- InterpolateCoordTransMode::half_pixel,
236- InterpolateCoordTransMode::asymmetric) &&
237- any_of (interpolateAttrs.mode , InterpolateMode::linear, InterpolateMode::linear_onnx)) {
232+ ov::intel_cpu::InterpolateCoordTransMode::half_pixel,
233+ ov::intel_cpu::InterpolateCoordTransMode::asymmetric) &&
234+ any_of (interpolateAttrs.mode ,
235+ ov::intel_cpu::InterpolateMode::linear,
236+ ov::intel_cpu::InterpolateMode::linear_onnx)) {
238237 DEBUG_LOG (" ACL Interpolate does not support scales mode with linear/linear_onnx and half_pixel/asymmetric" );
239238 return false ;
240239 }
241240
242- if (interpolateAttrs.mode == InterpolateMode::nearest &&
241+ if (interpolateAttrs.mode == ov::intel_cpu:: InterpolateMode::nearest &&
243242 !isSupportedConfiguration (interpolateAttrs, srcDescs, dstDescs)) {
244243 DEBUG_LOG (" ACL Interpolate isSupportedConfiguration method fails for nearest mode" );
245244 return false ;
246245 }
247246
248- if (interpolateAttrs.coordTransMode == InterpolateCoordTransMode::pytorch_half_pixel) {
247+ if (interpolateAttrs.coordTransMode == ov::intel_cpu:: InterpolateCoordTransMode::pytorch_half_pixel) {
249248 DEBUG_LOG (" ACL Interpolate does not support pytorch_half_pixel mode" );
250249 return false ;
251250 }
0 commit comments