Skip to content

Commit 3053264

Browse files
authored
[CI] Enable Lint (#9)
1 parent 5190082 commit 3053264

9 files changed

Lines changed: 49 additions & 27 deletions

File tree

.github/workflows/main.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
runs-on: ubuntu-latest
180180
env:
181181
PLATFORM: cpu
182-
DOCKER_RUN: docker/bash.sh --env PLATFORM --env SKIP_SLOW_TESTS --env TEST_STEP_NAME
182+
DOCKER_RUN: docker/bash.sh --env PLATFORM --env SKIP_SLOW_TESTS --env TEST_STEP_NAME
183183
steps:
184184
- uses: actions/checkout@v2
185185
with:
@@ -196,7 +196,7 @@ jobs:
196196
run: >-
197197
$DOCKER_RUN $IMAGE ./tests/scripts/task_config_build_cpu.sh build &&
198198
echo "set(USE_MACA OFF)" >> build/config.cmake &&
199-
$DOCKER_RUN $IMAGE tests/scripts/task_build.py --build-dir build &&
199+
$DOCKER_RUN $IMAGE tests/scripts/task_build.py --build-dir build &&
200200
$DOCKER_RUN $IMAGE ./tests/scripts/task_build.py --build-dir build --cmake-target cpptest
201201
- name: Run CPP unit test
202202
shell: bash -l {0}
@@ -210,4 +210,26 @@ jobs:
210210
$DOCKER_RUN $IMAGE ./tests/scripts/task_python_unittest.sh
211211
env:
212212
TEST_STEP_NAME: "CPU unittest: python"
213-
213+
Ci_Lint:
214+
if: ${{ github.repository == 'MetaX-MACA/mcTVM' }}
215+
runs-on: ubuntu-latest
216+
env:
217+
PLATFORM: cpu
218+
DOCKER_RUN: docker/bash.sh --env CI --env PLATFORM --env TVM_SHARD_INDEX --env TVM_NUM_SHARDS --env RUN_DISPLAY_URL --env PLATFORM --env SKIP_SLOW_TESTS --env TEST_STEP_NAME
219+
steps:
220+
- uses: actions/checkout@v2
221+
with:
222+
submodules: 'recursive'
223+
- name: Pull Image
224+
shell: bash -l {0}
225+
run: >-
226+
python ./ci/scripts/jenkins/determine_docker_images.py ci_lint &&
227+
image=$(cat .docker-image-names/ci_lint) &&
228+
docker pull $image &&
229+
echo "IMAGE=$image" >> $GITHUB_ENV
230+
- name: Run Lint
231+
shell: bash -l {0}
232+
run: >-
233+
$DOCKER_RUN $IMAGE ./tests/scripts/task_lint.sh
234+
env:
235+
TEST_STEP_NAME: "Lint"

.pre-commit-config.yaml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,56 +31,53 @@
3131
# - $ pre-commit run
3232
#
3333

34-
default_language_version:
35-
python: python3.6
3634
fail_fast: True
37-
default_stages: [push]
35+
default_stages: [pre-push]
3836
repos:
3937
- repo: https://github.com/pre-commit/pre-commit-hooks
40-
rev: v2.3.0
38+
rev: v5.0.0
4139
hooks:
4240
- id: check-added-large-files
4341
- id: check-merge-conflict
4442
- id: check-yaml
4543
- id: end-of-file-fixer
46-
stages: [push]
4744
- id: trailing-whitespace
48-
stages: [push]
45+
4946
- repo: local
5047
hooks:
5148
- id: run-black
5249
name: Running Black...
53-
entry: docker/lint.sh python_format
50+
entry: script -q -c "bash docker/lint.sh -i python_format" /dev/null
5451
language: system
5552
always_run: true
5653
pass_filenames: false
5754
- id: run-file-checks
5855
name: Checking File Types....
59-
entry: docker/lint.sh file_type
56+
entry: script -q -c "bash docker/lint.sh file_type" /dev/null
6057
language: system
6158
always_run: true
6259
pass_filenames: false
6360
- id: run-headers-check
6461
name: Checking ASF License Headers ...
65-
entry: docker/lint.sh asf
62+
entry: script -q -c "bash docker/lint.sh asf" /dev/null
6663
language: system
6764
always_run: true
6865
pass_filenames: false
6966
- id: run-headers-check
7067
name: Linting the C++ code ...
71-
entry: docker/lint.sh cpplint
68+
entry: script -q -c "bash docker/lint.sh cpplint" /dev/null
7269
language: system
7370
always_run: true
7471
pass_filenames: false
7572
- id: run-clang-format
7673
name: Checking Clang format ...
77-
entry: docker/lint.sh clang_format
74+
entry: script -q -c "bash docker/lint.sh clang_format" /dev/null
7875
language: system
7976
always_run: true
8077
pass_filenames: false
8178
- id: run-mypy
8279
name: Type Checking with MyPY ...
83-
entry: docker/lint.sh mypy
80+
entry: script -q -c "bash docker/lint.sh mypy" /dev/null
8481
language: system
8582
always_run: true
8683
pass_filenames: false
@@ -90,3 +87,4 @@ repos:
9087
language: system
9188
always_run: true
9289
pass_filenames: false
90+
stages: [commit]

python/tvm/contrib/mxcc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import re
1919
import subprocess
2020
import os
21-
from os.path import join, exists
2221

2322
import tvm.ffi
2423
import tvm.runtime
@@ -28,7 +27,9 @@
2827
from . import utils
2928

3029

31-
def compile_maca(code, target_format="mcbin", arch=None, options=None, path_target=None):
30+
def compile_maca(
31+
code, target_format="mcbin", arch=None, options=None, path_target=None
32+
): # pylint: disable=unused-argument
3233
"""Compile maca code with MXCC from env.
3334
3435
Parameters
@@ -175,7 +176,7 @@ def have_fp16(compute_version):
175176
compute_version: str
176177
compute capability of a GPU (e.g. "6.0")
177178
"""
178-
major, minor = parse_compute_version(compute_version)
179+
major, minor = parse_compute_version(compute_version) # pylint: disable=unused-variable
179180
if major >= 10:
180181
return True
181182

@@ -287,7 +288,7 @@ def get_target_compute_version(target=None):
287288

288289

289290
@tvm.ffi.register_func("tvm.contrib.mxcc.supports_fp8")
290-
def have_fp8(compute_version):
291+
def have_fp8(compute_version): # pylint: disable=unused-argument
291292
"""Whether fp8 support is provided in the specified compute capability or not
292293
293294
Parameters

python/tvm/tir/tensor_intrin/maca.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
# under the License.
1717
# pylint: disable=invalid-name,missing-function-docstring,unused-variable
1818
"""Intrinsics for tensorization on MetaX GPU."""
19-
from typing import Dict, Literal, Optional, Tuple
19+
from typing import Dict, Literal, Tuple
2020

21-
from tvm.ffi import register_func
22-
from tvm.runtime import convert
2321
from tvm.script import tir as T
2422
from tvm.tir import Cast, IntImm, TensorIntrin
2523
from tvm.tir.function import PrimFunc

src/meta_schedule/schedule_rule/schedule_rule.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Array<ScheduleRule> ScheduleRule::DefaultMACA() {
429429
}
430430

431431
Array<ScheduleRule> ScheduleRule::DefaultMACAWMMA() {
432-
// TODO: ENABLE MMA OF MACA
432+
// TODO(metax): ENABLE MMA OF MACA
433433
Array<Map<String, String>> wmma_intrin_groups = {
434434
// Tensor Cores f32 += f32 * f32
435435
{

src/runtime/maca/maca_device_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class MACADeviceAPI final : public DeviceAPI {
109109
return;
110110
}
111111
case kApiVersion: {
112-
//*rv = MACA_VERSION;
112+
// *rv = MACA_VERSION;
113113
return;
114114
}
115115
case kDriverVersion:

src/target/source/codegen_maca.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <tvm/tir/index_map.h>
2929
#include <tvm/tir/stmt_functor.h>
3030

31+
#include <algorithm>
3132
#include <cmath>
3233
#include <string>
3334
#include <utility>
@@ -1152,9 +1153,9 @@ void CodeGenMACA::VisitStmt_(const AttrStmtNode* op) {
11521153
auto wait_attrs = GetAsyncWaitAttributes(op);
11531154
auto queue_id = wait_attrs.first.as<IntImmNode>();
11541155
ICHECK(queue_id && queue_id->value == 0) << "For MACA, the index of an async queue must be 0.";
1155-
// TODO: Because the data type of the operation written into this block cannot be obtained
1156-
// temporarily, for a barrier_arrive_and_wait function that only involves one type of data,
1157-
// assume that if there is a method to obtain it in the future, replace the bit here.
1156+
// TODO(metax): Because the data type of the operation written into this block cannot be
1157+
// obtained temporarily, for a barrier_arrive_and_wait function that only involves one type
1158+
// of data,assume that if there is a method to obtain it in the future, replace the bit here.
11581159
std::string bit = "";
11591160
std::string mask_ = "";
11601161
for (const auto& pair : mcDummyRetNum) {

src/target/source/codegen_maca.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <queue>
3232
#include <string>
3333
#include <unordered_map>
34+
#include <vector>
3435

3536
#include "codegen_c.h"
3637

tests/lint/check_file_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"groovy",
9595
# Python-parseable config files
9696
"ini",
97+
"png",
9798
}
9899

99100
# List of file names allowed

0 commit comments

Comments
 (0)