Skip to content

关于 Code Style 的几个建议 #973

Closed
@wangkuiyi

Description

@wangkuiyi

之前都没有顾上跟进Paddle 计算代码的改进。今天 Github Notifications 提醒我几个关于 function 的PR的更新,我在看PR之前先学习了一下 paddle/function 里的代码。有几个建议,请 @hedaoyuan 看看:

  1. 文件名命名模式不一致,比如有 TestMain.cpp 也有 cross_map_normal_op.cpp。建议按照 Google style,统一成 test_main.cpp。

  2. 在头文件 FunctionTest.h 里有 using directive,而且这个using directive是在global namespace里。虽然可能我们预期用户只在 unit test 里include这个头文件,但是实际上我们并没法控制用户不犯错误,为了安全,建议按照 Google style guide,从头文件里去掉这些 using directives。

  3. 和我们之前的习惯一样,所有的symbol都是定义在 namespace paddle 里的。建议确保 namespace 的名字和 目录名一致。在 paddle/function 里,symbols都应该定义在 paddle::function 里:

    namespace paddle {
    namespace function {
    
    class Tensor {
    ...
    }
    
    }  // namespace function
    }  // namespace paddle
    

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions