         }
 
         int inverse(nd4j::LaunchContext *context, NDArray *input, NDArray *output) {
-            defaultContext = context;
             NDArray::prepareSpecialUse({output}, {input});
             BUILD_SINGLE_SELECTOR(input->dataType(), return inverse_, (context, input, output), FLOAT_NATIVE);
             NDArray::registerSpecialUse({output}, {input});

    static void invertUpperMatrix_(NDArray* inputMatrix, NDArray* invertedMatrix) {
        int n = inputMatrix->rows();
        invertedMatrix->setIdentity();
        auto stream = defaultContext->getCudaStream();
        if (inputMatrix->isIdentityMatrix()) { // the inverse for I is I
            return;
        }

namespace nd4j {
namespace ops {
namespace helpers {
//    template <typename T>
//    static __device__ void swapRows_(T* matrix, Nd4jLong* shape, int theFirst, int theSecond, Nd4jLong N) {
//        if (theFirst != theSecond) {
