def test_linalg_norm(): """All that I'm asking of this test is that it doesn't error out.""" x = cp.array([1, 2, 3]) l2 = cp.linalg.norm(x)
def loss(w, x, y): preds = model(w, x) loss_score = cp.mean(cp.power(preds.ravel() - y.ravel(), cp.array(2))) return loss_score
def fun(x): return cp.array([[2 * x, x + 1], [x, x]])
def test_sparse_coo_matrix(eye): """This just has to not error out.""" data = cp.array([1, 2, 3]).astype("float32") rows = cp.array([1, 2, 3]).astype("float32") cols = cp.array([1, 3, 4]).astype("float32") print(eye.shape)
def fun(x): return cp.array(x)
def fun(x): return cp.array([x, x])
def fun(x): A = cp.array([x, x * 1.0, x + 2.5]) return A + A
def fun(x): A = cp.array([[x, x * 1.0, x + 2.5], [x**2, x, x / 2.0]]) return A + A
def fun(x): # return cp.array([x, x * 1.0, x + 2.5]) return cp.array([x, x, x])
def fun(x): return cp.array([[x, x * 1.0, x + 2.5], [x**2, x, x / 2.0]])
def test_simple_append_arr(): A = cp.array([1.0, 2.0, 3.0]) b = 4.0 check_grads(cp.append, argnum=(0, 1))(A, b)
def fun(x): return cp.maximum(cp.array([x, x, 0.5]), cp.array([[x, 0.5, x], [x, x, 0.5]]))
def fun(x): return cp.min( cp.array([[x, x, x], [x, 0.5, 0.5], [0.5, 0.5, 0.5], [x, x, 0.5]]), axis=0, )
def fun(x): return cp.max(cp.array([[x, x], [x, 0.5]]), axis=1)
def test_nan_to_num(): y = cp.array([0.0, cp.nan, cp.inf, -cp.inf]) fun = lambda x: cp.sum(cp.sin(cp.nan_to_num(x + y))) x = cp.random.randn(4) check_grads(fun)(x)