-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New operators linalg_syrk, linalg_gelqf #7741
Conversation
|
||
Examples:: | ||
|
||
// Single matrix multiply | ||
A = [[1.0, 1.0], [1.0, 1.0]] | ||
B = [[1.0, 1.0], [1.0, 1.0], [1.0, 1.0]] | ||
gemm2(A, B, transpose_b = 1, alpha = 2.0) |
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.
Apparently some general renaming has happened recently for namespace reasons. All documentation now uses function names without linalg_prefix.
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.
OK, I will change the docstrings
src/operator/tensor/la_op.cc
Outdated
@@ -251,42 +253,42 @@ NNVM_REGISTER_OP(_backward_linalg_potri) | |||
.set_attr<nnvm::TIsBackward>("TIsBackward", true) | |||
.set_attr<FCompute>("FCompute<cpu>", LaOpBackward<cpu, 2, 2, 3, 1, potri_backward>); | |||
|
|||
NNVM_REGISTER_OP(_linalg_trmm) | |||
NNVM_REGISTER_OP(linalg_trmm) |
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.
All these operators are now registered with an initial underscore followed by an alias for backward compatibility.
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.
OK, I will do this
src/operator/tensor/la_op.cc
Outdated
@@ -420,5 +421,134 @@ NNVM_REGISTER_OP(_backward_linalg_sumlogdiag) | |||
.set_attr<nnvm::TIsBackward>("TIsBackward", true) | |||
.set_attr<FCompute>("FCompute<cpu>", LaOpBackward<cpu, 2, 2, 2, 1, sumlogdiag_backward>); | |||
|
|||
NNVM_REGISTER_OP(linalg_syrk) |
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.
Initial underscore followed by alias (as well as in the other new operators)
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.
OK, will do this
src/operator/tensor/la_op.h
Outdated
if ( ndim < dim ) { | ||
return false; | ||
} | ||
CHECK_GE(ndim, dim) << "Shape of input has too few dimensions"; |
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.
Please leave original code. We may have ndim < dim in the case where the input shape has not yet been defined at all (but may be defined later). Means at this point in time we can't do any inference but not necessary that we can't ever (in a subsequent pass).
src/operator/linalg.h
Outdated
// CPU/GPU-versions of LAPACK functions "gelqf", "orglq". Please refer to the | ||
// LAPACK documentation for further details. | ||
// Note: | ||
// - The current implementation works for CPU only. In particular, when called |
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.
There are no separate batch mode functions for this. So we should not refer to batch mode functions in this comment or add batch mode functions.
docs/api/python/symbol.md
Outdated
@@ -526,6 +526,8 @@ Composite multiple symbols into a new one by an operator. | |||
linalg_trmm | |||
linalg_trsm | |||
linalg_sumlogdiag | |||
linalg_syrk |
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.
wrong indentation
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.
Done
what's the status on this? |
I managed to run all unit tests in continuous-integration/jenkins/pr-head, except for the R ones. They fail for funny reasons, which seem nothing to do with my changes. I am trying again. |
Unit tests for esoteric APIs (Perl, R, Scala) fail with: Remote call on mxnet14 failed I fail to see what this has to do with my code changes. Not interested in these APIs (or should I be?). |
The R/Perl-unit tests were failing because of a git-issue. All other ones did pass. I did a full review and IMO all is fine now. There will be a followup PR by me in a week or so that will bring in the CUDA support for these new operators. So from my point of view, this can be integrated. Just would like to have confirmation from Matthias that the documentation changes look as expected when formatted. |
Yes I confirmed all docstrings in the tool you sent me, they all look fine. |
Thank you Eric for the incredible turnaround time |
@@ -526,6 +526,8 @@ Composite multiple symbols into a new one by an operator. | |||
linalg_trmm | |||
linalg_trsm | |||
linalg_sumlogdiag | |||
linalg_syrk | |||
linalg_gelqf |
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.
I assume ndarray.md
should be updated, too?
const Tensor<cpu, 2, DType>& B, DType alpha, \ | ||
DType beta, bool tA, Stream<cpu> *s) { \ | ||
check_syrk(A, B, alpha, beta, tA); \ | ||
cblas_##fname(CblasRowMajor, CblasLower, (tA ? CblasTrans : CblasNoTrans), \ |
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.
Hi, MXNet.jl got compilation error when build from MXNet's master:
https://travis-ci.org/dmlc/MXNet.jl/jobs/272939237#L1213
any idea?
src/operator/contrib/./../linalg_impl.h:782:1: note: in expansion of macro ‘LINALG_CPU_SYRK’
LINALG_CPU_SYRK(ssyrk, float)
^
src/operator/contrib/./../linalg_impl.h: In function ‘void linalg_syrk(const mshadow::Tensor<Device, 2, DType>&, const mshadow::Tensor<Device, 2, DType>&, DType, DType, bool, mshadow::Stream<Device>*) [with xpu = mshadow::cpu; DType = double]’:
src/operator/contrib/./../linalg_impl.h:748:61: error: ‘cblas_dsyrk’ was not declared in this scope
A.dptr_, A.stride_, beta, B.dptr_, B.stride_); \
^
src/operator/contrib/./../linalg_impl.h:783:1: note: in expansion of macro ‘LINALG_CPU_SYRK’
LINALG_CPU_SYRK(dsyrk, double)
^
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.
Hello, {s|d}syrk is a BLAS function, which can be called as cblas_{s|d}syrk (via the cblas interface).
For whatever reason, this does not work in your particular setup. What is quite odd about this is that linalg_impl.h calls a range of other cblas_XXX functions:
cblas_*gemm, cblas_*trmm, cblas_*trsm (where * in s, d).
AFAIK, cblas has all of these AND cblas_*syrk.
Are you getting errors for the other cblas calls as well?
Maybe @asmushetzel has an idea what is going on here?
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.
I finally figured out that MXNet.jl needs a modified cblas.h
: https://github.com/dmlc/MXNet.jl/blob/master/deps/cblas.h
I will manage to send a patch for that. @mseeger thanks for your time and explanation!
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.
It seems that your cblas.h is edited, right? This is not good. Maybe find out what Julia is doing there?
We may rely on further blas functions in the future, so better try and get the correct cblas.h being used
Looks as if we don't have testing Julia-build on Jenkins. That's why such things slip through. |
This was also my thought. Why do they edit cblas.h? Just to save some compile time? |
@asmushetzel