Composite implementation of matrix_solve_ls that supports GPU.
(matrix, rhs, l2_regularizer)
| 275 | return math_ops.matmul(matrix, cholesky_solve(chol, rhs), adjoint_a=True) |
| 276 | |
| 277 | def _composite_impl(matrix, rhs, l2_regularizer): |
| 278 | """Composite implementation of matrix_solve_ls that supports GPU.""" |
| 279 | with ops.name_scope(name, 'matrix_solve_ls', [matrix, rhs, l2_regularizer]): |
| 280 | matrix_shape = matrix.get_shape()[-2:] |
| 281 | if matrix_shape.is_fully_defined(): |
| 282 | if matrix_shape[-2] >= matrix_shape[-1]: |
| 283 | return _overdetermined(matrix, rhs, l2_regularizer) |
| 284 | else: |
| 285 | return _underdetermined(matrix, rhs, l2_regularizer) |
| 286 | else: |
| 287 | # We have to defer determining the shape to runtime and use |
| 288 | # conditional execution of the appropriate graph. |
| 289 | matrix_shape = array_ops.shape(matrix)[-2:] |
| 290 | return control_flow_ops.cond( |
| 291 | matrix_shape[-2] >= matrix_shape[-1], |
| 292 | lambda: _overdetermined(matrix, rhs, l2_regularizer), |
| 293 | lambda: _underdetermined(matrix, rhs, l2_regularizer)) |
| 294 | |
| 295 | matrix = ops.convert_to_tensor(matrix, name='matrix') |
| 296 | if matrix.dtype == dtypes.complex128 and l2_regularizer != 0: |
no test coverage detected