Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit d768e36

Browse files
committed
update comments and docs
1 parent 9826d25 commit d768e36

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/operator/linalg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void linalg_getri(const Tensor<xpu, 2, DType>& LU,
228228

229229
// Note that this function only implements GPU version with "getriBatched" in cuBLAS.
230230
// Unlike lapack routines in cpu, it is computed out-of-place, so the final matrix
231-
// inversion is stored in A.
231+
// inverse is stored in A.
232232
template<typename xpu, typename DType>
233233
void linalg_batch_getri(const Tensor<xpu, 3, DType>& A,
234234
const Tensor<xpu, 3, DType>& LU,
@@ -237,7 +237,7 @@ void linalg_batch_getri(const Tensor<xpu, 3, DType>& A,
237237

238238
//////////////////////////////// INVERSE ////////////////////////////////////////////
239239

240-
// CPU/GPU-versions of matrix inversion combining LAPACK function "getrf" and "getri"
240+
// CPU/GPU-versions of matrix inverse combining LAPACK function "getrf" and "getri"
241241
// Note that A = inverse(B)
242242
template<typename xpu, typename DType>
243243
void linalg_batch_inverse(const Tensor<xpu, 3, DType>& A,

src/operator/linalg_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ LINALG_GPU_BATCH_GETRI(DgetriBatched, double)
14291429

14301430
//////////////////////////////// INVERSE ////////////////////////////////////////////
14311431

1432-
// CPU/GPU-versions of matrix inversion combining LAPACK function "getrf" and "getri"
1432+
// CPU/GPU-versions of matrix inverse combining LAPACK function "getrf" and "getri"
14331433

14341434
// Note A = inverse(B)
14351435
#define LINALG_CPU_BATCH_INVERSE(xpu, DType) \
@@ -1490,7 +1490,7 @@ template<> inline \
14901490
void linalg_batch_inverse<xpu, DType>(const Tensor<xpu, 3, DType>& A, \
14911491
const Tensor<xpu, 3, DType>& B, \
14921492
const mxnet::OpContext& ctx) { \
1493-
LOG(FATAL) << "gpu matrix inversion requires CUDA version >= 8.0!"; \
1493+
LOG(FATAL) << "gpu matrix inverse requires CUDA version >= 8.0!"; \
14941494
}
14951495

14961496
#endif // CUDA_VERSION >= 8000
@@ -1552,7 +1552,7 @@ void linalg_batch_det_backward_helper<xpu, DType>(const Tensor<xpu, 3, DType>& L
15521552
const Tensor<xpu, 3, DType>& temp, \
15531553
const DType zero_det, \
15541554
const mxnet::OpContext& ctx) { \
1555-
LOG(FATAL) << "gpu matrix inversion requires CUDA version >= 8.0!"; \
1555+
LOG(FATAL) << "gpu matrix inverse requires CUDA version >= 8.0!"; \
15561556
}
15571557

15581558
#endif // CUDA_VERSION >= 8000

src/operator/tensor/la_op.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -952,18 +952,18 @@ If *n>2*, *det* is performed separately on the trailing two dimensions
952952
for all inputs (batch mode).
953953
954954
.. note:: The operator supports float32 and float64 data types only.
955-
.. note:: There is no gradient backwarded when det(A) == 0 because it's
956-
rarely hit upon in float point computation and the Jacobi's
957-
formula on determinant gradient is not computationally efficient
958-
when A is non-invertible.
955+
.. note:: There is no gradient backwarded when A is non-invertible (which is
956+
equivalent to det(A) = 0) because zero is rarely hit upon in float
957+
point computation and the Jacobi's formula on determinant gradient
958+
is not computationally efficient when A is non-invertible.
959959
960960
Examples::
961961
962-
Single matrix inversion
962+
Single matrix determinant
963963
A = [[1., 4.], [2., 3.]]
964964
det(A) = [-5.]
965965
966-
Batch matrix inversion
966+
Batch matrix determinant
967967
A = [[[1., 4.], [2., 3.]],
968968
[[2., 3.], [1., 4.]]]
969969
det(A) = [-5., 5.]
@@ -1006,16 +1006,18 @@ for all inputs (batch mode).
10061006
.. note:: The operator supports float32 and float64 data types only.
10071007
.. note:: The gradient is not properly defined on sign, so the gradient of
10081008
it is not backwarded.
1009+
.. note:: No gradient is backwarded when A is non-invertible. Please see
1010+
the docs of operator det for detail.
10091011
10101012
Examples::
10111013
1012-
Single matrix inversion
1014+
Single matrix signed log determinant
10131015
A = [[2., 3.], [1., 4.]]
10141016
sign, logabsdet = slogdet(A)
10151017
sign = [1.]
10161018
logabsdet = [1.609438]
10171019
1018-
Batch matrix inversion
1020+
Batch matrix signed log determinant
10191021
A = [[[2., 3.], [1., 4.]],
10201022
[[1., 2.], [2., 4.]],
10211023
[[1., 2.], [4., 3.]]]

0 commit comments

Comments
 (0)