-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-tidy] NO.6 enable modernize-avoid-c-arrays
check
#55774
[clang-tidy] NO.6 enable modernize-avoid-c-arrays
check
#55774
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
这个pytorch中是启用的,tensorflow中没有启用,跟pytorch对齐吧。 |
modernize-avoid-c-arrays
check
我其实是担心会有一些性能上的损失 测试代码: #include <iostream>
#include <array>
class demo1 {
public:
static constexpr uint32_t attributes_num = 1;
static const char *attributes_name[attributes_num];
};
class demo2 {
public:
static constexpr uint32_t attributes_num = 1;
const std::array<char*, attributes_num> attributes_name = {"program"};
};
const char *demo1::attributes_name[demo1::attributes_num] = {"program"};
static void charbenchmark(benchmark::State& state) {
for (auto _ : state) {
demo1 d;
benchmark::DoNotOptimize(d.attributes_name[0]);
}
}
BENCHMARK(charbenchmark);
static void arraybenchmark(benchmark::State& state) {
for (auto _ : state) {
demo2 d2;
benchmark::DoNotOptimize(d2.attributes_name[0]);
}
}
BENCHMARK(arraybenchmark); 测试网站: https://quick-bench.com/ 使用 |
release版一般会开启-O优化的吧 |
paddle/ir/core/builtin_op.h
Outdated
@@ -50,7 +50,7 @@ class IR_API GetParameterOp : public ir::Op<GetParameterOp> { | |||
using Op::Op; | |||
static const char *name() { return "builtin.get_parameter"; } | |||
static constexpr uint32_t attributes_num = 1; | |||
static const char *attributes_name[attributes_num]; | |||
const std::array<char *, attributes_num> attributes_name = {"parameter_name"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里我们是必须要设定为 static,不建议修改
存量过多拆分成几个pr来做,当前进度 |
@gouzil 我看了下任务 7 cppcoreguidelines-avoid-c-arrays,文档里说它只是任务 6 modernize-avoid-c-arrays 的一个 alias,所以表单里任务 6、7 都记上你的名字了哈,最后完成时候同时启用这俩就行 @GreatV 另外,任务 1、2 和 8、9 好像也只是 alias 的关系,我在表单里做了一下标记以免认领冲突~ |
需要解决下流水线的编译问题 |
Done |
当前commit还是进度5%不到么? |
paddle/phi/api/profiler/profiler.cc
Outdated
@@ -33,11 +33,11 @@ limitations under the License. */ | |||
#include "paddle/phi/backends/dynload/nvtx.h" | |||
#endif | |||
|
|||
PHI_DEFINE_bool(enable_host_event_recorder_hook, | |||
PHI_DEFINE_bool(enable_host_event_recorder_hook, // NOLINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
话说这些宏的话,是不是可以从宏定义处直接加 NOLINT 捏?不然可能要加很多 NOLINT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有一部分是因为第三方库引起的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个我有在paddle/phi/core/flags.h
的PHI_DEFINE_bool
宏加上了,但是还是会扫到
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个我之前试的是,好像必须在相关语句的第一行才行,第二行好像就不太行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实,修复了
是的,由于时间有点久了,先合入一部分然后我再扫一次,这个pr主要是验证可行性以及一些解决方案 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTMeow
PR types
Others
PR changes
Others
Description
@GreatV 帮忙看看是否需要引入。
(这个也不能自动修复)
相关链接: