We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
参考了下 Caffe2 里序列的实现,和 @reyoung @qingqing01 @hedaoyuan 讨论后,觉得 LODTensor 拆成两个 Variable 传入会让框架实现更简单。
LODTensor的实现思路借鉴了PaddlePaddle v2 里的 Argument , 尝试在原有 Tensor 里添加一些 member及 member function 来支持 LOD 相关的操作。
Argument
Tensor
LOD
为了实现 RNNOp -> FCOp -> RNNOp 调用过程中,LOD 的传递问题, 目前在做的是,提供类似 CloneType 的方式来推导outputs的类型,并对不感知LOD的Op保持透明。
RNNOp -> FCOp -> RNNOp
CloneType
这个思路需要继续处理下面问题:
type_info
REGISTER_INHERIENCE(child_type, father_type)
对现有框架需要的修改:
output_x->CloneType(input_x)
在查看 Caffe2 中的实现方法时, 发现Caffe2里只有一种Tensor实现,所有其他结构的信息都是通过多个Tensor组合来实现。
其中,类似LOD的一种表示在 https://caffe2.ai/docs/sparse-operations.html#null__more-complex-examples , 部分代码如下
# Assume feature types are defined somewhere as enum {PAGE_ID=1, APP_ID=2, POST_ID=3} ex1 = {1: {10, 11}, 3: {101}} ex2 = {1: {11}, 2: {50}, 3: {102, 103}} batch = {ex1, ex2}# values with lengths values = [10, 11, 101, 11, 50, 102, 103] # \____/ \_/ \_/ \_/ \______/ values_lengths = [ 2, 1, 1, 1, 2] keys = [ 1, 3, 1, 2, 3] # \_________/ \__________/ example_lengths = [ 2, 3]
可以当成3层变长sequence 的表示。
Caffe2里非Tensor的表示都是Tensor + 额外的Variable表示id信息的方式给入,比如 SparseLengthsWeightedSum
输入有4个,如下
其中, INDICES 和 LENGTHS 是与表示方式相关的额外内容。
INDICES
LENGTHS
Caffe2 如此设计的好处:
缺点:
data, seqinfo = DataProvider(xxx) rnn_out, rnn_seqinfo = RNN(rnn_in, seqinfo) fc_out = fc(rnn_in) # passin the latest sequence info. rnn_out, rnn_seqinfo1 = RNN(fc_out, rnn_seqinfo)
Caffe2的设计的确有其简单可依赖的特点,让Op及Tensor数据类型的实现更加明确,如果用这样的想法来做LODTensor接下来的工作:
衍生的好处:
The text was updated successfully, but these errors were encountered:
fix benchmark in deploy with solov2 (PaddlePaddle#3391)
1dc5c01
No branches or pull requests
参考了下 Caffe2 里序列的实现,和 @reyoung @qingqing01 @hedaoyuan 讨论后,觉得 LODTensor 拆成两个 Variable 传入会让框架实现更简单。
LODTensor 及周边设计现状
LODTensor的实现思路借鉴了PaddlePaddle v2 里的
Argument
,尝试在原有
Tensor
里添加一些 member及 member function 来支持LOD
相关的操作。为了实现
RNNOp -> FCOp -> RNNOp
调用过程中,LOD
的传递问题,目前在做的是,提供类似
CloneType
的方式来推导outputs的类型,并对不感知LOD
的Op保持透明。这个思路需要继续处理下面问题:
type_info
的继承关系的记录REGISTER_INHERIENCE(child_type, father_type)
的接口对现有框架需要的修改:
output_x->CloneType(input_x)
的接口,来自动推导output的类型caffe2 对类似结构的表示方法
在查看 Caffe2 中的实现方法时,
发现Caffe2里只有一种Tensor实现,所有其他结构的信息都是通过多个Tensor组合来实现。
其中,类似LOD的一种表示在 https://caffe2.ai/docs/sparse-operations.html#null__more-complex-examples , 部分代码如下
可以当成3层变长sequence 的表示。
Caffe2里非Tensor的表示都是Tensor + 额外的Variable表示id信息的方式给入,比如
SparseLengthsWeightedSum
输入有4个,如下
其中,
INDICES
和LENGTHS
是与表示方式相关的额外内容。Caffe2 如此设计的好处:
缺点:
一种简单但相对有扩展性的方案
Caffe2的设计的确有其简单可依赖的特点,让Op及Tensor数据类型的实现更加明确,如果用这样的想法来做LODTensor接下来的工作:
衍生的好处:
The text was updated successfully, but these errors were encountered: