-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[IR] Type system stage2: add class Type, type uniquer utils, class IRContext #50412
[IR] Type system stage2: add class Type, type uniquer utils, class IRContext #50412
Conversation
你的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.
当前paddle的单测文件好像是以test_打头或者以_tester结尾,建议保持一致。
paddle/ir/ir_context.h
Outdated
/// \return Global parameterless for IrContext. | ||
/// | ||
static IrContext *Instance() { | ||
VLOG(4) << "=> Instance called with context (ir_context_ == " << ir_context_ |
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.
ir_context这儿多线程是不是有风险?
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/ir/type_base.h
Outdated
/// | ||
template <typename T> | ||
static void RegisterType(IrContext *ctx) { | ||
RegisterType<T>(ctx, T::type_id()); // class Type需要提供type_id接口 |
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.
这个直接调用 TypeID::get()不可以吗?
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.
LGTM
template <typename T> \ | ||
static bool classof(T val) { \ | ||
return val.type_id() == type_id(); \ | ||
} \ |
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.
add blank line here
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.
Done, tks.
|
||
DECLARE_TYPE_UTILITY_FUNCTOR(Float32Type, ir::TypeStorage); | ||
|
||
static Float32Type get(ir::IrContext *context); |
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.
I think this line can move into macro DECLARE_TYPE_UTILITY_FUNCTOR? and same for the first line?
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.
DECLARE_TYPE_UTILITY_FUNCTOR中已经提供了默认的get方法
template <typename... Args> static concrete_type get(ir::IrContext *ctx, Args... args) { return ir::TypeManager::template get<concrete_type>(ctx, args...); }
这里是针对内置类型,重载了一个get方法,直接从IrContext的缓存中获取,而上述宏定义中默认的get方法是通过TypeManager获取的
paddle/ir/CMakeLists.txt
Outdated
|
||
file(GLOB IR_SRCS "*.cc") | ||
|
||
file(GLOB IR_TEST_SRCS "*_test.cc") |
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.
Better move all tests into paddle/ir/tests
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.
Done,tks.
/// | ||
class Type { | ||
public: | ||
using StorageType = TypeStorage; |
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.
Why rename it?
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.
为了统一有参类型的Storage(TypeStorage的派生)和无参类型Storage(TypeStorage)的名字,如果都使用TypeStorage,可能会误导认为是无参类型
paddle/ir/type_base.h
Outdated
abstract_type_ = const_cast<AbstractType *>(&abstract_type); | ||
} | ||
|
||
AbstractType *abstract_type_{nullptr}; |
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.
It could be marked as not owned?
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.
Done, tks.
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.
LGTM
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.
LGTM
PR types
New features
PR changes
APIs
Describe
1. PR 主要内容:
2. Todo: