-
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
LoDTensor in operators. #4151
Comments
Output<framework::LoDTensor> 请教下Output为什么一定要是 |
@jacquesqiao 上面comments确实没有解释为什么要使用
template <typename T>
T* Output(const std::string& name) const {
auto var = OutputVar(name);
return var == nullptr ? nullptr : var->GetMutable<T>();
} 这里调用 template <typename T>
T* GetMutable() {
if (!IsType<T>()) {
holder_.reset(new PlaceholderImpl<T>(new T()));
}
return static_cast<T*>(holder_->Ptr());
} 第一次调用 |
将非
|
现状理解:
问题:
|
@Superjom 我看了一下你上面comment中的三个链接,好像只有第一个链接中的 |
不是LoD 传递相关的吗? fc(lodtensor as tensor) -> lodtensor ? 如果不是这个问题或者只是选择题请忽略。 |
关于
LoDTensor
在operator里的用法,合入#4083 之后, 对于非sequence operators使用,需要注意:InferShape
里对输出用:Output<framework::LoDTensor>
Tensor
。用
SigmoidOp
举例:SigmoidKernel:
有同学觉得一些地方使用
LoDTensor
, 一些地方用Tensor
,这样有点晕,大家怎么看?如果要改的话,有两种方式:
所有operator的任何地方都用
LoDTenor
,(王益老师也强调,LoDTensor
是我们的一个特点)LoDTensor
.InferShapeContext::Output<T>(const std::string& name)
函数对Tensor特化,GetMutable<LoDTensor>
始终使用LoDTensor
:InferShapeContext::Output<Tensor>()
永远无法在scope里创造出Tensor
.大家有什么建议吗?
The text was updated successfully, but these errors were encountered: