Skip to content

Commit

Permalink
[CPU] Enable clang-format for aarch64 (#28071)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDuplensky authored Dec 16, 2024
1 parent b5a3c65 commit 44f7ddb
Show file tree
Hide file tree
Showing 65 changed files with 3,693 additions and 3,014 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ jobs:
level: warning
fail_on_error: true

clang-format-aarch64:
runs-on: ubuntu-22.04
if: ${{ github.repository_owner == 'openvinotoolkit' }}
permissions:
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: 'true'

- name: Install clang-format-15 and cross-compilation dependencies
run: |
sudo apt update
sudo apt --assume-yes install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu scons clang-format-15
# Run cmake with -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT in order to enable codestyle check for ITT collector
- name: CMake configure
run: cmake -DENABLE_CLANG_FORMAT=ON -DENABLE_TESTS=ON -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT -DCMAKE_TOOLCHAIN_FILE=cmake/arm64.toolchain.cmake -B build_arm64

- name: Create code style diff
run: cmake --build build_arm64 --target clang_format_fix_all -j8

- name: suggester / clang-format
if: startsWith(github.event_name, 'pull_request')
uses: reviewdog/action-suggester@db4abb16fbaabe386831e5addb7be1485d0d63d3 # v1.18.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
level: warning
fail_on_error: true

ShellCheck:
runs-on: ubuntu-22.04
if: ${{ github.repository_owner == 'openvinotoolkit' }}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,47 @@ namespace aarch64 {

class jit_convert_emitter : public jit_emitter {
public:
jit_convert_emitter(dnnl::impl::cpu::aarch64::jit_generator *host, dnnl::impl::cpu::aarch64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n, ov::element::Type exec_prc = ov::element::f32);
jit_convert_emitter(dnnl::impl::cpu::aarch64::jit_generator* host,
dnnl::impl::cpu::aarch64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n,
ov::element::Type exec_prc = ov::element::f32);

size_t get_inputs_count() const override;

protected:
void emit_data() const override;
void validate_types() const;
template <typename TReg>
void jit_convert_process(const TReg &src, const TReg &dst, ov::element::Type input_type, ov::element::Type output_type,
void jit_convert_process(const TReg& src,
const TReg& dst,
ov::element::Type input_type,
ov::element::Type output_type,
bool is_saturated) const;

ov::element::Type input_type;
ov::element::Type output_type;

private:
template <typename TReg>
inline void cvt_f16_to_f32(const TReg &src, const TReg &dst) const;
inline void cvt_f16_to_f32(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_f32_to_f16(const TReg &src, const TReg &dst) const;
inline void cvt_f32_to_f16(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_f32_to_i32(const TReg &src, const TReg &dst) const;
inline void cvt_f32_to_i32(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_i32_to_f32(const TReg &src, const TReg &dst) const;
inline void cvt_i32_to_f32(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_i32_to_i16(const TReg &src, const TReg &dst, bool is_saturated) const;
inline void cvt_i32_to_i16(const TReg& src, const TReg& dst, bool is_saturated) const;
template <typename TReg>
inline void cvt_i16_to_i32(const TReg &src, const TReg &dst) const;
inline void cvt_i16_to_i32(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_f16_to_i16(const TReg &src, const TReg &dst) const;
inline void cvt_f16_to_i16(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_i16_to_f16(const TReg &src, const TReg &dst) const;
inline void cvt_i16_to_f16(const TReg& src, const TReg& dst) const;
template <typename TReg>
inline void cvt_i16_to_byte(const TReg &src, const TReg &dst, bool is_signed, bool is_saturated) const;
inline void cvt_i16_to_byte(const TReg& src, const TReg& dst, bool is_signed, bool is_saturated) const;
template <typename TReg>
inline void cvt_byte_to_i16(const TReg &src, const TReg &dst, bool is_signed) const;
inline void cvt_byte_to_i16(const TReg& src, const TReg& dst, bool is_signed) const;
};

// This emitter is covered by specification of "Convert" operation. The implementation uses a "warp-around" conversion.
Expand All @@ -56,13 +61,15 @@ class jit_convert_emitter : public jit_emitter {
// 129 -> -127
class jit_convert_truncation_emitter : public jit_convert_emitter {
public:
jit_convert_truncation_emitter(dnnl::impl::cpu::aarch64::jit_generator *host, dnnl::impl::cpu::aarch64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n, ov::element::Type exec_prc = ov::element::f32);
jit_convert_truncation_emitter(dnnl::impl::cpu::aarch64::jit_generator* host,
dnnl::impl::cpu::aarch64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n,
ov::element::Type exec_prc = ov::element::f32);

private:
void emit_impl(const std::vector<size_t>& in_idxs, const std::vector<size_t>& out_idxs) const override;
template <dnnl::impl::cpu::aarch64::cpu_isa_t isa>
void emit_isa(const std::vector<size_t> &in_idxs, const std::vector<size_t> &out_idxs) const;
void emit_isa(const std::vector<size_t>& in_idxs, const std::vector<size_t>& out_idxs) const;
};

// This emitter is covered by the common dnnl behavior. The implementation uses a "saturation" conversion.
Expand All @@ -71,15 +78,17 @@ class jit_convert_truncation_emitter : public jit_convert_emitter {
// 129 -> 127
class jit_convert_saturation_emitter : public jit_convert_emitter {
public:
jit_convert_saturation_emitter(dnnl::impl::cpu::aarch64::jit_generator *host, dnnl::impl::cpu::aarch64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n, ov::element::Type exec_prc = ov::element::f32);
jit_convert_saturation_emitter(dnnl::impl::cpu::aarch64::jit_generator* host,
dnnl::impl::cpu::aarch64::cpu_isa_t host_isa,
const std::shared_ptr<ov::Node>& n,
ov::element::Type exec_prc = ov::element::f32);

private:
void emit_impl(const std::vector<size_t>& in_idxs, const std::vector<size_t>& out_idxs) const override;
template <dnnl::impl::cpu::aarch64::cpu_isa_t isa>
void emit_isa(const std::vector<size_t> &in_idxs, const std::vector<size_t> &out_idxs) const;
void emit_isa(const std::vector<size_t>& in_idxs, const std::vector<size_t>& out_idxs) const;
};

} // namespace aarch64
} // namespace intel_cpu
} // namespace ov
} // namespace aarch64
} // namespace intel_cpu
} // namespace ov
Loading

0 comments on commit 44f7ddb

Please sign in to comment.