Matrix::MUL operators using and test Daoyuan's Paddle Function, SparseMatrixArg and Function Test#1147
Conversation
90a0f3f to
3f09139
Compare
5020971 to
2074603
Compare
2074603 to
02f5647
Compare
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
注释还得在加强,要写明白MulFunc支持哪些参数类型,比如Dense,CSR/CSC Sparse等。
另外,calc实现中的几个if逻辑也需要在这里写清楚。
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
alpha_, beta_这两个不一定需要。目前Paddle中对于Matrix::mul()的调用只有C = A * B和C = A * B + C两种,分别可以通过设置C参数的ASSIGN_TO/ADD_TO属性来实现。
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
output matrix, M * N这样的注释也并不好,并没有哪个地方解释M和N分别是什么。
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
还需要增加一个CHECK检查上面几个if都没有走到的逻辑。
paddle/function/BufferArg.h
Outdated
There was a problem hiding this comment.
SparseFormat和SparseValueType放在Matrix.h里面并不合适;Matrix.h和SparseMatrix.h里面的数据结构最终是不准备用的,所以可以考虑把这两个TensorType.h里面去。
paddle/function/BufferArg.h
Outdated
There was a problem hiding this comment.
BufferArg可以表示一个高维的data,trans_属性对3维或者4维的BufferArg无法很好的解释。
Mul Function里面的transa/transb实际是Function的属性,而不是BufferArg的属性(cblas_sgemm/cublasSgemm也一样)。
There was a problem hiding this comment.
trans_ 是数据的属性,matrix, sparse matrix里面是转置矩阵,对于更高order的Tensor,其实是有对应于矩阵转置的generalization的。https://arxiv.org/pdf/1411.1503v1.pdf
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
这里,包括后面几个API中的一些参数CHECK,实际应该是在Function里面检查。如果运行时参数错误,也需要在Function里面就能报出。
paddle/function/FunctionTest.h
Outdated
There was a problem hiding this comment.
FunctionCompare可能得加个钩子,uniform(0.001, 1)可能支持不了所有Function的参数初始化。
There was a problem hiding this comment.
Good idea. Will do it later for the future unit test cases.
bd54d72 to
6dd017f
Compare
There was a problem hiding this comment.
另外,我在#1216 (comment)
里面FunctionBase增加ops和check两个接口,在乘法接口里面也可以实现一下。
@hedaoyuan , 好的,我看一下你的PR,然后再开个PR,在MUL里面添加一下这两个接口。
我这个PR比较大一点,已经address了一下你的comments。如果你觉得没什么问题的话,要不先Approve一下?
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
cTrans_不需要吧。cblas_sgemm/cublasSgemm里面也有没有cTrans这个参数的。
另外,alpha_/beta_我觉得还是去掉吧,从目前Paddle的实现来看NeuralNetwork Computation里面并不会需要这样两个参数,去掉也可以稍微简化一点接口的用法。
paddle/function/MulOp.cpp
Outdated
There was a problem hiding this comment.
以后估计也不会支持cTrans_ == ture,所以直接去掉cTrans_更好。
…::mul(CpuMatrix, CpuMatrix)
and GpuMatrix::mul(CpuMatrix, GpuSparseMatrix)
SparseGpuMatrix::mul(GpuMatrix, GpuMatrix), CpuMatrix::mul(CpuSparseMatrix, CpuMatrix), and GpuMatrix::mul(GpuSparseMatrix, GpuMatrix)
e6f0840 to
5b1a5c1
Compare
* Fix is_zero * Use constexpr * Add CUTLASS_PRAGMA_UNROLL to loops * Avoid if branches in is_zero
Add the following Matrix::Mul operators: (#977)
Use and test Daoyuan's SparseMatrixArg, Function Test.
Write new sparse/dense matrix unit test using Function test.