-
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
[JitLayer]Pybind JitLayer VarBase Function and add python UT #44010
Conversation
… pybind-jit-layer
paddle/fluid/jit/compilation_unit.cc
Outdated
} | ||
|
||
const FunctionMap &CompilationUnit::FunctionDict() const { | ||
return function_dict_; |
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.
function_dict_ 不是一个合适的命名,因为dict是python的概念。C++里是map,下个PR可以考虑优化下
paddle/fluid/jit/compilation_unit.h
Outdated
@@ -32,8 +34,12 @@ class CompilationUnit { | |||
void SetFunction(const std::string &name, | |||
const std::shared_ptr<BaseFunction> &function); | |||
|
|||
std::vector<std::string> FunctionNames() const; | |||
|
|||
const FunctionMap &FunctionDict() const; |
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.
同上,这里的FunctionDict也不是一个好的API名
paddle/fluid/pybind/pybind.cc
Outdated
#include "paddle/phi/core/compat/convert_utils.h" | ||
#include "paddle/phi/core/lod_utils.h" | ||
#include "paddle/utils/none.h" | ||
#ifdef PADDLE_WITH_ASCEND | ||
#include "paddle/fluid/pybind/ascend_wrapper_py.h" | ||
#endif | ||
#include "paddle/fluid/jit/executor_function.h" | ||
#include "paddle/fluid/jit/layer.h" | ||
#include "paddle/fluid/jit/serializer.h" |
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.
这里三个头文件都是不需要的吧?
python/paddle/jit/layer.py
Outdated
from paddle.fluid.core import Load | ||
|
||
|
||
class Layer(): |
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.
class Layer(): | |
class Layer: | |
或者 | |
class Layer(object) |
python/paddle/jit/layer.py
Outdated
def __init__(self): | ||
self.cpp_layer = None | ||
# {name: Function} | ||
self.funciton_map = {} |
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.
self.funciton_map = {} | |
self.functions = {} |
有单词拼写错误,另外这里的dict需要使用WeakRef么?
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.
这里应该不需要WeakRef吧,funciton_map 持有的python端的 Function: self.funciton_map[name] = Function(function)
。其余的意见已经修改,感谢
python/paddle/jit/layer.py
Outdated
|
||
for name, function in function_dict.items(): | ||
self.funciton_map[name] = Function(function) | ||
setattr(self, name, self.funciton_map[name].__call__) |
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.
setattr(self, name, self.funciton_map[name].__call__) | |
setattr(self, name, self.funciton_map[name]) |
是不是不需要设置__call__,直接setattr对应的Function即可?
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
Others
PR changes
Others
Describe
[JitLayer]Pybind JitLayer VarBase Function and add python UT