Skip to content

Commit

Permalink
cleanup and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
eshoguli committed Sep 14, 2024
1 parent 7dd226e commit d4c30c6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2018-2024 Intel Corporation
// Copyright (C) 2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@

#include "acl_lowp_fullyconnected.hpp"

#include "acl_weights.hpp"
#include "arm_compute/runtime/NEON/functions/NEGEMMLowpMatrixMultiplyCore.h"

#include "memory_desc/cpu_memory_desc_utils.h"
#include "nodes/common/cpu_convert.h"
#include "nodes/executors/acl/acl_utils.hpp"
#include "nodes/executors/executor.hpp"
#include "nodes/executors/memory_arguments.hpp"
#include "utils/debug_capabilities.h"
#include "nodes/executors/debug_messages.hpp"
#include "nodes/executors/implementation_utils.hpp"
#include "acl_weights.hpp"
#include "acl_utils.hpp"

#include "nodes/common/cpu_convert.h"
#include "memory_desc/cpu_memory_desc_utils.h"
#include "utils/debug_capabilities.h"

namespace ov {
namespace intel_cpu {
Expand All @@ -41,9 +38,7 @@ static void initFCAttrs(const FCAttrs &attrs,
arm_compute::GEMMInfo& fullyConnectedLayerInfo,
const PostOps &postOps) {
aclTensorAttrs.hasLayoutTypeNHWC = memory.at(ARG_SRC)->getDescPtr()->hasLayoutType(LayoutType::nspc);
//fullyConnectedLayerInfo.weights_trained_layout = getAclDataLayoutByMemoryDesc(memory.at(ARG_WEI)->getDescPtr());
aclfcAttrs.inputPrecision = memory.at(ARG_SRC)->getDescPtr()->getPrecision();
//fullyConnectedLayerInfo.transpose_weights = false;
aclfcAttrs.weightsNonTransposed = attrs.weightsNonTransposed;

if (!postOps.empty()) {
Expand Down Expand Up @@ -86,11 +81,6 @@ void ACLLowpFullyConnectedExecutor::updateTensorsShapes(ACLShapes& aclMemoryShap
}

arm_compute::Status ACLLowpFullyConnectedExecutor::validateTensorsInfo(const ACLInfos & aclMemoryInfos) {
// TODO: debug only
//const auto src0 = aclMemoryInfos[ACLArgs::ACL_SRC_0].get();
//const auto src1 = aclMemoryInfos[ACLArgs::ACL_WEI].get();
//const auto dst = aclMemoryInfos[ACLArgs::ACL_DST].get();

auto &tensor_info = aclMemoryInfos[ACLArgs::ACL_SRC_0];
if (dequantizationScales.empty()) {
tensor_info->set_quantization_info(arm_compute::QuantizationInfo(1.f));
Expand All @@ -104,7 +94,7 @@ arm_compute::Status ACLLowpFullyConnectedExecutor::validateTensorsInfo(const ACL
const auto matMulValid = arm_compute::NEGEMMLowpMatrixMultiplyCore::validate(
aclMemoryInfos[ACLArgs::ACL_SRC_0].get(),
aclMemoryInfos[ACLArgs::ACL_WEI].get(),
nullptr, //aclMemoryInfos[ACLArgs::ACL_BIAS].get(),
aclMemoryInfos[ACLArgs::ACL_BIAS].get(),
aclMemoryInfos[ACLArgs::ACL_DST].get(),
gemmInfo);
return matMulValid;
Expand All @@ -126,7 +116,6 @@ ACLFunction ACLLowpFullyConnectedExecutor::configureFunction(const ACLTensors &
return gemm;
}

// TODO: move to ACLLowpExecutor
std::shared_ptr<arm_compute::TensorInfo> ACLLowpFullyConnectedExecutor::initTensorInfo(
const arm_compute::TensorShape& tensorShape,
const arm_compute::DataType& dataType,
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_weights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

#include "acl_fullyconnected.hpp"
#include "acl_utils.hpp"
#include "nodes/common/cpu_convert.h"
#include "nodes/executors/executor.hpp"
#include "nodes/executors/memory_arguments.hpp"
#include "utils/debug_capabilities.h"
#include "nodes/executors/debug_messages.hpp"
#include "nodes/executors/implementation_utils.hpp"
#include "nodes/common/cpu_convert.h"
#include "memory_desc/cpu_memory_desc_utils.h"
#include "utils/debug_capabilities.h"

namespace ov {
namespace intel_cpu {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static const TypeMapping aclFCTypeMapping {

static const TypeMapping aclLowpFCTypeMapping {
// {src, wei, bia, dst} pt<src, wei, bias, dst>
{{_i8, _i8, _any, _f32}, pt(just<i8>(), just<i8>(), just<i32>(), just<f32>())}
{{_i8, _i8, _any, _f32}, pt(just<i8>(), just<i8>(), just<f32>(), just<f32>())}
};

static const MappingNotation dnnlConvolutionMappingNotation {
Expand Down Expand Up @@ -396,7 +396,6 @@ const std::vector<ExecutorImplementation<FCAttrs>>& getImplementations() {
},
// acceptsShapes
[](const MemoryArgs& memory) -> bool {
// @todo create syntactic sugar (functor) for shape agnostic lambda
return true;
},
// create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,7 @@ void Transformations::Lpt(const std::vector<ov::element::Type>& defaultPrecision
}),
PrecisionsRestriction::create<ov::opset1::MatMul>({
{{0}, {ov::element::u8, ov::element::i8}},
#if defined(OPENVINO_ARCH_ARM64)
{{1}, {ov::element::u8, ov::element::i8}}
#else
{{1}, {ov::element::i8}}
#endif
}),
PrecisionsRestriction::create<ov::opset5::LSTMSequence>({
{{0, 1}, {ov::element::u8}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ class MatMulTransformationTestValues {
ov::builder::subgraph::FakeQuantizeOnData fqOnData1;
ov::Shape inputShape2;
ov::builder::subgraph::FakeQuantizeOnData fqOnData2;
// TODO: remove, not used
std::string expectedKernelName;
std::string expectedRuntimePrecision;
bool requantization;
};

typedef std::tuple<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ std::string MatMulTransformation::getTestCaseName(const testing::TestParamInfo<M
result <<
precision << "_" <<
targetDevice << "_" <<
"IN1=" << testValues.inputShape1 << "_" <<
testValues.inputShape1 << "_" <<
testValues.fqOnData1 << "_" <<
"IN2=" << testValues.inputShape2 << "_" <<
testValues.fqOnData2 << "_" <<
testValues.requantization;
testValues.inputShape2 << "_" <<
testValues.fqOnData2;

return result.str();
}
Expand All @@ -46,12 +45,11 @@ void MatMulTransformation::SetUp() {
init_input_shapes({ testValues.inputShape1, testValues.inputShape2 });

function = ov::builder::subgraph::MatMulFunction::getOriginal(
ov::element::f16, // precision,
precision,
testValues.inputShape1,
testValues.fqOnData1,
testValues.inputShape2,
testValues.fqOnData2,
testValues.requantization);
testValues.fqOnData2);

ov::pass::InitNodeInfo().run_on_model(function);
}
Expand All @@ -61,13 +59,10 @@ void MatMulTransformation::run() {

LayerTransformation::run();

const auto& actualType = get_runtime_precision_by_type("MatMul");
const auto expected = std::get<3>(GetParam());
EXPECT_EQ(expected.expectedRuntimePrecision, actualType);
const auto params = std::get<3>(GetParam());
const auto actualType = get_runtime_precision(params.expectedKernelName);

const auto& actualPrimitiveType = get_property_by_type("MatMul", "primitiveType");
const auto expectedPrimitiveType = "gemm_acl_i8";
EXPECT_EQ(expectedPrimitiveType, actualPrimitiveType);
EXPECT_EQ(actualType, params.expectedRuntimePrecision);
}

TEST_P(MatMulTransformation, CompareWithRefImpl) {
Expand Down

0 comments on commit d4c30c6

Please sign in to comment.