Converting Between LinearOperators and torch.Tensor

linear_operator.to_linear_operator(obj)[source]

A function which ensures that obj is a LinearOperator. - If obj is a LinearOperator, this function does nothing. - If obj is a (normal) Tensor, this function wraps it with a DenseLinearOperator.

Parameters

obj (torch.Tensor or LinearOperator) –

Return type

LinearOperator

linear_operator.to_dense(obj)[source]

A function which ensures that obj is a (normal) Tensor. - If obj is a Tensor, this function does nothing. - If obj is a LinearOperator, this function evaluates it.

Parameters

obj (LinearOperator or torch.Tensor) –

Return type

torch.Tensor