mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-19 22:39:03 +00:00
Pre-commit in CI (#3029)
* Pre-commit in CI * Specify python version, and install dos2unix for remod * Refactor remod hook to correctly install dependencies * Run pre-commit
This commit is contained in:
16
.github/workflows/pre-commit.yml
vendored
Normal file
16
.github/workflows/pre-commit.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: pre-commit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [develop]
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- uses: pre-commit/action@v3.0.1
|
||||
@@ -32,9 +32,12 @@ repos:
|
||||
language: script
|
||||
types_or: [c++, text]
|
||||
verbose: true
|
||||
- id: run-remod-if-ck-tile-changed
|
||||
name: Run remod.py if ck_tile files changed
|
||||
entry: script/remod_for_ck_tile.sh
|
||||
language: script
|
||||
- id: remod-ck-tile
|
||||
name: Run ck_tile remod.py
|
||||
entry: python script/remod_for_ck_tile.py
|
||||
language: python
|
||||
files: '^(include|example)/ck_tile/.*$'
|
||||
additional_dependencies:
|
||||
- dos2unix
|
||||
- clang-format==18.1.3
|
||||
pass_filenames: false
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import pathlib
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
@@ -10,8 +11,12 @@ for p in sorted(Path("./").rglob("*")):
|
||||
|
||||
# formatting
|
||||
for x in all_files:
|
||||
subprocess.Popen(f"dos2unix -n {str(x)}", shell=True)
|
||||
cmd = f"clang-format-18 -style=file -i {str(x)}"
|
||||
subprocess.Popen(
|
||||
f"python -m dos2unix {str(x)} {str(x)}",
|
||||
shell=True,
|
||||
stdout=open(os.devnull, "wb"),
|
||||
)
|
||||
cmd = f"clang-format -style=file -i {str(x)}"
|
||||
# for xp in x.parents:
|
||||
# print(get_file_base(x))
|
||||
subprocess.Popen(cmd, shell=True)
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
#include "ck_tile/ops/gemm/kernel/gemm_multi_abd_kernel.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/gemm_multi_d_kernel.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/gemm_tile_partitioner.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/streamk_gemm_tile_partitioner.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/grouped_gemm_kernel.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/streamk_gemm_kernel.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/streamk_gemm_tile_partitioner.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/streamk_gemm_tile_partitioner_impl.hpp"
|
||||
#include "ck_tile/ops/gemm/kernel/universal_gemm_kernel.hpp"
|
||||
#include "ck_tile/ops/gemm/pipeline/gemm_pipeline_ag_bg_cr_base.hpp"
|
||||
#include "ck_tile/ops/gemm/pipeline/gemm_pipeline_ag_bg_cr_comp_async.hpp"
|
||||
|
||||
@@ -86,8 +86,12 @@ class submodule_t:
|
||||
submodule = submodule_t()
|
||||
# formatting
|
||||
for x in all_files:
|
||||
subprocess.Popen(f"dos2unix -n {str(x)}", shell=True)
|
||||
cmd = f"clang-format-18 -style=file -i {str(x)}"
|
||||
subprocess.Popen(
|
||||
f"python -m dos2unix {str(x)} {str(x)}",
|
||||
shell=True,
|
||||
stdout=open(os.devnull, "wb"),
|
||||
)
|
||||
cmd = f"clang-format -style=file -i {str(x)}"
|
||||
# for xp in x.parents:
|
||||
# print(get_file_base(x))
|
||||
subprocess.Popen(cmd, shell=True)
|
||||
|
||||
@@ -13,9 +13,6 @@ echo "I: Creating and activating virtual environment for pre-commit..."
|
||||
python3 -m venv "$(dirname "$0")/../.venv"
|
||||
source "$(dirname "$0")/../.venv/bin/activate"
|
||||
|
||||
echo "I: Installing tools required for pre-commit checks..."
|
||||
run_and_check pip install dos2unix
|
||||
run_and_check pip install clang-format==18.1.3
|
||||
echo "I: Installing pre-commit in virtual environment..."
|
||||
run_and_check pip install pre-commit
|
||||
run_and_check pre-commit install
|
||||
|
||||
13
script/remod_for_ck_tile.py
Executable file
13
script/remod_for_ck_tile.py
Executable file
@@ -0,0 +1,13 @@
|
||||
import os
|
||||
|
||||
root_dir = os.getcwd()
|
||||
ck_tile_include = root_dir + "/include/ck_tile"
|
||||
ck_tile_example = root_dir + "/example/ck_tile"
|
||||
|
||||
# Run for include
|
||||
os.chdir(ck_tile_include)
|
||||
_ = os.system("python remod.py")
|
||||
|
||||
# Run for example
|
||||
os.chdir(ck_tile_example)
|
||||
_ = os.system("python remod.py")
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# Run remod.py in both required locations
|
||||
(cd include/ck_tile/ && python3 remod.py)
|
||||
(cd example/ck_tile/ && python3 remod.py)
|
||||
Reference in New Issue
Block a user