@Override public double asum(INDArray x) { LinAlgExceptions.assertVector(x); return level1().asum(x); }
@Override public IComplexNumber asum(IComplexNDArray x) { LinAlgExceptions.assertVector(x); return level1().asum(x); }
/** * computes the sum of magnitudes of all vector elements or, for a complex vector x, the sum * * @param arr * @return */ @Override public double asum(INDArray arr) { if (arr.isSparse()) { return Nd4j.getSparseBlasWrapper().level1().asum(arr); } if (Nd4j.getExecutioner().getProfilingMode() == OpExecutioner.ProfilingMode.ALL) OpProfiler.getInstance().processBlasCall(false, arr); if (arr.data().dataType() == DataBuffer.Type.DOUBLE) { DefaultOpExecutioner.validateDataType(DataBuffer.Type.DOUBLE, arr); return dasum(arr.length(), arr, BlasBufferUtil.getBlasStride(arr)); } else if (arr.data().dataType() == DataBuffer.Type.FLOAT) { DefaultOpExecutioner.validateDataType(DataBuffer.Type.FLOAT, arr); return sasum(arr.length(), arr, BlasBufferUtil.getBlasStride(arr)); } else { DefaultOpExecutioner.validateDataType(DataBuffer.Type.HALF, arr); return hasum(arr.length(), arr, BlasBufferUtil.getBlasStride(arr)); } }
@Override public double asum(INDArray x) { LinAlgExceptions.assertVector(x); return level1().asum(x); }
@Override public IComplexNumber asum(IComplexNDArray x) { LinAlgExceptions.assertVector(x); return level1().asum(x); }
@Override public boolean terminate(double cost, double oldCost, Object[] otherParams) { INDArray gradient = (INDArray) otherParams[0]; return Nd4j.getBlasWrapper().level1().asum(gradient) == 0.0; } }