Skip to content

Commit

Permalink
[CPU][ARM] Added debug logs to ACL Interpolate executor (openvinotool…
Browse files Browse the repository at this point in the history
…kit#25866)

### Details:
 - Added debug logs to ACL Interpolate executor to debug easier
- Remove redundant check (since it duplicates the check
https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_cpu/src/nodes/executors/acl/acl_interpolate.cpp#L135_L136)

### Tickets:
 - *ticket-id*
  • Loading branch information
alvoron authored Aug 2, 2024
1 parent 34d41ae commit da2a4e7
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_interpolate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "acl_interpolate.hpp"
#include "acl_utils.hpp"
#include "utils/debug_capabilities.h"

static bool getIndices(const ov::intel_cpu::MemoryDescPtr &desc, int& index_h, int& index_w) {
if (desc->hasLayoutType(ov::intel_cpu::LayoutType::ncsp)) {
Expand All @@ -27,7 +28,10 @@ bool ov::intel_cpu::ACLInterpolateExecutor::init(const InterpolateAttrs &interpo
auto& out_shape = dstDescs[0]->getShape().getDims();

int index_h, index_w;
if (!getIndices(dstDescs[0], index_h, index_w)) { return false; }
if (!getIndices(dstDescs[0], index_h, index_w)) {
DEBUG_LOG("ACL Interpolate unsupported layout: ", dstDescs[0]->serializeFormat());
return false;
}

if ((aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::pytorch_half_pixel && out_shape[index_h] > 1 && out_shape[index_w] > 1) ||
aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::half_pixel) {
Expand All @@ -43,6 +47,7 @@ bool ov::intel_cpu::ACLInterpolateExecutor::init(const InterpolateAttrs &interpo
acl_policy = arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR;
break;
default:
DEBUG_LOG("Unsupported interpolate mode: ", static_cast<int>(aclInterpolateAttrs.mode));
return false;
}

Expand All @@ -60,16 +65,19 @@ bool ov::intel_cpu::ACLInterpolateExecutor::init(const InterpolateAttrs &interpo
precisionToAclDataType(dstDescs[0]->getPrecision()),
getAclDataLayoutByMemoryDesc(dstDescs[0]));

if (!arm_compute::NEScale::validate(&srcTensorInfo,
&dstTensorInfo,
arm_compute::ScaleKernelInfo(acl_policy,
arm_compute::BorderMode::REPLICATE,
arm_compute::PixelValue(),
acl_coord,
false,
aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::align_corners,
getAclDataLayoutByMemoryDesc(srcDescs[0]))))
arm_compute::Status status = arm_compute::NEScale::validate(&srcTensorInfo,
&dstTensorInfo,
arm_compute::ScaleKernelInfo(acl_policy,
arm_compute::BorderMode::REPLICATE,
arm_compute::PixelValue(),
acl_coord,
false,
aclInterpolateAttrs.coordTransMode == InterpolateCoordTransMode::align_corners,
getAclDataLayoutByMemoryDesc(srcDescs[0])));
if (!status) {
DEBUG_LOG("NEScale validation failed: ", status.error_description());
return false;
}

srcTensor.allocator()->init(srcTensorInfo);
dstTensor.allocator()->init(dstTensorInfo);
Expand Down Expand Up @@ -117,23 +125,21 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupportedConfiguration(
auto& coord_mode = interpolateAttrs.coordTransMode;
auto& nearest_mode = interpolateAttrs.nearestMode;

if (coord_mode == InterpolateCoordTransMode::asymmetric &&
nearest_mode == InterpolateNearestMode::floor) {
return is_upsample;
}

if (coord_mode == InterpolateCoordTransMode::align_corners &&
nearest_mode == InterpolateNearestMode::round_prefer_ceil) {
DEBUG_LOG("InterpolateCoordTransMode::align_corners with InterpolateNearestMode::round_prefer_ceil supported");
return true;
}

if (coord_mode == InterpolateCoordTransMode::half_pixel &&
(nearest_mode == InterpolateNearestMode::simple || nearest_mode == InterpolateNearestMode::round_prefer_ceil)) {
DEBUG_LOG("InterpolateCoordTransMode half_pixel is not supported for InterpolateNearestMode simple and round_prefer_ceil");
return false;
}

if (coord_mode == InterpolateCoordTransMode::asymmetric &&
(nearest_mode == InterpolateNearestMode::simple || nearest_mode == InterpolateNearestMode::floor)) {
DEBUG_LOG("asymmetric && (simple || floor) mode with upsample: ", is_upsample);
return is_upsample;
}

Expand All @@ -142,6 +148,7 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupportedConfiguration(
if (int_factor && coord_mode != InterpolateCoordTransMode::asymmetric &&
(nearest_mode == InterpolateNearestMode::round_prefer_ceil
|| nearest_mode == InterpolateNearestMode::round_prefer_floor)) {
DEBUG_LOG("upsample && int_factor && !asymmetric && (round_prefer_ceil || round_prefer_floor) case is supported");
return true;
}
} else if (scale_h < 1 && scale_w < 1) {
Expand All @@ -151,21 +158,26 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupportedConfiguration(

if (int_factor && coord_mode != InterpolateCoordTransMode::align_corners &&
nearest_mode == InterpolateNearestMode::simple) {
DEBUG_LOG("!upsample && int_factor && !align_corners && simple case is supported");
return true;
}

if (int_factor && nearest_mode == InterpolateNearestMode::round_prefer_ceil &&
((out_shape[index_h] > 1 && out_shape[index_w] > 1) || coord_mode != InterpolateCoordTransMode::half_pixel)) {
DEBUG_LOG("!upsample && int_factor && round_prefer_ceil && (out_shape > 1 || half_pixel) case is supported");
return true;
}
}
DEBUG_LOG("ACL Interpolate executor does not support such configuration: coord_mode=", static_cast<int>(coord_mode),
" nearest_mode=", static_cast<int>(nearest_mode), " upsample=", is_upsample, " scale_h=", scale_h, " scale_w=", scale_w);
return false;
}

bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupported(const ov::intel_cpu::InterpolateAttrs &interpolateAttrs,
const std::vector<MemoryDescPtr> &srcDescs,
const std::vector<MemoryDescPtr> &dstDescs) const {
if (srcDescs[0]->getShape().getDims().size() != 4u) {
DEBUG_LOG("ACL Interpolate does not support src shape rank: ", srcDescs[0]->getShape().getDims().size());
return false;
}

Expand All @@ -174,27 +186,32 @@ bool ov::intel_cpu::ACLInterpolateExecutorBuilder::isSupported(const ov::intel_c

if (!std::all_of(pads_begin.begin(), pads_begin.end(), [](int i){return i == 0;}) ||
!std::all_of(pads_end.begin(), pads_end.end(), [](int i){return i == 0;})) {
DEBUG_LOG("ACL Interpolate does not support padding");
return false;
}

if (interpolateAttrs.antialias ||
interpolateAttrs.coordTransMode == InterpolateCoordTransMode::tf_half_pixel_for_nn ||
interpolateAttrs.nearestMode == InterpolateNearestMode::ceil) {
DEBUG_LOG("ACL Interpolate does not support antialias, tf_half_pixel_for_nn, ceil modes");
return false;
}

if (interpolateAttrs.mode == InterpolateMode::cubic ||
interpolateAttrs.mode == InterpolateMode::bilinear_pillow ||
interpolateAttrs.mode == InterpolateMode::bicubic_pillow) {
DEBUG_LOG("ACL Interpolate does not support cubic, bilinear_pillow, bicubic_pillow modes");
return false;
}

if (interpolateAttrs.mode == InterpolateMode::nearest &&
!isSupportedConfiguration(interpolateAttrs, srcDescs, dstDescs)) {
DEBUG_LOG("ACL Interpolate isSupportedConfiguration method fails for nearest mode");
return false;
}

if (interpolateAttrs.coordTransMode == InterpolateCoordTransMode::pytorch_half_pixel) {
DEBUG_LOG("ACL Interpolate does not support pytorch_half_pixel mode");
return false;
}
return true;
Expand Down

0 comments on commit da2a4e7

Please sign in to comment.