Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
44049cb4
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
44049cb4
编写于
7月 05, 2023
作者:
张
张春乔
提交者:
GitHub
7月 05, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CodeStyle][CINN] ruff F401 in tools/cinn (#55012)
Co-authored-by:
N
SigureMo
<
sigure.qaq@gmail.com
>
上级
6a9cbb27
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
1 addition
and
199 deletion
+1
-199
pyproject.toml
pyproject.toml
+0
-3
tools/cinn/codestyle/.gitignore
tools/cinn/codestyle/.gitignore
+0
-3
tools/cinn/codestyle/clang_format.hook
tools/cinn/codestyle/clang_format.hook
+0
-15
tools/cinn/codestyle/copyright.hook
tools/cinn/codestyle/copyright.hook
+0
-134
tools/cinn/codestyle/cpplint_pre_commit.hook
tools/cinn/codestyle/cpplint_pre_commit.hook
+0
-27
tools/cinn/paddle_benchmark/paddle_save_model.py
tools/cinn/paddle_benchmark/paddle_save_model.py
+0
-6
tools/cinn/paddle_benchmark/test_paddle_ops.py
tools/cinn/paddle_benchmark/test_paddle_ops.py
+0
-3
tools/cinn/tvm_benchmark/test_topi_default.py
tools/cinn/tvm_benchmark/test_topi_default.py
+0
-4
tools/cinn/tvm_benchmark/tvm_graph_with_single_op.py
tools/cinn/tvm_benchmark/tvm_graph_with_single_op.py
+1
-4
未找到文件。
pyproject.toml
浏览文件 @
44049cb4
...
...
@@ -108,6 +108,3 @@ ignore = [
"F632"
,
"F811"
,
]
"tools/cinn/**"
=
[
"F401"
,
]
tools/cinn/codestyle/.gitignore
已删除
100644 → 0
浏览文件 @
6a9cbb27
*.pyc
*.html
*.json
tools/cinn/codestyle/clang_format.hook
已删除
100755 → 0
浏览文件 @
6a9cbb27
#!/bin/bash
set
-e
readonly
VERSION
=
"13.0.0"
version
=
$(
clang-format
-version
)
if
!
[[
$version
==
*
"
$VERSION
"
*
]]
;
then
echo
"clang-format version check failed."
echo
"a version contains '
$VERSION
' is needed, but get '
$version
'"
echo
"you can install the right version, and make an soft-link to '
\$
PATH' env"
exit
-1
fi
clang-format
$@
tools/cinn/codestyle/copyright.hook
已删除
100644 → 0
浏览文件 @
6a9cbb27
# Copyright (c) 2020 CINN Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import io
import re
import sys
import os
import datetime
COPYRIGHT = '''Copyright (c) 2016 CINN Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.'''
def _generate_copyright(comment_mark):
copyright=COPYRIGHT.split(os.linesep)
header = copyright[0].rstrip()
p = re.search('(\d{4})', header).group(0)
now = datetime.datetime.now()
header = header.replace(p,str(now.year))
ans=[comment_mark + " " + header + os.linesep]
for idx, line in enumerate(copyright[1:]):
ans.append(comment_mark + " " + line.rstrip() + os.linesep)
return ans
def _get_comment_mark(path):
lang_type=re.compile(r"\.(py|sh)$")
if lang_type.search(path) is not None:
return "#"
lang_type=re.compile(r"\.(h|c|hpp|cc|cpp|cu|go|cuh|proto)$")
if lang_type.search(path) is not None:
return "//"
return None
RE_ENCODE = re.compile(r"^[ \t\v]*#.*?coding[:=]", re.IGNORECASE)
RE_COPYRIGHT = re.compile(r".*Copyright \(c\) \d{4}", re.IGNORECASE)
RE_SHEBANG = re.compile(r"^[ \t\v]*#[ \t]?\!")
def _check_copyright(path):
head=[]
try:
with open(path) as f:
head = [next(f) for x in range(4)]
except StopIteration:
pass
for idx, line in enumerate(head):
if RE_COPYRIGHT.search(line) is not None:
return True
return False
def generate_copyright(path, comment_mark):
original_contents = io.open(path, encoding="utf-8").readlines()
head = original_contents[0:4]
insert_line_no=0
for i, line in enumerate(head):
if RE_ENCODE.search(line) or RE_SHEBANG.search(line):
insert_line_no=i+1
copyright = _generate_copyright(comment_mark)
if insert_line_no == 0:
new_contents = copyright
if len(original_contents) > 0 and len(original_contents[0].strip()) != 0:
new_contents.append(os.linesep)
new_contents.extend(original_contents)
else:
new_contents=original_contents[0:insert_line_no]
new_contents.append(os.linesep)
new_contents.extend(copyright)
if len(original_contents) > insert_line_no and len(original_contents[insert_line_no].strip()) != 0:
new_contents.append(os.linesep)
new_contents.extend(original_contents[insert_line_no:])
new_contents="".join(new_contents)
with io.open(path, 'w') as output_file:
output_file.write(new_contents)
def main(argv=None):
parser = argparse.ArgumentParser(
description='Checker for copyright declaration.')
parser.add_argument('filenames', nargs='*', help='Filenames to check')
args = parser.parse_args(argv)
retv = 0
for path in args.filenames:
comment_mark = _get_comment_mark(path)
if comment_mark is None:
print("warning:Unsupported file", path, file=sys.stderr)
continue
if _check_copyright(path):
continue
generate_copyright(path, comment_mark)
if __name__ == '__main__':
exit(main())
tools/cinn/codestyle/cpplint_pre_commit.hook
已删除
100755 → 0
浏览文件 @
6a9cbb27
#!/bin/bash
TOTAL_ERRORS
=
0
if
[[
!
$TRAVIS_BRANCH
]]
;
then
# install cpplint on local machine.
if
[[
!
$(
which cpplint
)
]]
;
then
pip
install
cpplint
fi
# diff files on local machine.
files
=
$(
git diff
--cached
--name-status
|
awk
'$1 != "D" {print $2}'
)
else
# diff files between PR and latest commit on Travis CI.
branch_ref
=
$(
git rev-parse
"
$TRAVIS_BRANCH
"
)
head_ref
=
$(
git rev-parse HEAD
)
files
=
$(
git diff
--name-status
$branch_ref
$head_ref
|
awk
'$1 != "D" {print $2}'
)
fi
# The trick to remove deleted files: https://stackoverflow.com/a/2413151
for
file
in
$files
;
do
if
[[
$file
=
~ ^
(
patches/grpc/.
*
)
]]
;
then
continue
;
else
cpplint
--filter
=
-readability
/fn_size,-legal/copyright
--linelength
=
120
$file
;
TOTAL_ERRORS
=
$(
expr
$TOTAL_ERRORS
+
$?
)
;
fi
done
exit
$TOTAL_ERRORS
tools/cinn/paddle_benchmark/paddle_save_model.py
浏览文件 @
44049cb4
...
...
@@ -12,12 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
sys
import
numpy
import
numpy
as
np
import
paddle
from
paddle
import
fluid
,
static
...
...
tools/cinn/paddle_benchmark/test_paddle_ops.py
浏览文件 @
44049cb4
...
...
@@ -12,9 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
argparse
import
os
import
sys
import
time
import
numpy
as
np
...
...
tools/cinn/tvm_benchmark/test_topi_default.py
浏览文件 @
44049cb4
...
...
@@ -12,14 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
timeit
import
numpy
import
tvm
import
tvm.testing
from
tvm
import
te
,
topi
from
tvm.contrib
import
ndk
,
tar
dtype
=
[
"float32"
,
"float32"
,
"float32"
,
"float32"
]
target
=
"llvm"
...
...
tools/cinn/tvm_benchmark/tvm_graph_with_single_op.py
浏览文件 @
44049cb4
...
...
@@ -12,15 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
numpy
as
np
import
tvm
import
tvm.contrib.graph_runtime
as
runtime
import
tvm.relay.testing
from
tvm
import
autotvm
,
relay
,
te
from
tvm.autotvm.tuner
import
GATuner
,
GridSearchTuner
,
RandomTuner
,
XGBTuner
from
tvm.contrib.utils
import
tempdir
from
tvm
import
relay
# To test different ops, change this single-op network.
# See https://github.com/apache/incubator-tvm/blob/main/docs/langref/relay_op.rst to get the op list.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录