You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpInfo is stored in OpRegistry in op_register.{h/cc}. However, Operator needs its OpInfo to know which input or output is duplicated, which output is intermediate. OpRegistry needs to register Operator. There is a cycle dependency here.
In the same time, it seems we should move Kernels to OpInfo as its field. Since our OpInfo's field can be nullptr.
// in .hstructOpInfo {
...
};
extern std::unordered_map<string, OpInfo>& GlobalOpInfo();
// in .cpp// Never destroy OpInfo, Leave it to operator system. Declare it as a pointer// to avoid complex global value initialization in C++, since global value initialization// in C++ is out of order.static std::unordered_map<string, OpInfo>* g_op_info = nullptr;
std::unordered_map<string, OpInfo> GlobalOpInfo() {
if (g_op_info == nullptr) {
// No need to consider multi-thread situation
g_op_info = new std::unordered_map<string, OpInfo>();
}
return *g_op_info;
}
If it should be done, I could give a PR in next day. Help is also welcome.
The text was updated successfully, but these errors were encountered:
OpInfo
is stored inOpRegistry
inop_register.{h/cc}
. However,Operator
needs itsOpInfo
to know which input or output is duplicated, which output is intermediate.OpRegistry
needs to registerOperator
. There is a cycle dependency here.In the same time, it seems we should move
Kernels
toOpInfo
as its field. Since ourOpInfo
's field can be nullptr.Also, we should make the global OpInfo fit Google C++ style. https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables .
If it should be done, I could give a PR in next day. Help is also welcome.
The text was updated successfully, but these errors were encountered: