diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/_ivp/__pycache__/__init__.cpython-310.pyc b/llava_video/lib/python3.10/site-packages/scipy/integrate/_ivp/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..acfc6bad002e610499f37edd6dbb8fcdba9c9eb2 Binary files /dev/null and b/llava_video/lib/python3.10/site-packages/scipy/integrate/_ivp/__pycache__/__init__.cpython-310.pyc differ diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/_ivp/__pycache__/lsoda.cpython-310.pyc b/llava_video/lib/python3.10/site-packages/scipy/integrate/_ivp/__pycache__/lsoda.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..546a0054e1c386b7bb1a27251b657be2faf10c5f Binary files /dev/null and b/llava_video/lib/python3.10/site-packages/scipy/integrate/_ivp/__pycache__/lsoda.cpython-310.pyc differ diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/__init__.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test__quad_vec.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test__quad_vec.py new file mode 100644 index 0000000000000000000000000000000000000000..851d28f5671c3eb5821a7379547c1ba66a7e1340 --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test__quad_vec.py @@ -0,0 +1,217 @@ +import pytest + +import numpy as np +from numpy.testing import assert_allclose + +from scipy.integrate import quad_vec + +from multiprocessing.dummy import Pool + + +quadrature_params = pytest.mark.parametrize( + 'quadrature', [None, "gk15", "gk21", "trapezoid"]) + + +@quadrature_params +def test_quad_vec_simple(quadrature): + n = np.arange(10) + def f(x): + return x ** n + for epsabs in [0.1, 1e-3, 1e-6]: + if quadrature == 'trapezoid' and epsabs < 1e-4: + # slow: skip + continue + + kwargs = dict(epsabs=epsabs, quadrature=quadrature) + + exact = 2**(n+1)/(n + 1) + + res, err = quad_vec(f, 0, 2, norm='max', **kwargs) + assert_allclose(res, exact, rtol=0, atol=epsabs) + + res, err = quad_vec(f, 0, 2, norm='2', **kwargs) + assert np.linalg.norm(res - exact) < epsabs + + res, err = quad_vec(f, 0, 2, norm='max', points=(0.5, 1.0), **kwargs) + assert_allclose(res, exact, rtol=0, atol=epsabs) + + res, err, *rest = quad_vec(f, 0, 2, norm='max', + epsrel=1e-8, + full_output=True, + limit=10000, + **kwargs) + assert_allclose(res, exact, rtol=0, atol=epsabs) + + +@quadrature_params +def test_quad_vec_simple_inf(quadrature): + def f(x): + return 1 / (1 + np.float64(x) ** 2) + + for epsabs in [0.1, 1e-3, 1e-6]: + if quadrature == 'trapezoid' and epsabs < 1e-4: + # slow: skip + continue + + kwargs = dict(norm='max', epsabs=epsabs, quadrature=quadrature) + + res, err = quad_vec(f, 0, np.inf, **kwargs) + assert_allclose(res, np.pi/2, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, 0, -np.inf, **kwargs) + assert_allclose(res, -np.pi/2, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, -np.inf, 0, **kwargs) + assert_allclose(res, np.pi/2, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, np.inf, 0, **kwargs) + assert_allclose(res, -np.pi/2, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, -np.inf, np.inf, **kwargs) + assert_allclose(res, np.pi, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, np.inf, -np.inf, **kwargs) + assert_allclose(res, -np.pi, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, np.inf, np.inf, **kwargs) + assert_allclose(res, 0, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, -np.inf, -np.inf, **kwargs) + assert_allclose(res, 0, rtol=0, atol=max(epsabs, err)) + + res, err = quad_vec(f, 0, np.inf, points=(1.0, 2.0), **kwargs) + assert_allclose(res, np.pi/2, rtol=0, atol=max(epsabs, err)) + + def f(x): + return np.sin(x + 2) / (1 + x ** 2) + exact = np.pi / np.e * np.sin(2) + epsabs = 1e-5 + + res, err, info = quad_vec(f, -np.inf, np.inf, limit=1000, norm='max', epsabs=epsabs, + quadrature=quadrature, full_output=True) + assert info.status == 1 + assert_allclose(res, exact, rtol=0, atol=max(epsabs, 1.5 * err)) + + +def test_quad_vec_args(): + def f(x, a): + return x * (x + a) * np.arange(3) + a = 2 + exact = np.array([0, 4/3, 8/3]) + + res, err = quad_vec(f, 0, 1, args=(a,)) + assert_allclose(res, exact, rtol=0, atol=1e-4) + + +def _lorenzian(x): + return 1 / (1 + x**2) + + +@pytest.mark.fail_slow(10) +def test_quad_vec_pool(): + f = _lorenzian + res, err = quad_vec(f, -np.inf, np.inf, norm='max', epsabs=1e-4, workers=4) + assert_allclose(res, np.pi, rtol=0, atol=1e-4) + + with Pool(10) as pool: + def f(x): + return 1 / (1 + x ** 2) + res, _ = quad_vec(f, -np.inf, np.inf, norm='max', epsabs=1e-4, workers=pool.map) + assert_allclose(res, np.pi, rtol=0, atol=1e-4) + + +def _func_with_args(x, a): + return x * (x + a) * np.arange(3) + + +@pytest.mark.fail_slow(10) +@pytest.mark.parametrize('extra_args', [2, (2,)]) +@pytest.mark.parametrize('workers', [1, 10]) +def test_quad_vec_pool_args(extra_args, workers): + f = _func_with_args + exact = np.array([0, 4/3, 8/3]) + + res, err = quad_vec(f, 0, 1, args=extra_args, workers=workers) + assert_allclose(res, exact, rtol=0, atol=1e-4) + + with Pool(workers) as pool: + res, err = quad_vec(f, 0, 1, args=extra_args, workers=pool.map) + assert_allclose(res, exact, rtol=0, atol=1e-4) + + +@quadrature_params +def test_num_eval(quadrature): + def f(x): + count[0] += 1 + return x**5 + + count = [0] + res = quad_vec(f, 0, 1, norm='max', full_output=True, quadrature=quadrature) + assert res[2].neval == count[0] + + +def test_info(): + def f(x): + return np.ones((3, 2, 1)) + + res, err, info = quad_vec(f, 0, 1, norm='max', full_output=True) + + assert info.success is True + assert info.status == 0 + assert info.message == 'Target precision reached.' + assert info.neval > 0 + assert info.intervals.shape[1] == 2 + assert info.integrals.shape == (info.intervals.shape[0], 3, 2, 1) + assert info.errors.shape == (info.intervals.shape[0],) + + +def test_nan_inf(): + def f_nan(x): + return np.nan + + def f_inf(x): + return np.inf if x < 0.1 else 1/x + + res, err, info = quad_vec(f_nan, 0, 1, full_output=True) + assert info.status == 3 + + res, err, info = quad_vec(f_inf, 0, 1, full_output=True) + assert info.status == 3 + + +@pytest.mark.parametrize('a,b', [(0, 1), (0, np.inf), (np.inf, 0), + (-np.inf, np.inf), (np.inf, -np.inf)]) +def test_points(a, b): + # Check that initial interval splitting is done according to + # `points`, by checking that consecutive sets of 15 point (for + # gk15) function evaluations lie between `points` + + points = (0, 0.25, 0.5, 0.75, 1.0) + points += tuple(-x for x in points) + + quadrature_points = 15 + interval_sets = [] + count = 0 + + def f(x): + nonlocal count + + if count % quadrature_points == 0: + interval_sets.append(set()) + + count += 1 + interval_sets[-1].add(float(x)) + return 0.0 + + quad_vec(f, a, b, points=points, quadrature='gk15', limit=0) + + # Check that all point sets lie in a single `points` interval + for p in interval_sets: + j = np.searchsorted(sorted(points), tuple(p)) + assert np.all(j == j[0]) + + +@pytest.mark.thread_unsafe +def test_trapz_deprecation(): + with pytest.deprecated_call(match="`quadrature='trapz'`"): + quad_vec(lambda x: x, 0, 1, quadrature="trapz") diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_bvp.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_bvp.py new file mode 100644 index 0000000000000000000000000000000000000000..4ef9eb6ff0502e1113d6bea7ad1e0088633d3151 --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_bvp.py @@ -0,0 +1,714 @@ +import sys + +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + +import numpy as np +from numpy.testing import (assert_, assert_array_equal, assert_allclose, + assert_equal) +from pytest import raises as assert_raises + +from scipy.sparse import coo_matrix +from scipy.special import erf +from scipy.integrate._bvp import (modify_mesh, estimate_fun_jac, + estimate_bc_jac, compute_jac_indices, + construct_global_jac, solve_bvp) + +import pytest + + +def exp_fun(x, y): + return np.vstack((y[1], y[0])) + + +def exp_fun_jac(x, y): + df_dy = np.empty((2, 2, x.shape[0])) + df_dy[0, 0] = 0 + df_dy[0, 1] = 1 + df_dy[1, 0] = 1 + df_dy[1, 1] = 0 + return df_dy + + +def exp_bc(ya, yb): + return np.hstack((ya[0] - 1, yb[0])) + + +def exp_bc_complex(ya, yb): + return np.hstack((ya[0] - 1 - 1j, yb[0])) + + +def exp_bc_jac(ya, yb): + dbc_dya = np.array([ + [1, 0], + [0, 0] + ]) + dbc_dyb = np.array([ + [0, 0], + [1, 0] + ]) + return dbc_dya, dbc_dyb + + +def exp_sol(x): + return (np.exp(-x) - np.exp(x - 2)) / (1 - np.exp(-2)) + + +def sl_fun(x, y, p): + return np.vstack((y[1], -p[0]**2 * y[0])) + + +def sl_fun_jac(x, y, p): + n, m = y.shape + df_dy = np.empty((n, 2, m)) + df_dy[0, 0] = 0 + df_dy[0, 1] = 1 + df_dy[1, 0] = -p[0]**2 + df_dy[1, 1] = 0 + + df_dp = np.empty((n, 1, m)) + df_dp[0, 0] = 0 + df_dp[1, 0] = -2 * p[0] * y[0] + + return df_dy, df_dp + + +def sl_bc(ya, yb, p): + return np.hstack((ya[0], yb[0], ya[1] - p[0])) + + +def sl_bc_jac(ya, yb, p): + dbc_dya = np.zeros((3, 2)) + dbc_dya[0, 0] = 1 + dbc_dya[2, 1] = 1 + + dbc_dyb = np.zeros((3, 2)) + dbc_dyb[1, 0] = 1 + + dbc_dp = np.zeros((3, 1)) + dbc_dp[2, 0] = -1 + + return dbc_dya, dbc_dyb, dbc_dp + + +def sl_sol(x, p): + return np.sin(p[0] * x) + + +def emden_fun(x, y): + return np.vstack((y[1], -y[0]**5)) + + +def emden_fun_jac(x, y): + df_dy = np.empty((2, 2, x.shape[0])) + df_dy[0, 0] = 0 + df_dy[0, 1] = 1 + df_dy[1, 0] = -5 * y[0]**4 + df_dy[1, 1] = 0 + return df_dy + + +def emden_bc(ya, yb): + return np.array([ya[1], yb[0] - (3/4)**0.5]) + + +def emden_bc_jac(ya, yb): + dbc_dya = np.array([ + [0, 1], + [0, 0] + ]) + dbc_dyb = np.array([ + [0, 0], + [1, 0] + ]) + return dbc_dya, dbc_dyb + + +def emden_sol(x): + return (1 + x**2/3)**-0.5 + + +def undefined_fun(x, y): + return np.zeros_like(y) + + +def undefined_bc(ya, yb): + return np.array([ya[0], yb[0] - 1]) + + +def big_fun(x, y): + f = np.zeros_like(y) + f[::2] = y[1::2] + return f + + +def big_bc(ya, yb): + return np.hstack((ya[::2], yb[::2] - 1)) + + +def big_sol(x, n): + y = np.ones((2 * n, x.size)) + y[::2] = x + return x + + +def big_fun_with_parameters(x, y, p): + """ Big version of sl_fun, with two parameters. + + The two differential equations represented by sl_fun are broadcast to the + number of rows of y, rotating between the parameters p[0] and p[1]. + Here are the differential equations: + + dy[0]/dt = y[1] + dy[1]/dt = -p[0]**2 * y[0] + dy[2]/dt = y[3] + dy[3]/dt = -p[1]**2 * y[2] + dy[4]/dt = y[5] + dy[5]/dt = -p[0]**2 * y[4] + dy[6]/dt = y[7] + dy[7]/dt = -p[1]**2 * y[6] + . + . + . + + """ + f = np.zeros_like(y) + f[::2] = y[1::2] + f[1::4] = -p[0]**2 * y[::4] + f[3::4] = -p[1]**2 * y[2::4] + return f + + +def big_fun_with_parameters_jac(x, y, p): + # big version of sl_fun_jac, with two parameters + n, m = y.shape + df_dy = np.zeros((n, n, m)) + df_dy[range(0, n, 2), range(1, n, 2)] = 1 + df_dy[range(1, n, 4), range(0, n, 4)] = -p[0]**2 + df_dy[range(3, n, 4), range(2, n, 4)] = -p[1]**2 + + df_dp = np.zeros((n, 2, m)) + df_dp[range(1, n, 4), 0] = -2 * p[0] * y[range(0, n, 4)] + df_dp[range(3, n, 4), 1] = -2 * p[1] * y[range(2, n, 4)] + + return df_dy, df_dp + + +def big_bc_with_parameters(ya, yb, p): + # big version of sl_bc, with two parameters + return np.hstack((ya[::2], yb[::2], ya[1] - p[0], ya[3] - p[1])) + + +def big_bc_with_parameters_jac(ya, yb, p): + # big version of sl_bc_jac, with two parameters + n = ya.shape[0] + dbc_dya = np.zeros((n + 2, n)) + dbc_dyb = np.zeros((n + 2, n)) + + dbc_dya[range(n // 2), range(0, n, 2)] = 1 + dbc_dyb[range(n // 2, n), range(0, n, 2)] = 1 + + dbc_dp = np.zeros((n + 2, 2)) + dbc_dp[n, 0] = -1 + dbc_dya[n, 1] = 1 + dbc_dp[n + 1, 1] = -1 + dbc_dya[n + 1, 3] = 1 + + return dbc_dya, dbc_dyb, dbc_dp + + +def big_sol_with_parameters(x, p): + # big version of sl_sol, with two parameters + return np.vstack((np.sin(p[0] * x), np.sin(p[1] * x))) + + +def shock_fun(x, y): + eps = 1e-3 + return np.vstack(( + y[1], + -(x * y[1] + eps * np.pi**2 * np.cos(np.pi * x) + + np.pi * x * np.sin(np.pi * x)) / eps + )) + + +def shock_bc(ya, yb): + return np.array([ya[0] + 2, yb[0]]) + + +def shock_sol(x): + eps = 1e-3 + k = np.sqrt(2 * eps) + return np.cos(np.pi * x) + erf(x / k) / erf(1 / k) + + +def nonlin_bc_fun(x, y): + # laplace eq. + return np.stack([y[1], np.zeros_like(x)]) + + +def nonlin_bc_bc(ya, yb): + phiA, phipA = ya + phiC, phipC = yb + + kappa, ioA, ioC, V, f = 1.64, 0.01, 1.0e-4, 0.5, 38.9 + + # Butler-Volmer Kinetics at Anode + hA = 0.0-phiA-0.0 + iA = ioA * (np.exp(f*hA) - np.exp(-f*hA)) + res0 = iA + kappa * phipA + + # Butler-Volmer Kinetics at Cathode + hC = V - phiC - 1.0 + iC = ioC * (np.exp(f*hC) - np.exp(-f*hC)) + res1 = iC - kappa*phipC + + return np.array([res0, res1]) + + +def nonlin_bc_sol(x): + return -0.13426436116763119 - 1.1308709 * x + + +def test_modify_mesh(): + x = np.array([0, 1, 3, 9], dtype=float) + x_new = modify_mesh(x, np.array([0]), np.array([2])) + assert_array_equal(x_new, np.array([0, 0.5, 1, 3, 5, 7, 9])) + + x = np.array([-6, -3, 0, 3, 6], dtype=float) + x_new = modify_mesh(x, np.array([1], dtype=int), np.array([0, 2, 3])) + assert_array_equal(x_new, [-6, -5, -4, -3, -1.5, 0, 1, 2, 3, 4, 5, 6]) + + +def test_compute_fun_jac(): + x = np.linspace(0, 1, 5) + y = np.empty((2, x.shape[0])) + y[0] = 0.01 + y[1] = 0.02 + p = np.array([]) + df_dy, df_dp = estimate_fun_jac(lambda x, y, p: exp_fun(x, y), x, y, p) + df_dy_an = exp_fun_jac(x, y) + assert_allclose(df_dy, df_dy_an) + assert_(df_dp is None) + + x = np.linspace(0, np.pi, 5) + y = np.empty((2, x.shape[0])) + y[0] = np.sin(x) + y[1] = np.cos(x) + p = np.array([1.0]) + df_dy, df_dp = estimate_fun_jac(sl_fun, x, y, p) + df_dy_an, df_dp_an = sl_fun_jac(x, y, p) + assert_allclose(df_dy, df_dy_an) + assert_allclose(df_dp, df_dp_an) + + x = np.linspace(0, 1, 10) + y = np.empty((2, x.shape[0])) + y[0] = (3/4)**0.5 + y[1] = 1e-4 + p = np.array([]) + df_dy, df_dp = estimate_fun_jac(lambda x, y, p: emden_fun(x, y), x, y, p) + df_dy_an = emden_fun_jac(x, y) + assert_allclose(df_dy, df_dy_an) + assert_(df_dp is None) + + +def test_compute_bc_jac(): + ya = np.array([-1.0, 2]) + yb = np.array([0.5, 3]) + p = np.array([]) + dbc_dya, dbc_dyb, dbc_dp = estimate_bc_jac( + lambda ya, yb, p: exp_bc(ya, yb), ya, yb, p) + dbc_dya_an, dbc_dyb_an = exp_bc_jac(ya, yb) + assert_allclose(dbc_dya, dbc_dya_an) + assert_allclose(dbc_dyb, dbc_dyb_an) + assert_(dbc_dp is None) + + ya = np.array([0.0, 1]) + yb = np.array([0.0, -1]) + p = np.array([0.5]) + dbc_dya, dbc_dyb, dbc_dp = estimate_bc_jac(sl_bc, ya, yb, p) + dbc_dya_an, dbc_dyb_an, dbc_dp_an = sl_bc_jac(ya, yb, p) + assert_allclose(dbc_dya, dbc_dya_an) + assert_allclose(dbc_dyb, dbc_dyb_an) + assert_allclose(dbc_dp, dbc_dp_an) + + ya = np.array([0.5, 100]) + yb = np.array([-1000, 10.5]) + p = np.array([]) + dbc_dya, dbc_dyb, dbc_dp = estimate_bc_jac( + lambda ya, yb, p: emden_bc(ya, yb), ya, yb, p) + dbc_dya_an, dbc_dyb_an = emden_bc_jac(ya, yb) + assert_allclose(dbc_dya, dbc_dya_an) + assert_allclose(dbc_dyb, dbc_dyb_an) + assert_(dbc_dp is None) + + +def test_compute_jac_indices(): + n = 2 + m = 4 + k = 2 + i, j = compute_jac_indices(n, m, k) + s = coo_matrix((np.ones_like(i), (i, j))).toarray() + s_true = np.array([ + [1, 1, 1, 1, 0, 0, 0, 0, 1, 1], + [1, 1, 1, 1, 0, 0, 0, 0, 1, 1], + [0, 0, 1, 1, 1, 1, 0, 0, 1, 1], + [0, 0, 1, 1, 1, 1, 0, 0, 1, 1], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], + [1, 1, 0, 0, 0, 0, 1, 1, 1, 1], + [1, 1, 0, 0, 0, 0, 1, 1, 1, 1], + [1, 1, 0, 0, 0, 0, 1, 1, 1, 1], + [1, 1, 0, 0, 0, 0, 1, 1, 1, 1], + ]) + assert_array_equal(s, s_true) + + +def test_compute_global_jac(): + n = 2 + m = 5 + k = 1 + i_jac, j_jac = compute_jac_indices(2, 5, 1) + x = np.linspace(0, 1, 5) + h = np.diff(x) + y = np.vstack((np.sin(np.pi * x), np.pi * np.cos(np.pi * x))) + p = np.array([3.0]) + + f = sl_fun(x, y, p) + + x_middle = x[:-1] + 0.5 * h + y_middle = 0.5 * (y[:, :-1] + y[:, 1:]) - h/8 * (f[:, 1:] - f[:, :-1]) + + df_dy, df_dp = sl_fun_jac(x, y, p) + df_dy_middle, df_dp_middle = sl_fun_jac(x_middle, y_middle, p) + dbc_dya, dbc_dyb, dbc_dp = sl_bc_jac(y[:, 0], y[:, -1], p) + + J = construct_global_jac(n, m, k, i_jac, j_jac, h, df_dy, df_dy_middle, + df_dp, df_dp_middle, dbc_dya, dbc_dyb, dbc_dp) + J = J.toarray() + + def J_block(h, p): + return np.array([ + [h**2*p**2/12 - 1, -0.5*h, -h**2*p**2/12 + 1, -0.5*h], + [0.5*h*p**2, h**2*p**2/12 - 1, 0.5*h*p**2, 1 - h**2*p**2/12] + ]) + + J_true = np.zeros((m * n + k, m * n + k)) + for i in range(m - 1): + J_true[i * n: (i + 1) * n, i * n: (i + 2) * n] = J_block(h[i], p[0]) + + J_true[:(m - 1) * n:2, -1] = p * h**2/6 * (y[0, :-1] - y[0, 1:]) + J_true[1:(m - 1) * n:2, -1] = p * (h * (y[0, :-1] + y[0, 1:]) + + h**2/6 * (y[1, :-1] - y[1, 1:])) + + J_true[8, 0] = 1 + J_true[9, 8] = 1 + J_true[10, 1] = 1 + J_true[10, 10] = -1 + + assert_allclose(J, J_true, rtol=1e-10) + + df_dy, df_dp = estimate_fun_jac(sl_fun, x, y, p) + df_dy_middle, df_dp_middle = estimate_fun_jac(sl_fun, x_middle, y_middle, p) + dbc_dya, dbc_dyb, dbc_dp = estimate_bc_jac(sl_bc, y[:, 0], y[:, -1], p) + J = construct_global_jac(n, m, k, i_jac, j_jac, h, df_dy, df_dy_middle, + df_dp, df_dp_middle, dbc_dya, dbc_dyb, dbc_dp) + J = J.toarray() + assert_allclose(J, J_true, rtol=2e-8, atol=2e-8) + + +def test_parameter_validation(): + x = [0, 1, 0.5] + y = np.zeros((2, 3)) + assert_raises(ValueError, solve_bvp, exp_fun, exp_bc, x, y) + + x = np.linspace(0, 1, 5) + y = np.zeros((2, 4)) + assert_raises(ValueError, solve_bvp, exp_fun, exp_bc, x, y) + + def fun(x, y, p): + return exp_fun(x, y) + def bc(ya, yb, p): + return exp_bc(ya, yb) + + y = np.zeros((2, x.shape[0])) + assert_raises(ValueError, solve_bvp, fun, bc, x, y, p=[1]) + + def wrong_shape_fun(x, y): + return np.zeros(3) + + assert_raises(ValueError, solve_bvp, wrong_shape_fun, bc, x, y) + + S = np.array([[0, 0]]) + assert_raises(ValueError, solve_bvp, exp_fun, exp_bc, x, y, S=S) + + +def test_no_params(): + x = np.linspace(0, 1, 5) + x_test = np.linspace(0, 1, 100) + y = np.zeros((2, x.shape[0])) + for fun_jac in [None, exp_fun_jac]: + for bc_jac in [None, exp_bc_jac]: + sol = solve_bvp(exp_fun, exp_bc, x, y, fun_jac=fun_jac, + bc_jac=bc_jac) + + assert_equal(sol.status, 0) + assert_(sol.success) + + assert_equal(sol.x.size, 5) + + sol_test = sol.sol(x_test) + + assert_allclose(sol_test[0], exp_sol(x_test), atol=1e-5) + + f_test = exp_fun(x_test, sol_test) + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(rel_res**2, axis=0)**0.5 + assert_(np.all(norm_res < 1e-3)) + + assert_(np.all(sol.rms_residuals < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_with_params(): + x = np.linspace(0, np.pi, 5) + x_test = np.linspace(0, np.pi, 100) + y = np.ones((2, x.shape[0])) + + for fun_jac in [None, sl_fun_jac]: + for bc_jac in [None, sl_bc_jac]: + sol = solve_bvp(sl_fun, sl_bc, x, y, p=[0.5], fun_jac=fun_jac, + bc_jac=bc_jac) + + assert_equal(sol.status, 0) + assert_(sol.success) + + assert_(sol.x.size < 10) + + assert_allclose(sol.p, [1], rtol=1e-4) + + sol_test = sol.sol(x_test) + + assert_allclose(sol_test[0], sl_sol(x_test, [1]), + rtol=1e-4, atol=1e-4) + + f_test = sl_fun(x_test, sol_test, [1]) + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(rel_res ** 2, axis=0) ** 0.5 + assert_(np.all(norm_res < 1e-3)) + + assert_(np.all(sol.rms_residuals < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_singular_term(): + x = np.linspace(0, 1, 10) + x_test = np.linspace(0.05, 1, 100) + y = np.empty((2, 10)) + y[0] = (3/4)**0.5 + y[1] = 1e-4 + S = np.array([[0, 0], [0, -2]]) + + for fun_jac in [None, emden_fun_jac]: + for bc_jac in [None, emden_bc_jac]: + sol = solve_bvp(emden_fun, emden_bc, x, y, S=S, fun_jac=fun_jac, + bc_jac=bc_jac) + + assert_equal(sol.status, 0) + assert_(sol.success) + + assert_equal(sol.x.size, 10) + + sol_test = sol.sol(x_test) + assert_allclose(sol_test[0], emden_sol(x_test), atol=1e-5) + + f_test = emden_fun(x_test, sol_test) + S.dot(sol_test) / x_test + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(rel_res ** 2, axis=0) ** 0.5 + + assert_(np.all(norm_res < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_complex(): + # The test is essentially the same as test_no_params, but boundary + # conditions are turned into complex. + x = np.linspace(0, 1, 5) + x_test = np.linspace(0, 1, 100) + y = np.zeros((2, x.shape[0]), dtype=complex) + for fun_jac in [None, exp_fun_jac]: + for bc_jac in [None, exp_bc_jac]: + sol = solve_bvp(exp_fun, exp_bc_complex, x, y, fun_jac=fun_jac, + bc_jac=bc_jac) + + assert_equal(sol.status, 0) + assert_(sol.success) + + sol_test = sol.sol(x_test) + + assert_allclose(sol_test[0].real, exp_sol(x_test), atol=1e-5) + assert_allclose(sol_test[0].imag, exp_sol(x_test), atol=1e-5) + + f_test = exp_fun(x_test, sol_test) + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(np.real(rel_res * np.conj(rel_res)), + axis=0) ** 0.5 + assert_(np.all(norm_res < 1e-3)) + + assert_(np.all(sol.rms_residuals < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_failures(): + x = np.linspace(0, 1, 2) + y = np.zeros((2, x.size)) + res = solve_bvp(exp_fun, exp_bc, x, y, tol=1e-5, max_nodes=5) + assert_equal(res.status, 1) + assert_(not res.success) + + x = np.linspace(0, 1, 5) + y = np.zeros((2, x.size)) + res = solve_bvp(undefined_fun, undefined_bc, x, y) + assert_equal(res.status, 2) + assert_(not res.success) + + +def test_big_problem(): + n = 30 + x = np.linspace(0, 1, 5) + y = np.zeros((2 * n, x.size)) + sol = solve_bvp(big_fun, big_bc, x, y) + + assert_equal(sol.status, 0) + assert_(sol.success) + + sol_test = sol.sol(x) + + assert_allclose(sol_test[0], big_sol(x, n)) + + f_test = big_fun(x, sol_test) + r = sol.sol(x, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(np.real(rel_res * np.conj(rel_res)), axis=0) ** 0.5 + assert_(np.all(norm_res < 1e-3)) + + assert_(np.all(sol.rms_residuals < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_big_problem_with_parameters(): + n = 30 + x = np.linspace(0, np.pi, 5) + x_test = np.linspace(0, np.pi, 100) + y = np.ones((2 * n, x.size)) + + for fun_jac in [None, big_fun_with_parameters_jac]: + for bc_jac in [None, big_bc_with_parameters_jac]: + sol = solve_bvp(big_fun_with_parameters, big_bc_with_parameters, x, + y, p=[0.5, 0.5], fun_jac=fun_jac, bc_jac=bc_jac) + + assert_equal(sol.status, 0) + assert_(sol.success) + + assert_allclose(sol.p, [1, 1], rtol=1e-4) + + sol_test = sol.sol(x_test) + + for isol in range(0, n, 4): + assert_allclose(sol_test[isol], + big_sol_with_parameters(x_test, [1, 1])[0], + rtol=1e-4, atol=1e-4) + assert_allclose(sol_test[isol + 2], + big_sol_with_parameters(x_test, [1, 1])[1], + rtol=1e-4, atol=1e-4) + + f_test = big_fun_with_parameters(x_test, sol_test, [1, 1]) + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(rel_res ** 2, axis=0) ** 0.5 + assert_(np.all(norm_res < 1e-3)) + + assert_(np.all(sol.rms_residuals < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_shock_layer(): + x = np.linspace(-1, 1, 5) + x_test = np.linspace(-1, 1, 100) + y = np.zeros((2, x.size)) + sol = solve_bvp(shock_fun, shock_bc, x, y) + + assert_equal(sol.status, 0) + assert_(sol.success) + + assert_(sol.x.size < 110) + + sol_test = sol.sol(x_test) + assert_allclose(sol_test[0], shock_sol(x_test), rtol=1e-5, atol=1e-5) + + f_test = shock_fun(x_test, sol_test) + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(rel_res ** 2, axis=0) ** 0.5 + + assert_(np.all(norm_res < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +def test_nonlin_bc(): + x = np.linspace(0, 0.1, 5) + x_test = x + y = np.zeros([2, x.size]) + sol = solve_bvp(nonlin_bc_fun, nonlin_bc_bc, x, y) + + assert_equal(sol.status, 0) + assert_(sol.success) + + assert_(sol.x.size < 8) + + sol_test = sol.sol(x_test) + assert_allclose(sol_test[0], nonlin_bc_sol(x_test), rtol=1e-5, atol=1e-5) + + f_test = nonlin_bc_fun(x_test, sol_test) + r = sol.sol(x_test, 1) - f_test + rel_res = r / (1 + np.abs(f_test)) + norm_res = np.sum(rel_res ** 2, axis=0) ** 0.5 + + assert_(np.all(norm_res < 1e-3)) + assert_allclose(sol.sol(sol.x), sol.y, rtol=1e-10, atol=1e-10) + assert_allclose(sol.sol(sol.x, 1), sol.yp, rtol=1e-10, atol=1e-10) + + +@pytest.mark.thread_unsafe +def test_verbose(): + # Smoke test that checks the printing does something and does not crash + x = np.linspace(0, 1, 5) + y = np.zeros((2, x.shape[0])) + for verbose in [0, 1, 2]: + old_stdout = sys.stdout + sys.stdout = StringIO() + try: + sol = solve_bvp(exp_fun, exp_bc, x, y, verbose=verbose) + text = sys.stdout.getvalue() + finally: + sys.stdout = old_stdout + + assert_(sol.success) + if verbose == 0: + assert_(not text, text) + if verbose >= 1: + assert_("Solved in" in text, text) + if verbose >= 2: + assert_("Max residual" in text, text) diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_cubature.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_cubature.py new file mode 100644 index 0000000000000000000000000000000000000000..899655c7631fbc86d06eb97c514761d4c882a632 --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_cubature.py @@ -0,0 +1,1389 @@ +import math +import scipy +import itertools + +import pytest + +from scipy._lib._array_api import ( + array_namespace, + xp_assert_close, + xp_size, + np_compat, + is_array_api_strict, +) +from scipy.conftest import array_api_compatible + +from scipy.integrate import cubature + +from scipy.integrate._rules import ( + Rule, FixedRule, + NestedFixedRule, + GaussLegendreQuadrature, GaussKronrodQuadrature, + GenzMalikCubature, +) + +from scipy.integrate._cubature import _InfiniteLimitsTransform + +pytestmark = [pytest.mark.usefixtures("skip_xp_backends"),] +skip_xp_backends = pytest.mark.skip_xp_backends + +# The integrands ``genz_malik_1980_*`` come from the paper: +# A.C. Genz, A.A. Malik, Remarks on algorithm 006: An adaptive algorithm for +# numerical integration over an N-dimensional rectangular region, Journal of +# Computational and Applied Mathematics, Volume 6, Issue 4, 1980, Pages 295-302, +# ISSN 0377-0427, https://doi.org/10.1016/0771-050X(80)90039-X. + + +def basic_1d_integrand(x, n, xp): + x_reshaped = xp.reshape(x, (-1, 1, 1)) + n_reshaped = xp.reshape(n, (1, -1, 1)) + + return x_reshaped**n_reshaped + + +def basic_1d_integrand_exact(n, xp): + # Exact only for integration over interval [0, 2]. + return xp.reshape(2**(n+1)/(n+1), (-1, 1)) + + +def basic_nd_integrand(x, n, xp): + return xp.reshape(xp.sum(x, axis=-1), (-1, 1))**xp.reshape(n, (1, -1)) + + +def basic_nd_integrand_exact(n, xp): + # Exact only for integration over interval [0, 2]. + return (-2**(3+n) + 4**(2+n))/((1+n)*(2+n)) + + +def genz_malik_1980_f_1(x, r, alphas, xp): + r""" + .. math:: f_1(\mathbf x) = \cos\left(2\pi r + \sum^n_{i = 1}\alpha_i x_i\right) + + .. code-block:: mathematica + + genzMalik1980f1[x_List, r_, alphas_List] := Cos[2*Pi*r + Total[x*alphas]] + """ + + npoints, ndim = x.shape[0], x.shape[-1] + + alphas_reshaped = alphas[None, ...] + x_reshaped = xp.reshape(x, (npoints, *([1]*(len(alphas.shape) - 1)), ndim)) + + return xp.cos(2*math.pi*r + xp.sum(alphas_reshaped * x_reshaped, axis=-1)) + + +def genz_malik_1980_f_1_exact(a, b, r, alphas, xp): + ndim = xp_size(a) + a = xp.reshape(a, (*([1]*(len(alphas.shape) - 1)), ndim)) + b = xp.reshape(b, (*([1]*(len(alphas.shape) - 1)), ndim)) + + return ( + (-2)**ndim + * 1/xp.prod(alphas, axis=-1) + * xp.cos(2*math.pi*r + xp.sum(alphas * (a+b) * 0.5, axis=-1)) + * xp.prod(xp.sin(alphas * (a-b)/2), axis=-1) + ) + + +def genz_malik_1980_f_1_random_args(rng, shape, xp): + r = xp.asarray(rng.random(shape[:-1])) + alphas = xp.asarray(rng.random(shape)) + + difficulty = 9 + normalisation_factors = xp.sum(alphas, axis=-1)[..., None] + alphas = difficulty * alphas / normalisation_factors + + return (r, alphas) + + +def genz_malik_1980_f_2(x, alphas, betas, xp): + r""" + .. math:: f_2(\mathbf x) = \prod^n_{i = 1} (\alpha_i^2 + (x_i - \beta_i)^2)^{-1} + + .. code-block:: mathematica + + genzMalik1980f2[x_List, alphas_List, betas_List] := + 1/Times @@ ((alphas^2 + (x - betas)^2)) + """ + npoints, ndim = x.shape[0], x.shape[-1] + + alphas_reshaped = alphas[None, ...] + betas_reshaped = betas[None, ...] + + x_reshaped = xp.reshape(x, (npoints, *([1]*(len(alphas.shape) - 1)), ndim)) + + return 1/xp.prod(alphas_reshaped**2 + (x_reshaped-betas_reshaped)**2, axis=-1) + + +def genz_malik_1980_f_2_exact(a, b, alphas, betas, xp): + ndim = xp_size(a) + a = xp.reshape(a, (*([1]*(len(alphas.shape) - 1)), ndim)) + b = xp.reshape(b, (*([1]*(len(alphas.shape) - 1)), ndim)) + + # `xp` is the unwrapped namespace, so `.atan` won't work for `xp = np` and np<2. + xp_test = array_namespace(a) + + return ( + (-1)**ndim * 1/xp.prod(alphas, axis=-1) + * xp.prod( + xp_test.atan((a - betas)/alphas) - xp_test.atan((b - betas)/alphas), + axis=-1, + ) + ) + + +def genz_malik_1980_f_2_random_args(rng, shape, xp): + ndim = shape[-1] + alphas = xp.asarray(rng.random(shape)) + betas = xp.asarray(rng.random(shape)) + + difficulty = 25.0 + products = xp.prod(alphas**xp.asarray(-2.0), axis=-1) + normalisation_factors = (products**xp.asarray(1 / (2*ndim)))[..., None] + alphas = alphas * normalisation_factors * math.pow(difficulty, 1 / (2*ndim)) + + # Adjust alphas from distribution used in Genz and Malik 1980 since denominator + # is very small for high dimensions. + alphas *= 10 + + return alphas, betas + + +def genz_malik_1980_f_3(x, alphas, xp): + r""" + .. math:: f_3(\mathbf x) = \exp\left(\sum^n_{i = 1} \alpha_i x_i\right) + + .. code-block:: mathematica + + genzMalik1980f3[x_List, alphas_List] := Exp[Dot[x, alphas]] + """ + + npoints, ndim = x.shape[0], x.shape[-1] + + alphas_reshaped = alphas[None, ...] + x_reshaped = xp.reshape(x, (npoints, *([1]*(len(alphas.shape) - 1)), ndim)) + + return xp.exp(xp.sum(alphas_reshaped * x_reshaped, axis=-1)) + + +def genz_malik_1980_f_3_exact(a, b, alphas, xp): + ndim = xp_size(a) + a = xp.reshape(a, (*([1]*(len(alphas.shape) - 1)), ndim)) + b = xp.reshape(b, (*([1]*(len(alphas.shape) - 1)), ndim)) + + return ( + (-1)**ndim * 1/xp.prod(alphas, axis=-1) + * xp.prod(xp.exp(alphas * a) - xp.exp(alphas * b), axis=-1) + ) + + +def genz_malik_1980_f_3_random_args(rng, shape, xp): + alphas = xp.asarray(rng.random(shape)) + normalisation_factors = xp.sum(alphas, axis=-1)[..., None] + difficulty = 12.0 + alphas = difficulty * alphas / normalisation_factors + + return (alphas,) + + +def genz_malik_1980_f_4(x, alphas, xp): + r""" + .. math:: f_4(\mathbf x) = \left(1 + \sum^n_{i = 1} \alpha_i x_i\right)^{-n-1} + + .. code-block:: mathematica + genzMalik1980f4[x_List, alphas_List] := + (1 + Dot[x, alphas])^(-Length[alphas] - 1) + """ + + npoints, ndim = x.shape[0], x.shape[-1] + + alphas_reshaped = alphas[None, ...] + x_reshaped = xp.reshape(x, (npoints, *([1]*(len(alphas.shape) - 1)), ndim)) + + return (1 + xp.sum(alphas_reshaped * x_reshaped, axis=-1))**(-ndim-1) + + +def genz_malik_1980_f_4_exact(a, b, alphas, xp): + ndim = xp_size(a) + + def F(x): + x_reshaped = xp.reshape(x, (*([1]*(len(alphas.shape) - 1)), ndim)) + + return ( + (-1)**ndim/xp.prod(alphas, axis=-1) + / math.factorial(ndim) + / (1 + xp.sum(alphas * x_reshaped, axis=-1)) + ) + + return _eval_indefinite_integral(F, a, b, xp) + + +def _eval_indefinite_integral(F, a, b, xp): + """ + Calculates a definite integral from points `a` to `b` by summing up over the corners + of the corresponding hyperrectangle. + """ + + ndim = xp_size(a) + points = xp.stack([a, b], axis=0) + + out = 0 + for ind in itertools.product(range(2), repeat=ndim): + selected_points = xp.asarray([points[i, j] for i, j in zip(ind, range(ndim))]) + out += pow(-1, sum(ind) + ndim) * F(selected_points) + + return out + + +def genz_malik_1980_f_4_random_args(rng, shape, xp): + ndim = shape[-1] + + alphas = xp.asarray(rng.random(shape)) + normalisation_factors = xp.sum(alphas, axis=-1)[..., None] + difficulty = 14.0 + alphas = (difficulty / ndim) * alphas / normalisation_factors + + return (alphas,) + + +def genz_malik_1980_f_5(x, alphas, betas, xp): + r""" + .. math:: + + f_5(\mathbf x) = \exp\left(-\sum^n_{i = 1} \alpha^2_i (x_i - \beta_i)^2\right) + + .. code-block:: mathematica + + genzMalik1980f5[x_List, alphas_List, betas_List] := + Exp[-Total[alphas^2 * (x - betas)^2]] + """ + + npoints, ndim = x.shape[0], x.shape[-1] + + alphas_reshaped = alphas[None, ...] + betas_reshaped = betas[None, ...] + + x_reshaped = xp.reshape(x, (npoints, *([1]*(len(alphas.shape) - 1)), ndim)) + + return xp.exp( + -xp.sum(alphas_reshaped**2 * (x_reshaped - betas_reshaped)**2, axis=-1) + ) + + +def genz_malik_1980_f_5_exact(a, b, alphas, betas, xp): + ndim = xp_size(a) + a = xp.reshape(a, (*([1]*(len(alphas.shape) - 1)), ndim)) + b = xp.reshape(b, (*([1]*(len(alphas.shape) - 1)), ndim)) + + return ( + (1/2)**ndim + * 1/xp.prod(alphas, axis=-1) + * (math.pi**(ndim/2)) + * xp.prod( + scipy.special.erf(alphas * (betas - a)) + + scipy.special.erf(alphas * (b - betas)), + axis=-1, + ) + ) + + +def genz_malik_1980_f_5_random_args(rng, shape, xp): + alphas = xp.asarray(rng.random(shape)) + betas = xp.asarray(rng.random(shape)) + + difficulty = 21.0 + normalisation_factors = xp.sqrt(xp.sum(alphas**xp.asarray(2.0), axis=-1))[..., None] + alphas = alphas / normalisation_factors * math.sqrt(difficulty) + + return alphas, betas + + +def f_gaussian(x, alphas, xp): + r""" + .. math:: + + f(\mathbf x) = \exp\left(-\sum^n_{i = 1} (\alpha_i x_i)^2 \right) + """ + npoints, ndim = x.shape[0], x.shape[-1] + alphas_reshaped = alphas[None, ...] + x_reshaped = xp.reshape(x, (npoints, *([1]*(len(alphas.shape) - 1)), ndim)) + + return xp.exp(-xp.sum((alphas_reshaped * x_reshaped)**2, axis=-1)) + + +def f_gaussian_exact(a, b, alphas, xp): + # Exact only when `a` and `b` are one of: + # (-oo, oo), or + # (0, oo), or + # (-oo, 0) + # `alphas` can be arbitrary. + + ndim = xp_size(a) + double_infinite_count = 0 + semi_infinite_count = 0 + + for i in range(ndim): + if xp.isinf(a[i]) and xp.isinf(b[i]): # doubly-infinite + double_infinite_count += 1 + elif xp.isinf(a[i]) != xp.isinf(b[i]): # exclusive or, so semi-infinite + semi_infinite_count += 1 + + return (math.sqrt(math.pi) ** ndim) / ( + 2**semi_infinite_count * xp.prod(alphas, axis=-1) + ) + + +def f_gaussian_random_args(rng, shape, xp): + alphas = xp.asarray(rng.random(shape)) + + # If alphas are very close to 0 this makes the problem very difficult due to large + # values of ``f``. + alphas *= 100 + + return (alphas,) + + +def f_modified_gaussian(x_arr, n, xp): + r""" + .. math:: + + f(x, y, z, w) = x^n \sqrt{y} \exp(-y-z^2-w^2) + """ + x, y, z, w = x_arr[:, 0], x_arr[:, 1], x_arr[:, 2], x_arr[:, 3] + res = (x ** n[:, None]) * xp.sqrt(y) * xp.exp(-y-z**2-w**2) + + return res.T + + +def f_modified_gaussian_exact(a, b, n, xp): + # Exact only for the limits + # a = (0, 0, -oo, -oo) + # b = (1, oo, oo, oo) + # but defined here as a function to match the format of the other integrands. + return 1/(2 + 2*n) * math.pi ** (3/2) + + +def f_with_problematic_points(x_arr, points, xp): + """ + This emulates a function with a list of singularities given by `points`. + + If no `x_arr` are one of the `points`, then this function returns 1. + """ + + for point in points: + if xp.any(x_arr == point): + raise ValueError("called with a problematic point") + + return xp.ones(x_arr.shape[0]) + + +@array_api_compatible +class TestCubature: + """ + Tests related to the interface of `cubature`. + """ + + @pytest.mark.parametrize("rule_str", [ + "gauss-kronrod", + "genz-malik", + "gk21", + "gk15", + ]) + def test_pass_str(self, rule_str, xp): + n = xp.arange(5, dtype=xp.float64) + a = xp.asarray([0, 0], dtype=xp.float64) + b = xp.asarray([2, 2], dtype=xp.float64) + + res = cubature(basic_nd_integrand, a, b, rule=rule_str, args=(n, xp)) + + xp_assert_close( + res.estimate, + basic_nd_integrand_exact(n, xp), + rtol=1e-8, + atol=0, + ) + + @skip_xp_backends(np_only=True, + reason='array-likes only supported for NumPy backend') + def test_pass_array_like_not_array(self, xp): + n = np_compat.arange(5, dtype=np_compat.float64) + a = [0] + b = [2] + + res = cubature( + basic_1d_integrand, + a, + b, + args=(n, xp) + ) + + xp_assert_close( + res.estimate, + basic_1d_integrand_exact(n, xp), + rtol=1e-8, + atol=0, + ) + + def test_stops_after_max_subdivisions(self, xp): + a = xp.asarray([0]) + b = xp.asarray([1]) + rule = BadErrorRule() + + res = cubature( + basic_1d_integrand, # Any function would suffice + a, + b, + rule=rule, + max_subdivisions=10, + args=(xp.arange(5, dtype=xp.float64), xp), + ) + + assert res.subdivisions == 10 + assert res.status == "not_converged" + + def test_a_and_b_must_be_1d(self, xp): + a = xp.asarray([[0]], dtype=xp.float64) + b = xp.asarray([[1]], dtype=xp.float64) + + with pytest.raises(Exception, match="`a` and `b` must be 1D arrays"): + cubature(basic_1d_integrand, a, b, args=(xp,)) + + def test_a_and_b_must_be_nonempty(self, xp): + a = xp.asarray([]) + b = xp.asarray([]) + + with pytest.raises(Exception, match="`a` and `b` must be nonempty"): + cubature(basic_1d_integrand, a, b, args=(xp,)) + + def test_zero_width_limits(self, xp): + n = xp.arange(5, dtype=xp.float64) + + a = xp.asarray([0], dtype=xp.float64) + b = xp.asarray([0], dtype=xp.float64) + + res = cubature( + basic_1d_integrand, + a, + b, + args=(n, xp), + ) + + xp_assert_close( + res.estimate, + xp.asarray([[0], [0], [0], [0], [0]], dtype=xp.float64), + rtol=1e-8, + atol=0, + ) + + def test_limits_other_way_around(self, xp): + n = xp.arange(5, dtype=xp.float64) + + a = xp.asarray([2], dtype=xp.float64) + b = xp.asarray([0], dtype=xp.float64) + + res = cubature( + basic_1d_integrand, + a, + b, + args=(n, xp), + ) + + xp_assert_close( + res.estimate, + -basic_1d_integrand_exact(n, xp), + rtol=1e-8, + atol=0, + ) + + def test_result_dtype_promoted_correctly(self, xp): + result_dtype = cubature( + basic_1d_integrand, + xp.asarray([0], dtype=xp.float64), + xp.asarray([1], dtype=xp.float64), + points=[], + args=(xp.asarray([1], dtype=xp.float64), xp), + ).estimate.dtype + + assert result_dtype == xp.float64 + + result_dtype = cubature( + basic_1d_integrand, + xp.asarray([0], dtype=xp.float32), + xp.asarray([1], dtype=xp.float32), + points=[], + args=(xp.asarray([1], dtype=xp.float32), xp), + ).estimate.dtype + + assert result_dtype == xp.float32 + + result_dtype = cubature( + basic_1d_integrand, + xp.asarray([0], dtype=xp.float32), + xp.asarray([1], dtype=xp.float64), + points=[], + args=(xp.asarray([1], dtype=xp.float32), xp), + ).estimate.dtype + + assert result_dtype == xp.float64 + + +@pytest.mark.parametrize("rtol", [1e-4]) +@pytest.mark.parametrize("atol", [1e-5]) +@pytest.mark.parametrize("rule", [ + "gk15", + "gk21", + "genz-malik", +]) +@array_api_compatible +class TestCubatureProblems: + """ + Tests that `cubature` gives the correct answer. + """ + + @pytest.mark.parametrize("problem", [ + # -- f1 -- + ( + # Function to integrate, like `f(x, *args)` + genz_malik_1980_f_1, + + # Exact solution, like `exact(a, b, *args)` + genz_malik_1980_f_1_exact, + + # Coordinates of `a` + [0], + + # Coordinates of `b` + [10], + + # Arguments to pass to `f` and `exact` + ( + 1/4, + [5], + ) + ), + ( + genz_malik_1980_f_1, + genz_malik_1980_f_1_exact, + [0, 0], + [1, 1], + ( + 1/4, + [2, 4], + ), + ), + ( + genz_malik_1980_f_1, + genz_malik_1980_f_1_exact, + [0, 0], + [5, 5], + ( + 1/2, + [2, 4], + ) + ), + ( + genz_malik_1980_f_1, + genz_malik_1980_f_1_exact, + [0, 0, 0], + [5, 5, 5], + ( + 1/2, + [1, 1, 1], + ) + ), + + # -- f2 -- + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + [-1], + [1], + ( + [5], + [4], + ) + ), + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + + [0, 0], + [10, 50], + ( + [-3, 3], + [-2, 2], + ), + ), + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + [0, 0, 0], + [1, 1, 1], + ( + [1, 1, 1], + [1, 1, 1], + ) + ), + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + [0, 0, 0], + [1, 1, 1], + ( + [2, 3, 4], + [2, 3, 4], + ) + ), + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + [-1, -1, -1], + [1, 1, 1], + ( + [1, 1, 1], + [2, 2, 2], + ) + ), + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + [-1, -1, -1, -1], + [1, 1, 1, 1], + ( + [1, 1, 1, 1], + [1, 1, 1, 1], + ) + ), + + # -- f3 -- + ( + genz_malik_1980_f_3, + genz_malik_1980_f_3_exact, + [-1], + [1], + ( + [1/2], + ), + ), + ( + genz_malik_1980_f_3, + genz_malik_1980_f_3_exact, + [0, -1], + [1, 1], + ( + [5, 5], + ), + ), + ( + genz_malik_1980_f_3, + genz_malik_1980_f_3_exact, + [-1, -1, -1], + [1, 1, 1], + ( + [1, 1, 1], + ), + ), + + # -- f4 -- + ( + genz_malik_1980_f_4, + genz_malik_1980_f_4_exact, + [0], + [2], + ( + [1], + ), + ), + ( + genz_malik_1980_f_4, + genz_malik_1980_f_4_exact, + [0, 0], + [2, 1], + ([1, 1],), + ), + ( + genz_malik_1980_f_4, + genz_malik_1980_f_4_exact, + [0, 0, 0], + [1, 1, 1], + ([1, 1, 1],), + ), + + # -- f5 -- + ( + genz_malik_1980_f_5, + genz_malik_1980_f_5_exact, + [-1], + [1], + ( + [-2], + [2], + ), + ), + ( + genz_malik_1980_f_5, + genz_malik_1980_f_5_exact, + [-1, -1], + [1, 1], + ( + [2, 3], + [4, 5], + ), + ), + ( + genz_malik_1980_f_5, + genz_malik_1980_f_5_exact, + [-1, -1], + [1, 1], + ( + [-1, 1], + [0, 0], + ), + ), + ( + genz_malik_1980_f_5, + genz_malik_1980_f_5_exact, + [-1, -1, -1], + [1, 1, 1], + ( + [1, 1, 1], + [1, 1, 1], + ), + ), + ]) + def test_scalar_output(self, problem, rule, rtol, atol, xp): + f, exact, a, b, args = problem + + a = xp.asarray(a, dtype=xp.float64) + b = xp.asarray(b, dtype=xp.float64) + args = tuple(xp.asarray(arg, dtype=xp.float64) for arg in args) + + ndim = xp_size(a) + + if rule == "genz-malik" and ndim < 2: + pytest.skip("Genz-Malik cubature does not support 1D integrals") + + res = cubature( + f, + a, + b, + rule=rule, + rtol=rtol, + atol=atol, + args=(*args, xp), + ) + + assert res.status == "converged" + + est = res.estimate + exact_sol = exact(a, b, *args, xp) + + xp_assert_close( + est, + exact_sol, + rtol=rtol, + atol=atol, + err_msg=f"estimate_error={res.error}, subdivisions={res.subdivisions}", + ) + + @pytest.mark.parametrize("problem", [ + ( + # Function to integrate, like `f(x, *args)` + genz_malik_1980_f_1, + + # Exact solution, like `exact(a, b, *args)` + genz_malik_1980_f_1_exact, + + # Function that generates random args of a certain shape. + genz_malik_1980_f_1_random_args, + ), + ( + genz_malik_1980_f_2, + genz_malik_1980_f_2_exact, + genz_malik_1980_f_2_random_args, + ), + ( + genz_malik_1980_f_3, + genz_malik_1980_f_3_exact, + genz_malik_1980_f_3_random_args + ), + ( + genz_malik_1980_f_4, + genz_malik_1980_f_4_exact, + genz_malik_1980_f_4_random_args + ), + ( + genz_malik_1980_f_5, + genz_malik_1980_f_5_exact, + genz_malik_1980_f_5_random_args, + ), + ]) + @pytest.mark.parametrize("shape", [ + (2,), + (3,), + (4,), + (1, 2), + (1, 3), + (1, 4), + (3, 2), + (3, 4, 2), + (2, 1, 3), + ]) + def test_array_output(self, problem, rule, shape, rtol, atol, xp): + rng = np_compat.random.default_rng(1) + ndim = shape[-1] + + if rule == "genz-malik" and ndim < 2: + pytest.skip("Genz-Malik cubature does not support 1D integrals") + + if rule == "genz-malik" and ndim >= 5: + pytest.mark.slow("Gauss-Kronrod is slow in >= 5 dim") + + f, exact, random_args = problem + args = random_args(rng, shape, xp) + + a = xp.asarray([0] * ndim, dtype=xp.float64) + b = xp.asarray([1] * ndim, dtype=xp.float64) + + res = cubature( + f, + a, + b, + rule=rule, + rtol=rtol, + atol=atol, + args=(*args, xp), + ) + + est = res.estimate + exact_sol = exact(a, b, *args, xp) + + xp_assert_close( + est, + exact_sol, + rtol=rtol, + atol=atol, + err_msg=f"estimate_error={res.error}, subdivisions={res.subdivisions}", + ) + + err_msg = (f"estimate_error={res.error}, " + f"subdivisions= {res.subdivisions}, " + f"true_error={xp.abs(res.estimate - exact_sol)}") + assert res.status == "converged", err_msg + + assert res.estimate.shape == shape[:-1] + + @pytest.mark.parametrize("problem", [ + ( + # Function to integrate + lambda x, xp: x, + + # Exact value + [50.0], + + # Coordinates of `a` + [0], + + # Coordinates of `b` + [10], + + # Points by which to split up the initial region + None, + ), + ( + lambda x, xp: xp.sin(x)/x, + [2.551496047169878], # si(1) + si(2), + [-1], + [2], + [ + [0.0], + ], + ), + ( + lambda x, xp: xp.ones((x.shape[0], 1)), + [1.0], + [0, 0, 0], + [1, 1, 1], + [ + [0.5, 0.5, 0.5], + ], + ), + ( + lambda x, xp: xp.ones((x.shape[0], 1)), + [1.0], + [0, 0, 0], + [1, 1, 1], + [ + [0.25, 0.25, 0.25], + [0.5, 0.5, 0.5], + ], + ), + ( + lambda x, xp: xp.ones((x.shape[0], 1)), + [1.0], + [0, 0, 0], + [1, 1, 1], + [ + [0.1, 0.25, 0.5], + [0.25, 0.25, 0.25], + [0.5, 0.5, 0.5], + ], + ) + ]) + def test_break_points(self, problem, rule, rtol, atol, xp): + f, exact, a, b, points = problem + + a = xp.asarray(a, dtype=xp.float64) + b = xp.asarray(b, dtype=xp.float64) + exact = xp.asarray(exact, dtype=xp.float64) + + if points is not None: + points = [xp.asarray(point, dtype=xp.float64) for point in points] + + ndim = xp_size(a) + + if rule == "genz-malik" and ndim < 2: + pytest.skip("Genz-Malik cubature does not support 1D integrals") + + if rule == "genz-malik" and ndim >= 5: + pytest.mark.slow("Gauss-Kronrod is slow in >= 5 dim") + + res = cubature( + f, + a, + b, + rule=rule, + rtol=rtol, + atol=atol, + points=points, + args=(xp,), + ) + + xp_assert_close( + res.estimate, + exact, + rtol=rtol, + atol=atol, + err_msg=f"estimate_error={res.error}, subdivisions={res.subdivisions}", + check_dtype=False, + ) + + err_msg = (f"estimate_error={res.error}, " + f"subdivisions= {res.subdivisions}, " + f"true_error={xp.abs(res.estimate - exact)}") + assert res.status == "converged", err_msg + + @skip_xp_backends( + "jax.numpy", + reasons=["transforms make use of indexing assignment"], + ) + @pytest.mark.parametrize("problem", [ + ( + # Function to integrate + f_gaussian, + + # Exact solution + f_gaussian_exact, + + # Arguments passed to f + f_gaussian_random_args, + (1, 1), + + # Limits, have to match the shape of the arguments + [-math.inf], # a + [math.inf], # b + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (2, 2), + [-math.inf, -math.inf], + [math.inf, math.inf], + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (1, 1), + [0], + [math.inf], + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (1, 1), + [-math.inf], + [0], + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (2, 2), + [0, 0], + [math.inf, math.inf], + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (2, 2), + [0, -math.inf], + [math.inf, math.inf], + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (1, 4), + [0, 0, -math.inf, -math.inf], + [math.inf, math.inf, math.inf, math.inf], + ), + ( + f_gaussian, + f_gaussian_exact, + f_gaussian_random_args, + (1, 4), + [-math.inf, -math.inf, -math.inf, -math.inf], + [0, 0, math.inf, math.inf], + ), + ( + lambda x, xp: 1/xp.prod(x, axis=-1)**2, + + # Exact only for the below limits, not for general `a` and `b`. + lambda a, b, xp: xp.asarray(1/6, dtype=xp.float64), + + # Arguments + lambda rng, shape, xp: tuple(), + tuple(), + + [1, -math.inf, 3], + [math.inf, -2, math.inf], + ), + + # This particular problem can be slow + pytest.param( + ( + # f(x, y, z, w) = x^n * sqrt(y) * exp(-y-z**2-w**2) for n in [0,1,2,3] + f_modified_gaussian, + + # This exact solution is for the below limits, not in general + f_modified_gaussian_exact, + + # Constant arguments + lambda rng, shape, xp: (xp.asarray([0, 1, 2, 3, 4], dtype=xp.float64),), + tuple(), + + [0, 0, -math.inf, -math.inf], + [1, math.inf, math.inf, math.inf] + ), + + marks=pytest.mark.xslow, + ), + ]) + def test_infinite_limits(self, problem, rule, rtol, atol, xp): + rng = np_compat.random.default_rng(1) + f, exact, random_args_func, random_args_shape, a, b = problem + + a = xp.asarray(a, dtype=xp.float64) + b = xp.asarray(b, dtype=xp.float64) + args = random_args_func(rng, random_args_shape, xp) + + ndim = xp_size(a) + + if rule == "genz-malik" and ndim < 2: + pytest.skip("Genz-Malik cubature does not support 1D integrals") + + if rule == "genz-malik" and ndim >= 4: + pytest.mark.slow("Genz-Malik is slow in >= 5 dim") + + if rule == "genz-malik" and ndim >= 4 and is_array_api_strict(xp): + pytest.mark.xslow("Genz-Malik very slow for array_api_strict in >= 4 dim") + + res = cubature( + f, + a, + b, + rule=rule, + rtol=rtol, + atol=atol, + args=(*args, xp), + ) + + assert res.status == "converged" + + xp_assert_close( + res.estimate, + exact(a, b, *args, xp), + rtol=rtol, + atol=atol, + err_msg=f"error_estimate={res.error}, subdivisions={res.subdivisions}", + check_0d=False, + ) + + @skip_xp_backends( + "jax.numpy", + reasons=["transforms make use of indexing assignment"], + ) + @pytest.mark.parametrize("problem", [ + ( + # Function to integrate + lambda x, xp: (xp.sin(x) / x)**8, + + # Exact value + [151/315 * math.pi], + + # Limits + [-math.inf], + [math.inf], + + # Breakpoints + [[0]], + + ), + ( + # Function to integrate + lambda x, xp: (xp.sin(x[:, 0]) / x[:, 0])**8, + + # Exact value + 151/315 * math.pi, + + # Limits + [-math.inf, 0], + [math.inf, 1], + + # Breakpoints + [[0, 0.5]], + + ) + ]) + def test_infinite_limits_and_break_points(self, problem, rule, rtol, atol, xp): + f, exact, a, b, points = problem + + a = xp.asarray(a, dtype=xp.float64) + b = xp.asarray(b, dtype=xp.float64) + exact = xp.asarray(exact, dtype=xp.float64) + + ndim = xp_size(a) + + if rule == "genz-malik" and ndim < 2: + pytest.skip("Genz-Malik cubature does not support 1D integrals") + + if points is not None: + points = [xp.asarray(point, dtype=xp.float64) for point in points] + + res = cubature( + f, + a, + b, + rule=rule, + rtol=rtol, + atol=atol, + points=points, + args=(xp,), + ) + + assert res.status == "converged" + + xp_assert_close( + res.estimate, + exact, + rtol=rtol, + atol=atol, + err_msg=f"error_estimate={res.error}, subdivisions={res.subdivisions}", + check_0d=False, + ) + + +@array_api_compatible +class TestRules: + """ + Tests related to the general Rule interface (currently private). + """ + + @pytest.mark.parametrize("problem", [ + ( + # 2D problem, 1D rule + [0, 0], + [1, 1], + GaussKronrodQuadrature, + (21,), + ), + ( + # 1D problem, 2D rule + [0], + [1], + GenzMalikCubature, + (2,), + ) + ]) + def test_incompatible_dimension_raises_error(self, problem, xp): + a, b, quadrature, quadrature_args = problem + rule = quadrature(*quadrature_args, xp=xp) + + a = xp.asarray(a, dtype=xp.float64) + b = xp.asarray(b, dtype=xp.float64) + + with pytest.raises(Exception, match="incompatible dimension"): + rule.estimate(basic_1d_integrand, a, b, args=(xp,)) + + def test_estimate_with_base_classes_raise_error(self, xp): + a = xp.asarray([0]) + b = xp.asarray([1]) + + for base_class in [Rule(), FixedRule()]: + with pytest.raises(Exception): + base_class.estimate(basic_1d_integrand, a, b, args=(xp,)) + + +@array_api_compatible +class TestRulesQuadrature: + """ + Tests underlying quadrature rules (ndim == 1). + """ + + @pytest.mark.parametrize(("rule", "rule_args"), [ + (GaussLegendreQuadrature, (3,)), + (GaussLegendreQuadrature, (5,)), + (GaussLegendreQuadrature, (10,)), + (GaussKronrodQuadrature, (15,)), + (GaussKronrodQuadrature, (21,)), + ]) + def test_base_1d_quadratures_simple(self, rule, rule_args, xp): + quadrature = rule(*rule_args, xp=xp) + + n = xp.arange(5, dtype=xp.float64) + + def f(x): + x_reshaped = xp.reshape(x, (-1, 1, 1)) + n_reshaped = xp.reshape(n, (1, -1, 1)) + + return x_reshaped**n_reshaped + + a = xp.asarray([0], dtype=xp.float64) + b = xp.asarray([2], dtype=xp.float64) + + exact = xp.reshape(2**(n+1)/(n+1), (-1, 1)) + estimate = quadrature.estimate(f, a, b) + + xp_assert_close( + estimate, + exact, + rtol=1e-8, + atol=0, + ) + + @pytest.mark.parametrize(("rule_pair", "rule_pair_args"), [ + ((GaussLegendreQuadrature, GaussLegendreQuadrature), (10, 5)), + ]) + def test_base_1d_quadratures_error_from_difference(self, rule_pair, rule_pair_args, + xp): + n = xp.arange(5, dtype=xp.float64) + a = xp.asarray([0], dtype=xp.float64) + b = xp.asarray([2], dtype=xp.float64) + + higher = rule_pair[0](rule_pair_args[0], xp=xp) + lower = rule_pair[1](rule_pair_args[1], xp=xp) + + rule = NestedFixedRule(higher, lower) + res = cubature( + basic_1d_integrand, + a, b, + rule=rule, + rtol=1e-8, + args=(n, xp), + ) + + xp_assert_close( + res.estimate, + basic_1d_integrand_exact(n, xp), + rtol=1e-8, + atol=0, + ) + + @pytest.mark.parametrize("quadrature", [ + GaussLegendreQuadrature + ]) + def test_one_point_fixed_quad_impossible(self, quadrature, xp): + with pytest.raises(Exception): + quadrature(1, xp=xp) + + +@array_api_compatible +class TestRulesCubature: + """ + Tests underlying cubature rules (ndim >= 2). + """ + + @pytest.mark.parametrize("ndim", range(2, 11)) + def test_genz_malik_func_evaluations(self, ndim, xp): + """ + Tests that the number of function evaluations required for Genz-Malik cubature + matches the number in Genz and Malik 1980. + """ + + nodes, _ = GenzMalikCubature(ndim, xp=xp).nodes_and_weights + + assert nodes.shape[0] == (2**ndim) + 2*ndim**2 + 2*ndim + 1 + + def test_genz_malik_1d_raises_error(self, xp): + with pytest.raises(Exception, match="only defined for ndim >= 2"): + GenzMalikCubature(1, xp=xp) + + +@array_api_compatible +@skip_xp_backends( + "jax.numpy", + reasons=["transforms make use of indexing assignment"], +) +class TestTransformations: + @pytest.mark.parametrize(("a", "b", "points"), [ + ( + [0, 1, -math.inf], + [1, math.inf, math.inf], + [ + [1, 1, 1], + [0.5, 10, 10], + ] + ) + ]) + def test_infinite_limits_maintains_points(self, a, b, points, xp): + """ + Test that break points are correctly mapped under the _InfiniteLimitsTransform + transformation. + """ + + xp_compat = array_namespace(xp.empty(0)) + points = [xp.asarray(p, dtype=xp.float64) for p in points] + + f_transformed = _InfiniteLimitsTransform( + # Bind `points` and `xp` argument in f + lambda x: f_with_problematic_points(x, points, xp_compat), + xp.asarray(a, dtype=xp_compat.float64), + xp.asarray(b, dtype=xp_compat.float64), + xp=xp_compat, + ) + + for point in points: + transformed_point = f_transformed.inv(xp_compat.reshape(point, (1, -1))) + + with pytest.raises(Exception, match="called with a problematic point"): + f_transformed(transformed_point) + + +class BadErrorRule(Rule): + """ + A rule with fake high error so that cubature will keep on subdividing. + """ + + def estimate(self, f, a, b, args=()): + xp = array_namespace(a, b) + underlying = GaussLegendreQuadrature(10, xp=xp) + + return underlying.estimate(f, a, b, args) + + def estimate_error(self, f, a, b, args=()): + xp = array_namespace(a, b) + return xp.asarray(1e6, dtype=xp.float64) diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_odeint_jac.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_odeint_jac.py new file mode 100644 index 0000000000000000000000000000000000000000..7d28ccc93f4444f3f2e0b71da01c573d4f903dbc --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_odeint_jac.py @@ -0,0 +1,74 @@ +import numpy as np +from numpy.testing import assert_equal, assert_allclose +from scipy.integrate import odeint +import scipy.integrate._test_odeint_banded as banded5x5 + + +def rhs(y, t): + dydt = np.zeros_like(y) + banded5x5.banded5x5(t, y, dydt) + return dydt + + +def jac(y, t): + n = len(y) + jac = np.zeros((n, n), order='F') + banded5x5.banded5x5_jac(t, y, 1, 1, jac) + return jac + + +def bjac(y, t): + n = len(y) + bjac = np.zeros((4, n), order='F') + banded5x5.banded5x5_bjac(t, y, 1, 1, bjac) + return bjac + + +JACTYPE_FULL = 1 +JACTYPE_BANDED = 4 + + +def check_odeint(jactype): + if jactype == JACTYPE_FULL: + ml = None + mu = None + jacobian = jac + elif jactype == JACTYPE_BANDED: + ml = 2 + mu = 1 + jacobian = bjac + else: + raise ValueError(f"invalid jactype: {jactype!r}") + + y0 = np.arange(1.0, 6.0) + # These tolerances must match the tolerances used in banded5x5.f. + rtol = 1e-11 + atol = 1e-13 + dt = 0.125 + nsteps = 64 + t = dt * np.arange(nsteps+1) + + sol, info = odeint(rhs, y0, t, + Dfun=jacobian, ml=ml, mu=mu, + atol=atol, rtol=rtol, full_output=True) + yfinal = sol[-1] + odeint_nst = info['nst'][-1] + odeint_nfe = info['nfe'][-1] + odeint_nje = info['nje'][-1] + + y1 = y0.copy() + # Pure Fortran solution. y1 is modified in-place. + nst, nfe, nje = banded5x5.banded5x5_solve(y1, nsteps, dt, jactype) + + # It is likely that yfinal and y1 are *exactly* the same, but + # we'll be cautious and use assert_allclose. + assert_allclose(yfinal, y1, rtol=1e-12) + assert_equal((odeint_nst, odeint_nfe, odeint_nje), (nst, nfe, nje)) + + +def test_odeint_full_jac(): + check_odeint(JACTYPE_FULL) + + +def test_odeint_banded_jac(): + check_odeint(JACTYPE_BANDED) diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_quadpack.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_quadpack.py new file mode 100644 index 0000000000000000000000000000000000000000..e61a69df40f9b5975a6f02f40e6f72e34dbbf297 --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_quadpack.py @@ -0,0 +1,680 @@ +import sys +import math +import numpy as np +from numpy import sqrt, cos, sin, arctan, exp, log, pi +from numpy.testing import (assert_, + assert_allclose, assert_array_less, assert_almost_equal) +import pytest + +from scipy.integrate import quad, dblquad, tplquad, nquad +from scipy.special import erf, erfc +from scipy._lib._ccallback import LowLevelCallable + +import ctypes +import ctypes.util +from scipy._lib._ccallback_c import sine_ctypes + +import scipy.integrate._test_multivariate as clib_test + + +def assert_quad(value_and_err, tabled_value, error_tolerance=1.5e-8): + value, err = value_and_err + assert_allclose(value, tabled_value, atol=err, rtol=0) + if error_tolerance is not None: + assert_array_less(err, error_tolerance) + + +def get_clib_test_routine(name, restype, *argtypes): + ptr = getattr(clib_test, name) + return ctypes.cast(ptr, ctypes.CFUNCTYPE(restype, *argtypes)) + + +class TestCtypesQuad: + def setup_method(self): + if sys.platform == 'win32': + files = ['api-ms-win-crt-math-l1-1-0.dll'] + elif sys.platform == 'darwin': + files = ['libm.dylib'] + else: + files = ['libm.so', 'libm.so.6'] + + for file in files: + try: + self.lib = ctypes.CDLL(file) + break + except OSError: + pass + else: + # This test doesn't work on some Linux platforms (Fedora for + # example) that put an ld script in libm.so - see gh-5370 + pytest.skip("Ctypes can't import libm.so") + + restype = ctypes.c_double + argtypes = (ctypes.c_double,) + for name in ['sin', 'cos', 'tan']: + func = getattr(self.lib, name) + func.restype = restype + func.argtypes = argtypes + + def test_typical(self): + assert_quad(quad(self.lib.sin, 0, 5), quad(math.sin, 0, 5)[0]) + assert_quad(quad(self.lib.cos, 0, 5), quad(math.cos, 0, 5)[0]) + assert_quad(quad(self.lib.tan, 0, 1), quad(math.tan, 0, 1)[0]) + + def test_ctypes_sine(self): + quad(LowLevelCallable(sine_ctypes), 0, 1) + + def test_ctypes_variants(self): + sin_0 = get_clib_test_routine('_sin_0', ctypes.c_double, + ctypes.c_double, ctypes.c_void_p) + + sin_1 = get_clib_test_routine('_sin_1', ctypes.c_double, + ctypes.c_int, ctypes.POINTER(ctypes.c_double), + ctypes.c_void_p) + + sin_2 = get_clib_test_routine('_sin_2', ctypes.c_double, + ctypes.c_double) + + sin_3 = get_clib_test_routine('_sin_3', ctypes.c_double, + ctypes.c_int, ctypes.POINTER(ctypes.c_double)) + + sin_4 = get_clib_test_routine('_sin_3', ctypes.c_double, + ctypes.c_int, ctypes.c_double) + + all_sigs = [sin_0, sin_1, sin_2, sin_3, sin_4] + legacy_sigs = [sin_2, sin_4] + legacy_only_sigs = [sin_4] + + # LowLevelCallables work for new signatures + for j, func in enumerate(all_sigs): + callback = LowLevelCallable(func) + if func in legacy_only_sigs: + pytest.raises(ValueError, quad, callback, 0, pi) + else: + assert_allclose(quad(callback, 0, pi)[0], 2.0) + + # Plain ctypes items work only for legacy signatures + for j, func in enumerate(legacy_sigs): + if func in legacy_sigs: + assert_allclose(quad(func, 0, pi)[0], 2.0) + else: + pytest.raises(ValueError, quad, func, 0, pi) + + +class TestMultivariateCtypesQuad: + def setup_method(self): + restype = ctypes.c_double + argtypes = (ctypes.c_int, ctypes.c_double) + for name in ['_multivariate_typical', '_multivariate_indefinite', + '_multivariate_sin']: + func = get_clib_test_routine(name, restype, *argtypes) + setattr(self, name, func) + + def test_typical(self): + # 1) Typical function with two extra arguments: + assert_quad(quad(self._multivariate_typical, 0, pi, (2, 1.8)), + 0.30614353532540296487) + + def test_indefinite(self): + # 2) Infinite integration limits --- Euler's constant + assert_quad(quad(self._multivariate_indefinite, 0, np.inf), + 0.577215664901532860606512) + + def test_threadsafety(self): + # Ensure multivariate ctypes are threadsafe + def threadsafety(y): + return y + quad(self._multivariate_sin, 0, 1)[0] + assert_quad(quad(threadsafety, 0, 1), 0.9596976941318602) + + +class TestQuad: + def test_typical(self): + # 1) Typical function with two extra arguments: + def myfunc(x, n, z): # Bessel function integrand + return cos(n*x-z*sin(x))/pi + assert_quad(quad(myfunc, 0, pi, (2, 1.8)), 0.30614353532540296487) + + def test_indefinite(self): + # 2) Infinite integration limits --- Euler's constant + def myfunc(x): # Euler's constant integrand + return -exp(-x)*log(x) + assert_quad(quad(myfunc, 0, np.inf), 0.577215664901532860606512) + + def test_singular(self): + # 3) Singular points in region of integration. + def myfunc(x): + if 0 < x < 2.5: + return sin(x) + elif 2.5 <= x <= 5.0: + return exp(-x) + else: + return 0.0 + + assert_quad(quad(myfunc, 0, 10, points=[2.5, 5.0]), + 1 - cos(2.5) + exp(-2.5) - exp(-5.0)) + + def test_sine_weighted_finite(self): + # 4) Sine weighted integral (finite limits) + def myfunc(x, a): + return exp(a*(x-1)) + + ome = 2.0**3.4 + assert_quad(quad(myfunc, 0, 1, args=20, weight='sin', wvar=ome), + (20*sin(ome)-ome*cos(ome)+ome*exp(-20))/(20**2 + ome**2)) + + def test_sine_weighted_infinite(self): + # 5) Sine weighted integral (infinite limits) + def myfunc(x, a): + return exp(-x*a) + + a = 4.0 + ome = 3.0 + assert_quad(quad(myfunc, 0, np.inf, args=a, weight='sin', wvar=ome), + ome/(a**2 + ome**2)) + + def test_cosine_weighted_infinite(self): + # 6) Cosine weighted integral (negative infinite limits) + def myfunc(x, a): + return exp(x*a) + + a = 2.5 + ome = 2.3 + assert_quad(quad(myfunc, -np.inf, 0, args=a, weight='cos', wvar=ome), + a/(a**2 + ome**2)) + + def test_algebraic_log_weight(self): + # 6) Algebraic-logarithmic weight. + def myfunc(x, a): + return 1/(1+x+2**(-a)) + + a = 1.5 + assert_quad(quad(myfunc, -1, 1, args=a, weight='alg', + wvar=(-0.5, -0.5)), + pi/sqrt((1+2**(-a))**2 - 1)) + + def test_cauchypv_weight(self): + # 7) Cauchy prinicpal value weighting w(x) = 1/(x-c) + def myfunc(x, a): + return 2.0**(-a)/((x-1)**2+4.0**(-a)) + + a = 0.4 + tabledValue = ((2.0**(-0.4)*log(1.5) - + 2.0**(-1.4)*log((4.0**(-a)+16) / (4.0**(-a)+1)) - + arctan(2.0**(a+2)) - + arctan(2.0**a)) / + (4.0**(-a) + 1)) + assert_quad(quad(myfunc, 0, 5, args=0.4, weight='cauchy', wvar=2.0), + tabledValue, error_tolerance=1.9e-8) + + def test_b_less_than_a(self): + def f(x, p, q): + return p * np.exp(-q*x) + + val_1, err_1 = quad(f, 0, np.inf, args=(2, 3)) + val_2, err_2 = quad(f, np.inf, 0, args=(2, 3)) + assert_allclose(val_1, -val_2, atol=max(err_1, err_2)) + + def test_b_less_than_a_2(self): + def f(x, s): + return np.exp(-x**2 / 2 / s) / np.sqrt(2.*s) + + val_1, err_1 = quad(f, -np.inf, np.inf, args=(2,)) + val_2, err_2 = quad(f, np.inf, -np.inf, args=(2,)) + assert_allclose(val_1, -val_2, atol=max(err_1, err_2)) + + def test_b_less_than_a_3(self): + def f(x): + return 1.0 + + val_1, err_1 = quad(f, 0, 1, weight='alg', wvar=(0, 0)) + val_2, err_2 = quad(f, 1, 0, weight='alg', wvar=(0, 0)) + assert_allclose(val_1, -val_2, atol=max(err_1, err_2)) + + def test_b_less_than_a_full_output(self): + def f(x): + return 1.0 + + res_1 = quad(f, 0, 1, weight='alg', wvar=(0, 0), full_output=True) + res_2 = quad(f, 1, 0, weight='alg', wvar=(0, 0), full_output=True) + err = max(res_1[1], res_2[1]) + assert_allclose(res_1[0], -res_2[0], atol=err) + + def test_double_integral(self): + # 8) Double Integral test + def simpfunc(y, x): # Note order of arguments. + return x+y + + a, b = 1.0, 2.0 + assert_quad(dblquad(simpfunc, a, b, lambda x: x, lambda x: 2*x), + 5/6.0 * (b**3.0-a**3.0)) + + def test_double_integral2(self): + def func(x0, x1, t0, t1): + return x0 + x1 + t0 + t1 + def g(x): + return x + def h(x): + return 2 * x + args = 1, 2 + assert_quad(dblquad(func, 1, 2, g, h, args=args),35./6 + 9*.5) + + def test_double_integral3(self): + def func(x0, x1): + return x0 + x1 + 1 + 2 + assert_quad(dblquad(func, 1, 2, 1, 2),6.) + + @pytest.mark.parametrize( + "x_lower, x_upper, y_lower, y_upper, expected", + [ + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-inf, 0] for all n. + (-np.inf, 0, -np.inf, 0, np.pi / 4), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-inf, -1] for each n (one at a time). + (-np.inf, -1, -np.inf, 0, np.pi / 4 * erfc(1)), + (-np.inf, 0, -np.inf, -1, np.pi / 4 * erfc(1)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-inf, -1] for all n. + (-np.inf, -1, -np.inf, -1, np.pi / 4 * (erfc(1) ** 2)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-inf, 1] for each n (one at a time). + (-np.inf, 1, -np.inf, 0, np.pi / 4 * (erf(1) + 1)), + (-np.inf, 0, -np.inf, 1, np.pi / 4 * (erf(1) + 1)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-inf, 1] for all n. + (-np.inf, 1, -np.inf, 1, np.pi / 4 * ((erf(1) + 1) ** 2)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain Dx = [-inf, -1] and Dy = [-inf, 1]. + (-np.inf, -1, -np.inf, 1, np.pi / 4 * ((erf(1) + 1) * erfc(1))), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain Dx = [-inf, 1] and Dy = [-inf, -1]. + (-np.inf, 1, -np.inf, -1, np.pi / 4 * ((erf(1) + 1) * erfc(1))), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [0, inf] for all n. + (0, np.inf, 0, np.inf, np.pi / 4), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [1, inf] for each n (one at a time). + (1, np.inf, 0, np.inf, np.pi / 4 * erfc(1)), + (0, np.inf, 1, np.inf, np.pi / 4 * erfc(1)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [1, inf] for all n. + (1, np.inf, 1, np.inf, np.pi / 4 * (erfc(1) ** 2)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-1, inf] for each n (one at a time). + (-1, np.inf, 0, np.inf, np.pi / 4 * (erf(1) + 1)), + (0, np.inf, -1, np.inf, np.pi / 4 * (erf(1) + 1)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-1, inf] for all n. + (-1, np.inf, -1, np.inf, np.pi / 4 * ((erf(1) + 1) ** 2)), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain Dx = [-1, inf] and Dy = [1, inf]. + (-1, np.inf, 1, np.inf, np.pi / 4 * ((erf(1) + 1) * erfc(1))), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain Dx = [1, inf] and Dy = [-1, inf]. + (1, np.inf, -1, np.inf, np.pi / 4 * ((erf(1) + 1) * erfc(1))), + # Multiple integration of a function in n = 2 variables: f(x, y, z) + # over domain D = [-inf, inf] for all n. + (-np.inf, np.inf, -np.inf, np.inf, np.pi) + ] + ) + def test_double_integral_improper( + self, x_lower, x_upper, y_lower, y_upper, expected + ): + # The Gaussian Integral. + def f(x, y): + return np.exp(-x ** 2 - y ** 2) + + assert_quad( + dblquad(f, x_lower, x_upper, y_lower, y_upper), + expected, + error_tolerance=3e-8 + ) + + def test_triple_integral(self): + # 9) Triple Integral test + def simpfunc(z, y, x, t): # Note order of arguments. + return (x+y+z)*t + + a, b = 1.0, 2.0 + assert_quad(tplquad(simpfunc, a, b, + lambda x: x, lambda x: 2*x, + lambda x, y: x - y, lambda x, y: x + y, + (2.,)), + 2*8/3.0 * (b**4.0 - a**4.0)) + + @pytest.mark.xslow + @pytest.mark.parametrize( + "x_lower, x_upper, y_lower, y_upper, z_lower, z_upper, expected", + [ + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, 0] for all n. + (-np.inf, 0, -np.inf, 0, -np.inf, 0, (np.pi ** (3 / 2)) / 8), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, -1] for each n (one at a time). + (-np.inf, -1, -np.inf, 0, -np.inf, 0, + (np.pi ** (3 / 2)) / 8 * erfc(1)), + (-np.inf, 0, -np.inf, -1, -np.inf, 0, + (np.pi ** (3 / 2)) / 8 * erfc(1)), + (-np.inf, 0, -np.inf, 0, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * erfc(1)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, -1] for each n (two at a time). + (-np.inf, -1, -np.inf, -1, -np.inf, 0, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 2)), + (-np.inf, -1, -np.inf, 0, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 2)), + (-np.inf, 0, -np.inf, -1, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 2)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, -1] for all n. + (-np.inf, -1, -np.inf, -1, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 3)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = [-inf, -1] and Dy = Dz = [-inf, 1]. + (-np.inf, -1, -np.inf, 1, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * (((erf(1) + 1) ** 2) * erfc(1))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dy = [-inf, -1] and Dz = [-inf, 1]. + (-np.inf, -1, -np.inf, -1, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) * (erfc(1) ** 2))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dz = [-inf, -1] and Dy = [-inf, 1]. + (-np.inf, -1, -np.inf, 1, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) * (erfc(1) ** 2))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = [-inf, 1] and Dy = Dz = [-inf, -1]. + (-np.inf, 1, -np.inf, -1, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) * (erfc(1) ** 2))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dy = [-inf, 1] and Dz = [-inf, -1]. + (-np.inf, 1, -np.inf, 1, -np.inf, -1, + (np.pi ** (3 / 2)) / 8 * (((erf(1) + 1) ** 2) * erfc(1))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dz = [-inf, 1] and Dy = [-inf, -1]. + (-np.inf, 1, -np.inf, -1, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * (((erf(1) + 1) ** 2) * erfc(1))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, 1] for each n (one at a time). + (-np.inf, 1, -np.inf, 0, -np.inf, 0, + (np.pi ** (3 / 2)) / 8 * (erf(1) + 1)), + (-np.inf, 0, -np.inf, 1, -np.inf, 0, + (np.pi ** (3 / 2)) / 8 * (erf(1) + 1)), + (-np.inf, 0, -np.inf, 0, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * (erf(1) + 1)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, 1] for each n (two at a time). + (-np.inf, 1, -np.inf, 1, -np.inf, 0, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 2)), + (-np.inf, 1, -np.inf, 0, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 2)), + (-np.inf, 0, -np.inf, 1, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 2)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, 1] for all n. + (-np.inf, 1, -np.inf, 1, -np.inf, 1, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 3)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [0, inf] for all n. + (0, np.inf, 0, np.inf, 0, np.inf, (np.pi ** (3 / 2)) / 8), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [1, inf] for each n (one at a time). + (1, np.inf, 0, np.inf, 0, np.inf, + (np.pi ** (3 / 2)) / 8 * erfc(1)), + (0, np.inf, 1, np.inf, 0, np.inf, + (np.pi ** (3 / 2)) / 8 * erfc(1)), + (0, np.inf, 0, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * erfc(1)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [1, inf] for each n (two at a time). + (1, np.inf, 1, np.inf, 0, np.inf, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 2)), + (1, np.inf, 0, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 2)), + (0, np.inf, 1, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 2)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [1, inf] for all n. + (1, np.inf, 1, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * (erfc(1) ** 3)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-1, inf] for each n (one at a time). + (-1, np.inf, 0, np.inf, 0, np.inf, + (np.pi ** (3 / 2)) / 8 * (erf(1) + 1)), + (0, np.inf, -1, np.inf, 0, np.inf, + (np.pi ** (3 / 2)) / 8 * (erf(1) + 1)), + (0, np.inf, 0, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * (erf(1) + 1)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-1, inf] for each n (two at a time). + (-1, np.inf, -1, np.inf, 0, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 2)), + (-1, np.inf, 0, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 2)), + (0, np.inf, -1, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 2)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-1, inf] for all n. + (-1, np.inf, -1, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) ** 3)), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = [1, inf] and Dy = Dz = [-1, inf]. + (1, np.inf, -1, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * (((erf(1) + 1) ** 2) * erfc(1))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dy = [1, inf] and Dz = [-1, inf]. + (1, np.inf, 1, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) * (erfc(1) ** 2))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dz = [1, inf] and Dy = [-1, inf]. + (1, np.inf, -1, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) * (erfc(1) ** 2))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = [-1, inf] and Dy = Dz = [1, inf]. + (-1, np.inf, 1, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * ((erf(1) + 1) * (erfc(1) ** 2))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dy = [-1, inf] and Dz = [1, inf]. + (-1, np.inf, -1, np.inf, 1, np.inf, + (np.pi ** (3 / 2)) / 8 * (((erf(1) + 1) ** 2) * erfc(1))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain Dx = Dz = [-1, inf] and Dy = [1, inf]. + (-1, np.inf, 1, np.inf, -1, np.inf, + (np.pi ** (3 / 2)) / 8 * (((erf(1) + 1) ** 2) * erfc(1))), + # Multiple integration of a function in n = 3 variables: f(x, y, z) + # over domain D = [-inf, inf] for all n. + (-np.inf, np.inf, -np.inf, np.inf, -np.inf, np.inf, + np.pi ** (3 / 2)), + ], + ) + def test_triple_integral_improper( + self, + x_lower, + x_upper, + y_lower, + y_upper, + z_lower, + z_upper, + expected + ): + # The Gaussian Integral. + def f(x, y, z): + return np.exp(-x ** 2 - y ** 2 - z ** 2) + + assert_quad( + tplquad(f, x_lower, x_upper, y_lower, y_upper, z_lower, z_upper), + expected, + error_tolerance=6e-8 + ) + + def test_complex(self): + def tfunc(x): + return np.exp(1j*x) + + assert np.allclose( + quad(tfunc, 0, np.pi/2, complex_func=True)[0], + 1+1j) + + # We consider a divergent case in order to force quadpack + # to return an error message. The output is compared + # against what is returned by explicit integration + # of the parts. + kwargs = {'a': 0, 'b': np.inf, 'full_output': True, + 'weight': 'cos', 'wvar': 1} + res_c = quad(tfunc, complex_func=True, **kwargs) + res_r = quad(lambda x: np.real(np.exp(1j*x)), + complex_func=False, + **kwargs) + res_i = quad(lambda x: np.imag(np.exp(1j*x)), + complex_func=False, + **kwargs) + + np.testing.assert_equal(res_c[0], res_r[0] + 1j*res_i[0]) + np.testing.assert_equal(res_c[1], res_r[1] + 1j*res_i[1]) + + assert len(res_c[2]['real']) == len(res_r[2:]) == 3 + assert res_c[2]['real'][2] == res_r[4] + assert res_c[2]['real'][1] == res_r[3] + assert res_c[2]['real'][0]['lst'] == res_r[2]['lst'] + + assert len(res_c[2]['imag']) == len(res_i[2:]) == 1 + assert res_c[2]['imag'][0]['lst'] == res_i[2]['lst'] + + +class TestNQuad: + @pytest.mark.fail_slow(5) + def test_fixed_limits(self): + def func1(x0, x1, x2, x3): + val = (x0**2 + x1*x2 - x3**3 + np.sin(x0) + + (1 if (x0 - 0.2*x3 - 0.5 - 0.25*x1 > 0) else 0)) + return val + + def opts_basic(*args): + return {'points': [0.2*args[2] + 0.5 + 0.25*args[0]]} + + res = nquad(func1, [[0, 1], [-1, 1], [.13, .8], [-.15, 1]], + opts=[opts_basic, {}, {}, {}], full_output=True) + assert_quad(res[:-1], 1.5267454070738635) + assert_(res[-1]['neval'] > 0 and res[-1]['neval'] < 4e5) + + @pytest.mark.fail_slow(5) + def test_variable_limits(self): + scale = .1 + + def func2(x0, x1, x2, x3, t0, t1): + val = (x0*x1*x3**2 + np.sin(x2) + 1 + + (1 if x0 + t1*x1 - t0 > 0 else 0)) + return val + + def lim0(x1, x2, x3, t0, t1): + return [scale * (x1**2 + x2 + np.cos(x3)*t0*t1 + 1) - 1, + scale * (x1**2 + x2 + np.cos(x3)*t0*t1 + 1) + 1] + + def lim1(x2, x3, t0, t1): + return [scale * (t0*x2 + t1*x3) - 1, + scale * (t0*x2 + t1*x3) + 1] + + def lim2(x3, t0, t1): + return [scale * (x3 + t0**2*t1**3) - 1, + scale * (x3 + t0**2*t1**3) + 1] + + def lim3(t0, t1): + return [scale * (t0 + t1) - 1, scale * (t0 + t1) + 1] + + def opts0(x1, x2, x3, t0, t1): + return {'points': [t0 - t1*x1]} + + def opts1(x2, x3, t0, t1): + return {} + + def opts2(x3, t0, t1): + return {} + + def opts3(t0, t1): + return {} + + res = nquad(func2, [lim0, lim1, lim2, lim3], args=(0, 0), + opts=[opts0, opts1, opts2, opts3]) + assert_quad(res, 25.066666666666663) + + def test_square_separate_ranges_and_opts(self): + def f(y, x): + return 1.0 + + assert_quad(nquad(f, [[-1, 1], [-1, 1]], opts=[{}, {}]), 4.0) + + def test_square_aliased_ranges_and_opts(self): + def f(y, x): + return 1.0 + + r = [-1, 1] + opt = {} + assert_quad(nquad(f, [r, r], opts=[opt, opt]), 4.0) + + def test_square_separate_fn_ranges_and_opts(self): + def f(y, x): + return 1.0 + + def fn_range0(*args): + return (-1, 1) + + def fn_range1(*args): + return (-1, 1) + + def fn_opt0(*args): + return {} + + def fn_opt1(*args): + return {} + + ranges = [fn_range0, fn_range1] + opts = [fn_opt0, fn_opt1] + assert_quad(nquad(f, ranges, opts=opts), 4.0) + + def test_square_aliased_fn_ranges_and_opts(self): + def f(y, x): + return 1.0 + + def fn_range(*args): + return (-1, 1) + + def fn_opt(*args): + return {} + + ranges = [fn_range, fn_range] + opts = [fn_opt, fn_opt] + assert_quad(nquad(f, ranges, opts=opts), 4.0) + + def test_matching_quad(self): + def func(x): + return x**2 + 1 + + res, reserr = quad(func, 0, 4) + res2, reserr2 = nquad(func, ranges=[[0, 4]]) + assert_almost_equal(res, res2) + assert_almost_equal(reserr, reserr2) + + def test_matching_dblquad(self): + def func2d(x0, x1): + return x0**2 + x1**3 - x0 * x1 + 1 + + res, reserr = dblquad(func2d, -2, 2, lambda x: -3, lambda x: 3) + res2, reserr2 = nquad(func2d, [[-3, 3], (-2, 2)]) + assert_almost_equal(res, res2) + assert_almost_equal(reserr, reserr2) + + def test_matching_tplquad(self): + def func3d(x0, x1, x2, c0, c1): + return x0**2 + c0 * x1**3 - x0 * x1 + 1 + c1 * np.sin(x2) + + res = tplquad(func3d, -1, 2, lambda x: -2, lambda x: 2, + lambda x, y: -np.pi, lambda x, y: np.pi, + args=(2, 3)) + res2 = nquad(func3d, [[-np.pi, np.pi], [-2, 2], (-1, 2)], args=(2, 3)) + assert_almost_equal(res, res2) + + def test_dict_as_opts(self): + try: + nquad(lambda x, y: x * y, [[0, 1], [0, 1]], opts={'epsrel': 0.0001}) + except TypeError: + assert False + diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_quadrature.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_quadrature.py new file mode 100644 index 0000000000000000000000000000000000000000..2237a12f1ba53e343e27c6853e1d613a3641b55c --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_quadrature.py @@ -0,0 +1,732 @@ +# mypy: disable-error-code="attr-defined" +import pytest +import numpy as np +from numpy.testing import assert_equal, assert_almost_equal, assert_allclose +from hypothesis import given +import hypothesis.strategies as st +import hypothesis.extra.numpy as hyp_num + +from scipy.integrate import (romb, newton_cotes, + cumulative_trapezoid, trapezoid, + quad, simpson, fixed_quad, + qmc_quad, cumulative_simpson) +from scipy.integrate._quadrature import _cumulative_simpson_unequal_intervals + +from scipy import stats, special, integrate +from scipy.conftest import array_api_compatible, skip_xp_invalid_arg +from scipy._lib._array_api_no_0d import xp_assert_close + +skip_xp_backends = pytest.mark.skip_xp_backends + + +class TestFixedQuad: + def test_scalar(self): + n = 4 + expected = 1/(2*n) + got, _ = fixed_quad(lambda x: x**(2*n - 1), 0, 1, n=n) + # quadrature exact for this input + assert_allclose(got, expected, rtol=1e-12) + + def test_vector(self): + n = 4 + p = np.arange(1, 2*n) + expected = 1/(p + 1) + got, _ = fixed_quad(lambda x: x**p[:, None], 0, 1, n=n) + assert_allclose(got, expected, rtol=1e-12) + + +class TestQuadrature: + def quad(self, x, a, b, args): + raise NotImplementedError + + def test_romb(self): + assert_equal(romb(np.arange(17)), 128) + + def test_romb_gh_3731(self): + # Check that romb makes maximal use of data points + x = np.arange(2**4+1) + y = np.cos(0.2*x) + val = romb(y) + val2, err = quad(lambda x: np.cos(0.2*x), x.min(), x.max()) + assert_allclose(val, val2, rtol=1e-8, atol=0) + + def test_newton_cotes(self): + """Test the first few degrees, for evenly spaced points.""" + n = 1 + wts, errcoff = newton_cotes(n, 1) + assert_equal(wts, n*np.array([0.5, 0.5])) + assert_almost_equal(errcoff, -n**3/12.0) + + n = 2 + wts, errcoff = newton_cotes(n, 1) + assert_almost_equal(wts, n*np.array([1.0, 4.0, 1.0])/6.0) + assert_almost_equal(errcoff, -n**5/2880.0) + + n = 3 + wts, errcoff = newton_cotes(n, 1) + assert_almost_equal(wts, n*np.array([1.0, 3.0, 3.0, 1.0])/8.0) + assert_almost_equal(errcoff, -n**5/6480.0) + + n = 4 + wts, errcoff = newton_cotes(n, 1) + assert_almost_equal(wts, n*np.array([7.0, 32.0, 12.0, 32.0, 7.0])/90.0) + assert_almost_equal(errcoff, -n**7/1935360.0) + + def test_newton_cotes2(self): + """Test newton_cotes with points that are not evenly spaced.""" + + x = np.array([0.0, 1.5, 2.0]) + y = x**2 + wts, errcoff = newton_cotes(x) + exact_integral = 8.0/3 + numeric_integral = np.dot(wts, y) + assert_almost_equal(numeric_integral, exact_integral) + + x = np.array([0.0, 1.4, 2.1, 3.0]) + y = x**2 + wts, errcoff = newton_cotes(x) + exact_integral = 9.0 + numeric_integral = np.dot(wts, y) + assert_almost_equal(numeric_integral, exact_integral) + + def test_simpson(self): + y = np.arange(17) + assert_equal(simpson(y), 128) + assert_equal(simpson(y, dx=0.5), 64) + assert_equal(simpson(y, x=np.linspace(0, 4, 17)), 32) + + # integral should be exactly 21 + x = np.linspace(1, 4, 4) + def f(x): + return x**2 + + assert_allclose(simpson(f(x), x=x), 21.0) + + # integral should be exactly 114 + x = np.linspace(1, 7, 4) + assert_allclose(simpson(f(x), dx=2.0), 114) + + # test multi-axis behaviour + a = np.arange(16).reshape(4, 4) + x = np.arange(64.).reshape(4, 4, 4) + y = f(x) + for i in range(3): + r = simpson(y, x=x, axis=i) + it = np.nditer(a, flags=['multi_index']) + for _ in it: + idx = list(it.multi_index) + idx.insert(i, slice(None)) + integral = x[tuple(idx)][-1]**3 / 3 - x[tuple(idx)][0]**3 / 3 + assert_allclose(r[it.multi_index], integral) + + # test when integration axis only has two points + x = np.arange(16).reshape(8, 2) + y = f(x) + r = simpson(y, x=x, axis=-1) + + integral = 0.5 * (y[:, 1] + y[:, 0]) * (x[:, 1] - x[:, 0]) + assert_allclose(r, integral) + + # odd points, test multi-axis behaviour + a = np.arange(25).reshape(5, 5) + x = np.arange(125).reshape(5, 5, 5) + y = f(x) + for i in range(3): + r = simpson(y, x=x, axis=i) + it = np.nditer(a, flags=['multi_index']) + for _ in it: + idx = list(it.multi_index) + idx.insert(i, slice(None)) + integral = x[tuple(idx)][-1]**3 / 3 - x[tuple(idx)][0]**3 / 3 + assert_allclose(r[it.multi_index], integral) + + # Tests for checking base case + x = np.array([3]) + y = np.power(x, 2) + assert_allclose(simpson(y, x=x, axis=0), 0.0) + assert_allclose(simpson(y, x=x, axis=-1), 0.0) + + x = np.array([3, 3, 3, 3]) + y = np.power(x, 2) + assert_allclose(simpson(y, x=x, axis=0), 0.0) + assert_allclose(simpson(y, x=x, axis=-1), 0.0) + + x = np.array([[1, 2, 4, 8], [1, 2, 4, 8], [1, 2, 4, 8]]) + y = np.power(x, 2) + zero_axis = [0.0, 0.0, 0.0, 0.0] + default_axis = [170 + 1/3] * 3 # 8**3 / 3 - 1/3 + assert_allclose(simpson(y, x=x, axis=0), zero_axis) + # the following should be exact + assert_allclose(simpson(y, x=x, axis=-1), default_axis) + + x = np.array([[1, 2, 4, 8], [1, 2, 4, 8], [1, 8, 16, 32]]) + y = np.power(x, 2) + zero_axis = [0.0, 136.0, 1088.0, 8704.0] + default_axis = [170 + 1/3, 170 + 1/3, 32**3 / 3 - 1/3] + assert_allclose(simpson(y, x=x, axis=0), zero_axis) + assert_allclose(simpson(y, x=x, axis=-1), default_axis) + + + @pytest.mark.parametrize('droplast', [False, True]) + def test_simpson_2d_integer_no_x(self, droplast): + # The inputs are 2d integer arrays. The results should be + # identical to the results when the inputs are floating point. + y = np.array([[2, 2, 4, 4, 8, 8, -4, 5], + [4, 4, 2, -4, 10, 22, -2, 10]]) + if droplast: + y = y[:, :-1] + result = simpson(y, axis=-1) + expected = simpson(np.array(y, dtype=np.float64), axis=-1) + assert_equal(result, expected) + + +class TestCumulative_trapezoid: + def test_1d(self): + x = np.linspace(-2, 2, num=5) + y = x + y_int = cumulative_trapezoid(y, x, initial=0) + y_expected = [0., -1.5, -2., -1.5, 0.] + assert_allclose(y_int, y_expected) + + y_int = cumulative_trapezoid(y, x, initial=None) + assert_allclose(y_int, y_expected[1:]) + + def test_y_nd_x_nd(self): + x = np.arange(3 * 2 * 4).reshape(3, 2, 4) + y = x + y_int = cumulative_trapezoid(y, x, initial=0) + y_expected = np.array([[[0., 0.5, 2., 4.5], + [0., 4.5, 10., 16.5]], + [[0., 8.5, 18., 28.5], + [0., 12.5, 26., 40.5]], + [[0., 16.5, 34., 52.5], + [0., 20.5, 42., 64.5]]]) + + assert_allclose(y_int, y_expected) + + # Try with all axes + shapes = [(2, 2, 4), (3, 1, 4), (3, 2, 3)] + for axis, shape in zip([0, 1, 2], shapes): + y_int = cumulative_trapezoid(y, x, initial=0, axis=axis) + assert_equal(y_int.shape, (3, 2, 4)) + y_int = cumulative_trapezoid(y, x, initial=None, axis=axis) + assert_equal(y_int.shape, shape) + + def test_y_nd_x_1d(self): + y = np.arange(3 * 2 * 4).reshape(3, 2, 4) + x = np.arange(4)**2 + # Try with all axes + ys_expected = ( + np.array([[[4., 5., 6., 7.], + [8., 9., 10., 11.]], + [[40., 44., 48., 52.], + [56., 60., 64., 68.]]]), + np.array([[[2., 3., 4., 5.]], + [[10., 11., 12., 13.]], + [[18., 19., 20., 21.]]]), + np.array([[[0.5, 5., 17.5], + [4.5, 21., 53.5]], + [[8.5, 37., 89.5], + [12.5, 53., 125.5]], + [[16.5, 69., 161.5], + [20.5, 85., 197.5]]])) + + for axis, y_expected in zip([0, 1, 2], ys_expected): + y_int = cumulative_trapezoid(y, x=x[:y.shape[axis]], axis=axis, + initial=None) + assert_allclose(y_int, y_expected) + + def test_x_none(self): + y = np.linspace(-2, 2, num=5) + + y_int = cumulative_trapezoid(y) + y_expected = [-1.5, -2., -1.5, 0.] + assert_allclose(y_int, y_expected) + + y_int = cumulative_trapezoid(y, initial=0) + y_expected = [0, -1.5, -2., -1.5, 0.] + assert_allclose(y_int, y_expected) + + y_int = cumulative_trapezoid(y, dx=3) + y_expected = [-4.5, -6., -4.5, 0.] + assert_allclose(y_int, y_expected) + + y_int = cumulative_trapezoid(y, dx=3, initial=0) + y_expected = [0, -4.5, -6., -4.5, 0.] + assert_allclose(y_int, y_expected) + + @pytest.mark.parametrize( + "initial", [1, 0.5] + ) + def test_initial_error(self, initial): + """If initial is not None or 0, a ValueError is raised.""" + y = np.linspace(0, 10, num=10) + with pytest.raises(ValueError, match="`initial`"): + cumulative_trapezoid(y, initial=initial) + + def test_zero_len_y(self): + with pytest.raises(ValueError, match="At least one point is required"): + cumulative_trapezoid(y=[]) + + +@array_api_compatible +class TestTrapezoid: + def test_simple(self, xp): + x = xp.arange(-10, 10, .1) + r = trapezoid(xp.exp(-.5 * x ** 2) / xp.sqrt(2 * xp.asarray(xp.pi)), dx=0.1) + # check integral of normal equals 1 + xp_assert_close(r, xp.asarray(1.0)) + + @skip_xp_backends('jax.numpy', + reasons=["JAX arrays do not support item assignment"]) + @pytest.mark.usefixtures("skip_xp_backends") + def test_ndim(self, xp): + x = xp.linspace(0, 1, 3) + y = xp.linspace(0, 2, 8) + z = xp.linspace(0, 3, 13) + + wx = xp.ones_like(x) * (x[1] - x[0]) + wx[0] /= 2 + wx[-1] /= 2 + wy = xp.ones_like(y) * (y[1] - y[0]) + wy[0] /= 2 + wy[-1] /= 2 + wz = xp.ones_like(z) * (z[1] - z[0]) + wz[0] /= 2 + wz[-1] /= 2 + + q = x[:, None, None] + y[None,:, None] + z[None, None,:] + + qx = xp.sum(q * wx[:, None, None], axis=0) + qy = xp.sum(q * wy[None, :, None], axis=1) + qz = xp.sum(q * wz[None, None, :], axis=2) + + # n-d `x` + r = trapezoid(q, x=x[:, None, None], axis=0) + xp_assert_close(r, qx) + r = trapezoid(q, x=y[None,:, None], axis=1) + xp_assert_close(r, qy) + r = trapezoid(q, x=z[None, None,:], axis=2) + xp_assert_close(r, qz) + + # 1-d `x` + r = trapezoid(q, x=x, axis=0) + xp_assert_close(r, qx) + r = trapezoid(q, x=y, axis=1) + xp_assert_close(r, qy) + r = trapezoid(q, x=z, axis=2) + xp_assert_close(r, qz) + + @skip_xp_backends('jax.numpy', + reasons=["JAX arrays do not support item assignment"]) + @pytest.mark.usefixtures("skip_xp_backends") + def test_gh21908(self, xp): + # extended testing for n-dim arrays + x = xp.reshape(xp.linspace(0, 29, 30), (3, 10)) + y = xp.reshape(xp.linspace(0, 29, 30), (3, 10)) + + out0 = xp.linspace(200, 380, 10) + xp_assert_close(trapezoid(y, x=x, axis=0), out0) + xp_assert_close(trapezoid(y, x=xp.asarray([0, 10., 20.]), axis=0), out0) + # x needs to be broadcastable against y + xp_assert_close( + trapezoid(y, x=xp.asarray([0, 10., 20.])[:, None], axis=0), + out0 + ) + with pytest.raises(Exception): + # x is not broadcastable against y + trapezoid(y, x=xp.asarray([0, 10., 20.])[None, :], axis=0) + + out1 = xp.asarray([ 40.5, 130.5, 220.5]) + xp_assert_close(trapezoid(y, x=x, axis=1), out1) + xp_assert_close( + trapezoid(y, x=xp.linspace(0, 9, 10), axis=1), + out1 + ) + + @skip_xp_invalid_arg + def test_masked(self, xp): + # Testing that masked arrays behave as if the function is 0 where + # masked + x = np.arange(5) + y = x * x + mask = x == 2 + ym = np.ma.array(y, mask=mask) + r = 13.0 # sum(0.5 * (0 + 1) * 1.0 + 0.5 * (9 + 16)) + assert_allclose(trapezoid(ym, x), r) + + xm = np.ma.array(x, mask=mask) + assert_allclose(trapezoid(ym, xm), r) + + xm = np.ma.array(x, mask=mask) + assert_allclose(trapezoid(y, xm), r) + + @skip_xp_backends(np_only=True, + reasons=['array-likes only supported for NumPy backend']) + @pytest.mark.usefixtures("skip_xp_backends") + def test_array_like(self, xp): + x = list(range(5)) + y = [t * t for t in x] + xarr = xp.asarray(x, dtype=xp.float64) + yarr = xp.asarray(y, dtype=xp.float64) + res = trapezoid(y, x) + resarr = trapezoid(yarr, xarr) + xp_assert_close(res, resarr) + + +class TestQMCQuad: + @pytest.mark.thread_unsafe + def test_input_validation(self): + message = "`func` must be callable." + with pytest.raises(TypeError, match=message): + qmc_quad("a duck", [0, 0], [1, 1]) + + message = "`func` must evaluate the integrand at points..." + with pytest.raises(ValueError, match=message): + qmc_quad(lambda: 1, [0, 0], [1, 1]) + + def func(x): + assert x.ndim == 1 + return np.sum(x) + message = "Exception encountered when attempting vectorized call..." + with pytest.warns(UserWarning, match=message): + qmc_quad(func, [0, 0], [1, 1]) + + message = "`n_points` must be an integer." + with pytest.raises(TypeError, match=message): + qmc_quad(lambda x: 1, [0, 0], [1, 1], n_points=1024.5) + + message = "`n_estimates` must be an integer." + with pytest.raises(TypeError, match=message): + qmc_quad(lambda x: 1, [0, 0], [1, 1], n_estimates=8.5) + + message = "`qrng` must be an instance of scipy.stats.qmc.QMCEngine." + with pytest.raises(TypeError, match=message): + qmc_quad(lambda x: 1, [0, 0], [1, 1], qrng="a duck") + + message = "`qrng` must be initialized with dimensionality equal to " + with pytest.raises(ValueError, match=message): + qmc_quad(lambda x: 1, [0, 0], [1, 1], qrng=stats.qmc.Sobol(1)) + + message = r"`log` must be boolean \(`True` or `False`\)." + with pytest.raises(TypeError, match=message): + qmc_quad(lambda x: 1, [0, 0], [1, 1], log=10) + + def basic_test(self, n_points=2**8, n_estimates=8, signs=None): + if signs is None: + signs = np.ones(2) + ndim = 2 + mean = np.zeros(ndim) + cov = np.eye(ndim) + + def func(x): + return stats.multivariate_normal.pdf(x.T, mean, cov) + + rng = np.random.default_rng(2879434385674690281) + qrng = stats.qmc.Sobol(ndim, seed=rng) + a = np.zeros(ndim) + b = np.ones(ndim) * signs + res = qmc_quad(func, a, b, n_points=n_points, + n_estimates=n_estimates, qrng=qrng) + ref = stats.multivariate_normal.cdf(b, mean, cov, lower_limit=a) + atol = special.stdtrit(n_estimates-1, 0.995) * res.standard_error # 99% CI + assert_allclose(res.integral, ref, atol=atol) + assert np.prod(signs)*res.integral > 0 + + rng = np.random.default_rng(2879434385674690281) + qrng = stats.qmc.Sobol(ndim, seed=rng) + logres = qmc_quad(lambda *args: np.log(func(*args)), a, b, + n_points=n_points, n_estimates=n_estimates, + log=True, qrng=qrng) + assert_allclose(np.exp(logres.integral), res.integral, rtol=1e-14) + assert np.imag(logres.integral) == (np.pi if np.prod(signs) < 0 else 0) + assert_allclose(np.exp(logres.standard_error), + res.standard_error, rtol=1e-14, atol=1e-16) + + @pytest.mark.parametrize("n_points", [2**8, 2**12]) + @pytest.mark.parametrize("n_estimates", [8, 16]) + def test_basic(self, n_points, n_estimates): + self.basic_test(n_points, n_estimates) + + @pytest.mark.parametrize("signs", [[1, 1], [-1, -1], [-1, 1], [1, -1]]) + def test_sign(self, signs): + self.basic_test(signs=signs) + + @pytest.mark.thread_unsafe + @pytest.mark.parametrize("log", [False, True]) + def test_zero(self, log): + message = "A lower limit was equal to an upper limit, so" + with pytest.warns(UserWarning, match=message): + res = qmc_quad(lambda x: 1, [0, 0], [0, 1], log=log) + assert res.integral == (-np.inf if log else 0) + assert res.standard_error == 0 + + def test_flexible_input(self): + # check that qrng is not required + # also checks that for 1d problems, a and b can be scalars + def func(x): + return stats.norm.pdf(x, scale=2) + + res = qmc_quad(func, 0, 1) + ref = stats.norm.cdf(1, scale=2) - stats.norm.cdf(0, scale=2) + assert_allclose(res.integral, ref, 1e-2) + + +def cumulative_simpson_nd_reference(y, *, x=None, dx=None, initial=None, axis=-1): + # Use cumulative_trapezoid if length of y < 3 + if y.shape[axis] < 3: + if initial is None: + return cumulative_trapezoid(y, x=x, dx=dx, axis=axis, initial=None) + else: + return initial + cumulative_trapezoid(y, x=x, dx=dx, axis=axis, initial=0) + + # Ensure that working axis is last axis + y = np.moveaxis(y, axis, -1) + x = np.moveaxis(x, axis, -1) if np.ndim(x) > 1 else x + dx = np.moveaxis(dx, axis, -1) if np.ndim(dx) > 1 else dx + initial = np.moveaxis(initial, axis, -1) if np.ndim(initial) > 1 else initial + + # If `x` is not present, create it from `dx` + n = y.shape[-1] + x = dx * np.arange(n) if dx is not None else x + # Similarly, if `initial` is not present, set it to 0 + initial_was_none = initial is None + initial = 0 if initial_was_none else initial + + # `np.apply_along_axis` accepts only one array, so concatenate arguments + x = np.broadcast_to(x, y.shape) + initial = np.broadcast_to(initial, y.shape[:-1] + (1,)) + z = np.concatenate((y, x, initial), axis=-1) + + # Use `np.apply_along_axis` to compute result + def f(z): + return cumulative_simpson(z[:n], x=z[n:2*n], initial=z[2*n:]) + res = np.apply_along_axis(f, -1, z) + + # Remove `initial` and undo axis move as needed + res = res[..., 1:] if initial_was_none else res + res = np.moveaxis(res, -1, axis) + return res + + +class TestCumulativeSimpson: + x0 = np.arange(4) + y0 = x0**2 + + @pytest.mark.parametrize('use_dx', (False, True)) + @pytest.mark.parametrize('use_initial', (False, True)) + def test_1d(self, use_dx, use_initial): + # Test for exact agreement with polynomial of highest + # possible order (3 if `dx` is constant, 2 otherwise). + rng = np.random.default_rng(82456839535679456794) + n = 10 + + # Generate random polynomials and ground truth + # integral of appropriate order + order = 3 if use_dx else 2 + dx = rng.random() + x = (np.sort(rng.random(n)) if order == 2 + else np.arange(n)*dx + rng.random()) + i = np.arange(order + 1)[:, np.newaxis] + c = rng.random(order + 1)[:, np.newaxis] + y = np.sum(c*x**i, axis=0) + Y = np.sum(c*x**(i + 1)/(i + 1), axis=0) + ref = Y if use_initial else (Y-Y[0])[1:] + + # Integrate with `cumulative_simpson` + initial = Y[0] if use_initial else None + kwarg = {'dx': dx} if use_dx else {'x': x} + res = cumulative_simpson(y, **kwarg, initial=initial) + + # Compare result against reference + if not use_dx: + assert_allclose(res, ref, rtol=2e-15) + else: + i0 = 0 if use_initial else 1 + # all terms are "close" + assert_allclose(res, ref, rtol=0.0025) + # only even-interval terms are "exact" + assert_allclose(res[i0::2], ref[i0::2], rtol=2e-15) + + @pytest.mark.parametrize('axis', np.arange(-3, 3)) + @pytest.mark.parametrize('x_ndim', (1, 3)) + @pytest.mark.parametrize('x_len', (1, 2, 7)) + @pytest.mark.parametrize('i_ndim', (None, 0, 3,)) + @pytest.mark.parametrize('dx', (None, True)) + def test_nd(self, axis, x_ndim, x_len, i_ndim, dx): + # Test behavior of `cumulative_simpson` with N-D `y` + rng = np.random.default_rng(82456839535679456794) + + # determine shapes + shape = [5, 6, x_len] + shape[axis], shape[-1] = shape[-1], shape[axis] + shape_len_1 = shape.copy() + shape_len_1[axis] = 1 + i_shape = shape_len_1 if i_ndim == 3 else () + + # initialize arguments + y = rng.random(size=shape) + x, dx = None, None + if dx: + dx = rng.random(size=shape_len_1) if x_ndim > 1 else rng.random() + else: + x = (np.sort(rng.random(size=shape), axis=axis) if x_ndim > 1 + else np.sort(rng.random(size=shape[axis]))) + initial = None if i_ndim is None else rng.random(size=i_shape) + + # compare results + res = cumulative_simpson(y, x=x, dx=dx, initial=initial, axis=axis) + ref = cumulative_simpson_nd_reference(y, x=x, dx=dx, initial=initial, axis=axis) + np.testing.assert_allclose(res, ref, rtol=1e-15) + + @pytest.mark.parametrize(('message', 'kwarg_update'), [ + ("x must be strictly increasing", dict(x=[2, 2, 3, 4])), + ("x must be strictly increasing", dict(x=[x0, [2, 2, 4, 8]], y=[y0, y0])), + ("x must be strictly increasing", dict(x=[x0, x0, x0], y=[y0, y0, y0], axis=0)), + ("At least one point is required", dict(x=[], y=[])), + ("`axis=4` is not valid for `y` with `y.ndim=1`", dict(axis=4)), + ("shape of `x` must be the same as `y` or 1-D", dict(x=np.arange(5))), + ("`initial` must either be a scalar or...", dict(initial=np.arange(5))), + ("`dx` must either be a scalar or...", dict(x=None, dx=np.arange(5))), + ]) + def test_simpson_exceptions(self, message, kwarg_update): + kwargs0 = dict(y=self.y0, x=self.x0, dx=None, initial=None, axis=-1) + with pytest.raises(ValueError, match=message): + cumulative_simpson(**dict(kwargs0, **kwarg_update)) + + def test_special_cases(self): + # Test special cases not checked elsewhere + rng = np.random.default_rng(82456839535679456794) + y = rng.random(size=10) + res = cumulative_simpson(y, dx=0) + assert_equal(res, 0) + + # Should add tests of: + # - all elements of `x` identical + # These should work as they do for `simpson` + + def _get_theoretical_diff_between_simps_and_cum_simps(self, y, x): + """`cumulative_simpson` and `simpson` can be tested against other to verify + they give consistent results. `simpson` will iteratively be called with + successively higher upper limits of integration. This function calculates + the theoretical correction required to `simpson` at even intervals to match + with `cumulative_simpson`. + """ + d = np.diff(x, axis=-1) + sub_integrals_h1 = _cumulative_simpson_unequal_intervals(y, d) + sub_integrals_h2 = _cumulative_simpson_unequal_intervals( + y[..., ::-1], d[..., ::-1] + )[..., ::-1] + + # Concatenate to build difference array + zeros_shape = (*y.shape[:-1], 1) + theoretical_difference = np.concatenate( + [ + np.zeros(zeros_shape), + (sub_integrals_h1[..., 1:] - sub_integrals_h2[..., :-1]), + np.zeros(zeros_shape), + ], + axis=-1, + ) + # Differences only expected at even intervals. Odd intervals will + # match exactly so there is no correction + theoretical_difference[..., 1::2] = 0.0 + # Note: the first interval will not match from this correction as + # `simpson` uses the trapezoidal rule + return theoretical_difference + + @pytest.mark.thread_unsafe + @pytest.mark.slow + @given( + y=hyp_num.arrays( + np.float64, + hyp_num.array_shapes(max_dims=4, min_side=3, max_side=10), + elements=st.floats(-10, 10, allow_nan=False).filter(lambda x: abs(x) > 1e-7) + ) + ) + def test_cumulative_simpson_against_simpson_with_default_dx( + self, y + ): + """Theoretically, the output of `cumulative_simpson` will be identical + to `simpson` at all even indices and in the last index. The first index + will not match as `simpson` uses the trapezoidal rule when there are only two + data points. Odd indices after the first index are shown to match with + a mathematically-derived correction.""" + def simpson_reference(y): + return np.stack( + [simpson(y[..., :i], dx=1.0) for i in range(2, y.shape[-1]+1)], axis=-1, + ) + + res = cumulative_simpson(y, dx=1.0) + ref = simpson_reference(y) + theoretical_difference = self._get_theoretical_diff_between_simps_and_cum_simps( + y, x=np.arange(y.shape[-1]) + ) + np.testing.assert_allclose( + res[..., 1:], ref[..., 1:] + theoretical_difference[..., 1:] + ) + + @pytest.mark.thread_unsafe + @pytest.mark.slow + @given( + y=hyp_num.arrays( + np.float64, + hyp_num.array_shapes(max_dims=4, min_side=3, max_side=10), + elements=st.floats(-10, 10, allow_nan=False).filter(lambda x: abs(x) > 1e-7) + ) + ) + def test_cumulative_simpson_against_simpson( + self, y + ): + """Theoretically, the output of `cumulative_simpson` will be identical + to `simpson` at all even indices and in the last index. The first index + will not match as `simpson` uses the trapezoidal rule when there are only two + data points. Odd indices after the first index are shown to match with + a mathematically-derived correction.""" + interval = 10/(y.shape[-1] - 1) + x = np.linspace(0, 10, num=y.shape[-1]) + x[1:] = x[1:] + 0.2*interval*np.random.uniform(-1, 1, len(x) - 1) + + def simpson_reference(y, x): + return np.stack( + [simpson(y[..., :i], x=x[..., :i]) for i in range(2, y.shape[-1]+1)], + axis=-1, + ) + + res = cumulative_simpson(y, x=x) + ref = simpson_reference(y, x) + theoretical_difference = self._get_theoretical_diff_between_simps_and_cum_simps( + y, x + ) + np.testing.assert_allclose( + res[..., 1:], ref[..., 1:] + theoretical_difference[..., 1:] + ) + +class TestLebedev: + def test_input_validation(self): + # only certain rules are available + message = "Order n=-1 not available..." + with pytest.raises(NotImplementedError, match=message): + integrate.lebedev_rule(-1) + + def test_quadrature(self): + # Test points/weights to integrate an example function + + def f(x): + return np.exp(x[0]) + + x, w = integrate.lebedev_rule(15) + res = w @ f(x) + ref = 14.7680137457653 # lebedev_rule reference [3] + assert_allclose(res, ref, rtol=1e-14) + assert_allclose(np.sum(w), 4 * np.pi) + + @pytest.mark.parametrize('order', list(range(3, 32, 2)) + list(range(35, 132, 6))) + def test_properties(self, order): + x, w = integrate.lebedev_rule(order) + # dispersion should be maximal; no clear spherical mean + with np.errstate(divide='ignore', invalid='ignore'): + res = stats.directional_stats(x.T, axis=0) + assert_allclose(res.mean_resultant_length, 0, atol=1e-15) + # weights should sum to 4*pi (surface area of unit sphere) + assert_allclose(np.sum(w), 4*np.pi) diff --git a/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_tanhsinh.py b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_tanhsinh.py new file mode 100644 index 0000000000000000000000000000000000000000..e3c05990457e1e9859bf44808dc029061eab4dd7 --- /dev/null +++ b/llava_video/lib/python3.10/site-packages/scipy/integrate/tests/test_tanhsinh.py @@ -0,0 +1,1153 @@ +# mypy: disable-error-code="attr-defined" +import os +import pytest +import math + +import numpy as np +from numpy.testing import assert_allclose + +from scipy.conftest import array_api_compatible +import scipy._lib._elementwise_iterative_method as eim +from scipy._lib._array_api_no_0d import xp_assert_close, xp_assert_equal +from scipy._lib._array_api import array_namespace, xp_size, xp_ravel, xp_copy, is_numpy +from scipy import special, stats +from scipy.integrate import quad_vec, nsum, tanhsinh as _tanhsinh +from scipy.integrate._tanhsinh import _pair_cache +from scipy.stats._discrete_distns import _gen_harmonic_gt1 + + +def norm_pdf(x, xp=None): + xp = array_namespace(x) if xp is None else xp + return 1/(2*xp.pi)**0.5 * xp.exp(-x**2/2) + +def norm_logpdf(x, xp=None): + xp = array_namespace(x) if xp is None else xp + return -0.5*math.log(2*xp.pi) - x**2/2 + + +def _vectorize(xp): + # xp-compatible version of np.vectorize + # assumes arguments are all arrays of the same shape + def decorator(f): + def wrapped(*arg_arrays): + shape = arg_arrays[0].shape + arg_arrays = [xp_ravel(arg_array) for arg_array in arg_arrays] + res = [] + for i in range(math.prod(shape)): + arg_scalars = [arg_array[i] for arg_array in arg_arrays] + res.append(f(*arg_scalars)) + return res + + return wrapped + + return decorator + + +@array_api_compatible +@pytest.mark.usefixtures("skip_xp_backends") +@pytest.mark.skip_xp_backends( + 'array_api_strict', reason='Currently uses fancy indexing assignment.' +) +@pytest.mark.skip_xp_backends( + 'jax.numpy', reason='JAX arrays do not support item assignment.' +) +class TestTanhSinh: + + # Test problems from [1] Section 6 + def f1(self, t): + return t * np.log(1 + t) + + f1.ref = 0.25 + f1.b = 1 + + def f2(self, t): + return t ** 2 * np.arctan(t) + + f2.ref = (np.pi - 2 + 2 * np.log(2)) / 12 + f2.b = 1 + + def f3(self, t): + return np.exp(t) * np.cos(t) + + f3.ref = (np.exp(np.pi / 2) - 1) / 2 + f3.b = np.pi / 2 + + def f4(self, t): + a = np.sqrt(2 + t ** 2) + return np.arctan(a) / ((1 + t ** 2) * a) + + f4.ref = 5 * np.pi ** 2 / 96 + f4.b = 1 + + def f5(self, t): + return np.sqrt(t) * np.log(t) + + f5.ref = -4 / 9 + f5.b = 1 + + def f6(self, t): + return np.sqrt(1 - t ** 2) + + f6.ref = np.pi / 4 + f6.b = 1 + + def f7(self, t): + return np.sqrt(t) / np.sqrt(1 - t ** 2) + + f7.ref = 2 * np.sqrt(np.pi) * special.gamma(3 / 4) / special.gamma(1 / 4) + f7.b = 1 + + def f8(self, t): + return np.log(t) ** 2 + + f8.ref = 2 + f8.b = 1 + + def f9(self, t): + return np.log(np.cos(t)) + + f9.ref = -np.pi * np.log(2) / 2 + f9.b = np.pi / 2 + + def f10(self, t): + return np.sqrt(np.tan(t)) + + f10.ref = np.pi * np.sqrt(2) / 2 + f10.b = np.pi / 2 + + def f11(self, t): + return 1 / (1 + t ** 2) + + f11.ref = np.pi / 2 + f11.b = np.inf + + def f12(self, t): + return np.exp(-t) / np.sqrt(t) + + f12.ref = np.sqrt(np.pi) + f12.b = np.inf + + def f13(self, t): + return np.exp(-t ** 2 / 2) + + f13.ref = np.sqrt(np.pi / 2) + f13.b = np.inf + + def f14(self, t): + return np.exp(-t) * np.cos(t) + + f14.ref = 0.5 + f14.b = np.inf + + def f15(self, t): + return np.sin(t) / t + + f15.ref = np.pi / 2 + f15.b = np.inf + + def error(self, res, ref, log=False, xp=None): + xp = array_namespace(res, ref) if xp is None else xp + err = abs(res - ref) + + if not log: + return err + + with np.errstate(divide='ignore'): + return xp.log10(err) + + def test_input_validation(self, xp): + f = self.f1 + + zero = xp.asarray(0) + f_b = xp.asarray(f.b) + + message = '`f` must be callable.' + with pytest.raises(ValueError, match=message): + _tanhsinh(42, zero, f_b) + + message = '...must be True or False.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, log=2) + + message = '...must be real numbers.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, xp.asarray(1+1j), f_b) + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, atol='ekki') + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, rtol=pytest) + + message = '...must be non-negative and finite.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, rtol=-1) + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, atol=xp.inf) + + message = '...may not be positive infinity.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, rtol=xp.inf, log=True) + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, atol=xp.inf, log=True) + + message = '...must be integers.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, maxlevel=object()) + # with pytest.raises(ValueError, match=message): # unused for now + # _tanhsinh(f, zero, f_b, maxfun=1+1j) + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, minlevel="migratory coconut") + + message = '...must be non-negative.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, maxlevel=-1) + # with pytest.raises(ValueError, match=message): # unused for now + # _tanhsinh(f, zero, f_b, maxfun=-1) + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, minlevel=-1) + + message = '...must be True or False.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, preserve_shape=2) + + message = '...must be callable.' + with pytest.raises(ValueError, match=message): + _tanhsinh(f, zero, f_b, callback='elderberry') + + @pytest.mark.parametrize("limits, ref", [ + [(0, math.inf), 0.5], # b infinite + [(-math.inf, 0), 0.5], # a infinite + [(-math.inf, math.inf), 1.], # a and b infinite + [(math.inf, -math.inf), -1.], # flipped limits + [(1, -1), stats.norm.cdf(-1.) - stats.norm.cdf(1.)], # flipped limits + ]) + def test_integral_transforms(self, limits, ref, xp): + # Check that the integral transforms are behaving for both normal and + # log integration + limits = [xp.asarray(limit) for limit in limits] + dtype = xp.asarray(float(limits[0])).dtype + ref = xp.asarray(ref, dtype=dtype) + + res = _tanhsinh(norm_pdf, *limits) + xp_assert_close(res.integral, ref) + + logres = _tanhsinh(norm_logpdf, *limits, log=True) + xp_assert_close(xp.exp(logres.integral), ref, check_dtype=False) + # Transformation should not make the result complex unnecessarily + xp_test = array_namespace(*limits) # we need xp.isdtype + assert (xp_test.isdtype(logres.integral.dtype, "real floating") if ref > 0 + else xp_test.isdtype(logres.integral.dtype, "complex floating")) + + xp_assert_close(xp.exp(logres.error), res.error, atol=1e-16, check_dtype=False) + + # 15 skipped intentionally; it's very difficult numerically + @pytest.mark.skip_xp_backends(np_only=True, + reason='Cumbersome to convert everything.') + @pytest.mark.parametrize('f_number', range(1, 15)) + def test_basic(self, f_number, xp): + f = getattr(self, f"f{f_number}") + rtol = 2e-8 + res = _tanhsinh(f, 0, f.b, rtol=rtol) + assert_allclose(res.integral, f.ref, rtol=rtol) + if f_number not in {14}: # mildly underestimates error here + true_error = abs(self.error(res.integral, f.ref)/res.integral) + assert true_error < res.error + + if f_number in {7, 10, 12}: # succeeds, but doesn't know it + return + + assert res.success + assert res.status == 0 + + @pytest.mark.skip_xp_backends(np_only=True, + reason="Distributions aren't xp-compatible.") + @pytest.mark.parametrize('ref', (0.5, [0.4, 0.6])) + @pytest.mark.parametrize('case', stats._distr_params.distcont) + def test_accuracy(self, ref, case, xp): + distname, params = case + if distname in {'dgamma', 'dweibull', 'laplace', 'kstwo'}: + # should split up interval at first-derivative discontinuity + pytest.skip('tanh-sinh is not great for non-smooth integrands') + if (distname in {'studentized_range', 'levy_stable'} + and not int(os.getenv('SCIPY_XSLOW', 0))): + pytest.skip('This case passes, but it is too slow.') + dist = getattr(stats, distname)(*params) + x = dist.interval(ref) + res = _tanhsinh(dist.pdf, *x) + assert_allclose(res.integral, ref) + + @pytest.mark.parametrize('shape', [tuple(), (12,), (3, 4), (3, 2, 2)]) + def test_vectorization(self, shape, xp): + # Test for correct functionality, output shapes, and dtypes for various + # input shapes. + rng = np.random.default_rng(82456839535679456794) + a = xp.asarray(rng.random(shape)) + b = xp.asarray(rng.random(shape)) + p = xp.asarray(rng.random(shape)) + n = math.prod(shape) + + def f(x, p): + f.ncall += 1 + f.feval += 1 if (xp_size(x) == n or x.ndim <= 1) else x.shape[-1] + return x**p + f.ncall = 0 + f.feval = 0 + + @_vectorize(xp) + def _tanhsinh_single(a, b, p): + return _tanhsinh(lambda x: x**p, a, b) + + res = _tanhsinh(f, a, b, args=(p,)) + refs = _tanhsinh_single(a, b, p) + + xp_test = array_namespace(a) # need xp.stack, isdtype + attrs = ['integral', 'error', 'success', 'status', 'nfev', 'maxlevel'] + for attr in attrs: + ref_attr = xp_test.stack([getattr(ref, attr) for ref in refs]) + res_attr = xp_ravel(getattr(res, attr)) + xp_assert_close(res_attr, ref_attr, rtol=1e-15) + assert getattr(res, attr).shape == shape + + assert xp_test.isdtype(res.success.dtype, 'bool') + assert xp_test.isdtype(res.status.dtype, 'integral') + assert xp_test.isdtype(res.nfev.dtype, 'integral') + assert xp_test.isdtype(res.maxlevel.dtype, 'integral') + assert xp.max(res.nfev) == f.feval + # maxlevel = 2 -> 3 function calls (2 initialization, 1 work) + assert xp.max(res.maxlevel) >= 2 + assert xp.max(res.maxlevel) == f.ncall + + def test_flags(self, xp): + # Test cases that should produce different status flags; show that all + # can be produced simultaneously. + def f(xs, js): + f.nit += 1 + funcs = [lambda x: xp.exp(-x**2), # converges + lambda x: xp.exp(x), # reaches maxiter due to order=2 + lambda x: xp.full_like(x, xp.nan)] # stops due to NaN + res = [] + for i in range(xp_size(js)): + x = xs[i, ...] + j = int(xp_ravel(js)[i]) + res.append(funcs[j](x)) + return xp.stack(res) + f.nit = 0 + + args = (xp.arange(3, dtype=xp.int64),) + a = xp.asarray([xp.inf]*3) + b = xp.asarray([-xp.inf] * 3) + res = _tanhsinh(f, a, b, maxlevel=5, args=args) + ref_flags = xp.asarray([0, -2, -3], dtype=xp.int32) + xp_assert_equal(res.status, ref_flags) + + def test_flags_preserve_shape(self, xp): + # Same test as above but using `preserve_shape` option to simplify. + def f(x): + res = [xp.exp(-x[0]**2), # converges + xp.exp(x[1]), # reaches maxiter due to order=2 + xp.full_like(x[2], xp.nan)] # stops due to NaN + return xp.stack(res) + + a = xp.asarray([xp.inf] * 3) + b = xp.asarray([-xp.inf] * 3) + res = _tanhsinh(f, a, b, maxlevel=5, preserve_shape=True) + ref_flags = xp.asarray([0, -2, -3], dtype=xp.int32) + xp_assert_equal(res.status, ref_flags) + + def test_preserve_shape(self, xp): + # Test `preserve_shape` option + def f(x, xp): + return xp.stack([xp.stack([x, xp.sin(10 * x)]), + xp.stack([xp.cos(30 * x), x * xp.sin(100 * x)])]) + + ref = quad_vec(lambda x: f(x, np), 0, 1) + res = _tanhsinh(lambda x: f(x, xp), xp.asarray(0), xp.asarray(1), + preserve_shape=True) + dtype = xp.asarray(0.).dtype + xp_assert_close(res.integral, xp.asarray(ref[0], dtype=dtype)) + + def test_convergence(self, xp): + # demonstrate that number of accurate digits doubles each iteration + dtype = xp.float64 # this only works with good precision + def f(t): + return t * xp.log(1 + t) + ref = xp.asarray(0.25, dtype=dtype) + a, b = xp.asarray(0., dtype=dtype), xp.asarray(1., dtype=dtype) + + last_logerr = 0 + for i in range(4): + res = _tanhsinh(f, a, b, minlevel=0, maxlevel=i) + logerr = self.error(res.integral, ref, log=True, xp=xp) + assert (logerr < last_logerr * 2 or logerr < -15.5) + last_logerr = logerr + + def test_options_and_result_attributes(self, xp): + # demonstrate that options are behaving as advertised and status + # messages are as intended + xp_test = array_namespace(xp.asarray(1.)) # need xp.atan + + def f(x): + f.calls += 1 + f.feval += xp_size(xp.asarray(x)) + return x**2 * xp_test.atan(x) + + f.ref = xp.asarray((math.pi - 2 + 2 * math.log(2)) / 12, dtype=xp.float64) + + default_rtol = 1e-12 + default_atol = f.ref * default_rtol # effective default absolute tol + + # Keep things simpler by leaving tolerances fixed rather than + # having to make them dtype-dependent + a = xp.asarray(0., dtype=xp.float64) + b = xp.asarray(1., dtype=xp.float64) + + # Test default options + f.feval, f.calls = 0, 0 + ref = _tanhsinh(f, a, b) + assert self.error(ref.integral, f.ref) < ref.error < default_atol + assert ref.nfev == f.feval + ref.calls = f.calls # reference number of function calls + assert ref.success + assert ref.status == 0 + + # Test `maxlevel` equal to required max level + # We should get all the same results + f.feval, f.calls = 0, 0 + maxlevel = int(ref.maxlevel) + res = _tanhsinh(f, a, b, maxlevel=maxlevel) + res.calls = f.calls + assert res == ref + + # Now reduce the maximum level. We won't meet tolerances. + f.feval, f.calls = 0, 0 + maxlevel -= 1 + assert maxlevel >= 2 # can't compare errors otherwise + res = _tanhsinh(f, a, b, maxlevel=maxlevel) + assert self.error(res.integral, f.ref) < res.error > default_atol + assert res.nfev == f.feval < ref.nfev + assert f.calls == ref.calls - 1 + assert not res.success + assert res.status == eim._ECONVERR + + # `maxfun` is currently not enforced + + # # Test `maxfun` equal to required number of function evaluations + # # We should get all the same results + # f.feval, f.calls = 0, 0 + # maxfun = ref.nfev + # res = _tanhsinh(f, 0, f.b, maxfun = maxfun) + # assert res == ref + # + # # Now reduce `maxfun`. We won't meet tolerances. + # f.feval, f.calls = 0, 0 + # maxfun -= 1 + # res = _tanhsinh(f, 0, f.b, maxfun=maxfun) + # assert self.error(res.integral, f.ref) < res.error > default_atol + # assert res.nfev == f.feval < ref.nfev + # assert f.calls == ref.calls - 1 + # assert not res.success + # assert res.status == 2 + + # Take this result to be the new reference + ref = res + ref.calls = f.calls + + # Test `atol` + f.feval, f.calls = 0, 0 + # With this tolerance, we should get the exact same result as ref + atol = np.nextafter(float(ref.error), np.inf) + res = _tanhsinh(f, a, b, rtol=0, atol=atol) + assert res.integral == ref.integral + assert res.error == ref.error + assert res.nfev == f.feval == ref.nfev + assert f.calls == ref.calls + # Except the result is considered to be successful + assert res.success + assert res.status == 0 + + f.feval, f.calls = 0, 0 + # With a tighter tolerance, we should get a more accurate result + atol = np.nextafter(float(ref.error), -np.inf) + res = _tanhsinh(f, a, b, rtol=0, atol=atol) + assert self.error(res.integral, f.ref) < res.error < atol + assert res.nfev == f.feval > ref.nfev + assert f.calls > ref.calls + assert res.success + assert res.status == 0 + + # Test `rtol` + f.feval, f.calls = 0, 0 + # With this tolerance, we should get the exact same result as ref + rtol = np.nextafter(float(ref.error/ref.integral), np.inf) + res = _tanhsinh(f, a, b, rtol=rtol) + assert res.integral == ref.integral + assert res.error == ref.error + assert res.nfev == f.feval == ref.nfev + assert f.calls == ref.calls + # Except the result is considered to be successful + assert res.success + assert res.status == 0 + + f.feval, f.calls = 0, 0 + # With a tighter tolerance, we should get a more accurate result + rtol = np.nextafter(float(ref.error/ref.integral), -np.inf) + res = _tanhsinh(f, a, b, rtol=rtol) + assert self.error(res.integral, f.ref)/f.ref < res.error/res.integral < rtol + assert res.nfev == f.feval > ref.nfev + assert f.calls > ref.calls + assert res.success + assert res.status == 0 + + @pytest.mark.skip_xp_backends('torch', reason= + 'https://github.com/scipy/scipy/pull/21149#issuecomment-2330477359', + ) + @pytest.mark.parametrize('rtol', [1e-4, 1e-14]) + def test_log(self, rtol, xp): + # Test equivalence of log-integration and regular integration + test_tols = dict(atol=1e-18, rtol=1e-15) + + # Positive integrand (real log-integrand) + a = xp.asarray(-1., dtype=xp.float64) + b = xp.asarray(2., dtype=xp.float64) + res = _tanhsinh(norm_logpdf, a, b, log=True, rtol=math.log(rtol)) + ref = _tanhsinh(norm_pdf, a, b, rtol=rtol) + xp_assert_close(xp.exp(res.integral), ref.integral, **test_tols) + xp_assert_close(xp.exp(res.error), ref.error, **test_tols) + assert res.nfev == ref.nfev + + # Real integrand (complex log-integrand) + def f(x): + return -norm_logpdf(x)*norm_pdf(x) + + def logf(x): + return xp.log(norm_logpdf(x) + 0j) + norm_logpdf(x) + xp.pi * 1j + + a = xp.asarray(-xp.inf, dtype=xp.float64) + b = xp.asarray(xp.inf, dtype=xp.float64) + res = _tanhsinh(logf, a, b, log=True) + ref = _tanhsinh(f, a, b) + # In gh-19173, we saw `invalid` warnings on one CI platform. + # Silencing `all` because I can't reproduce locally and don't want + # to risk the need to run CI again. + with np.errstate(all='ignore'): + xp_assert_close(xp.exp(res.integral), ref.integral, **test_tols, + check_dtype=False) + xp_assert_close(xp.exp(res.error), ref.error, **test_tols, + check_dtype=False) + assert res.nfev == ref.nfev + + def test_complex(self, xp): + # Test integration of complex integrand + # Finite limits + def f(x): + return xp.exp(1j * x) + + a, b = xp.asarray(0.), xp.asarray(xp.pi/4) + res = _tanhsinh(f, a, b) + ref = math.sqrt(2)/2 + (1-math.sqrt(2)/2)*1j + xp_assert_close(res.integral, xp.asarray(ref)) + + # Infinite limits + def f(x): + return norm_pdf(x) + 1j/2*norm_pdf(x/2) + + a, b = xp.asarray(xp.inf), xp.asarray(-xp.inf) + res = _tanhsinh(f, a, b) + xp_assert_close(res.integral, xp.asarray(-(1+1j))) + + @pytest.mark.parametrize("maxlevel", range(4)) + def test_minlevel(self, maxlevel, xp): + # Verify that minlevel does not change the values at which the + # integrand is evaluated or the integral/error estimates, only the + # number of function calls + + # need `xp.concat`, `xp.atan`, and `xp.sort` + xp_test = array_namespace(xp.asarray(1.)) + + def f(x): + f.calls += 1 + f.feval += xp_size(xp.asarray(x)) + f.x = xp_test.concat((f.x, xp_ravel(x))) + return x**2 * xp_test.atan(x) + + f.feval, f.calls, f.x = 0, 0, xp.asarray([]) + + a = xp.asarray(0, dtype=xp.float64) + b = xp.asarray(1, dtype=xp.float64) + ref = _tanhsinh(f, a, b, minlevel=0, maxlevel=maxlevel) + ref_x = xp_test.sort(f.x) + + for minlevel in range(0, maxlevel + 1): + f.feval, f.calls, f.x = 0, 0, xp.asarray([]) + options = dict(minlevel=minlevel, maxlevel=maxlevel) + res = _tanhsinh(f, a, b, **options) + # Should be very close; all that has changed is the order of values + xp_assert_close(res.integral, ref.integral, rtol=4e-16) + # Difference in absolute errors << magnitude of integral + xp_assert_close(res.error, ref.error, atol=4e-16 * ref.integral) + assert res.nfev == f.feval == f.x.shape[0] + assert f.calls == maxlevel - minlevel + 1 + 1 # 1 validation call + assert res.status == ref.status + xp_assert_equal(ref_x, xp_test.sort(f.x)) + + def test_improper_integrals(self, xp): + # Test handling of infinite limits of integration (mixed with finite limits) + def f(x): + x[xp.isinf(x)] = xp.nan + return xp.exp(-x**2) + a = xp.asarray([-xp.inf, 0, -xp.inf, xp.inf, -20, -xp.inf, -20]) + b = xp.asarray([xp.inf, xp.inf, 0, -xp.inf, 20, 20, xp.inf]) + ref = math.sqrt(math.pi) + ref = xp.asarray([ref, ref/2, ref/2, -ref, ref, ref, ref]) + res = _tanhsinh(f, a, b) + xp_assert_close(res.integral, ref) + + @pytest.mark.parametrize("limits", ((0, 3), ([-math.inf, 0], [3, 3]))) + @pytest.mark.parametrize("dtype", ('float32', 'float64')) + def test_dtype(self, limits, dtype, xp): + # Test that dtypes are preserved + dtype = getattr(xp, dtype) + a, b = xp.asarray(limits, dtype=dtype) + + def f(x): + assert x.dtype == dtype + return xp.exp(x) + + rtol = 1e-12 if dtype == xp.float64 else 1e-5 + res = _tanhsinh(f, a, b, rtol=rtol) + assert res.integral.dtype == dtype + assert res.error.dtype == dtype + assert xp.all(res.success) + xp_assert_close(res.integral, xp.exp(b)-xp.exp(a)) + + def test_maxiter_callback(self, xp): + # Test behavior of `maxiter` parameter and `callback` interface + a, b = xp.asarray(-xp.inf), xp.asarray(xp.inf) + def f(x): + return xp.exp(-x*x) + + minlevel, maxlevel = 0, 2 + maxiter = maxlevel - minlevel + 1 + kwargs = dict(minlevel=minlevel, maxlevel=maxlevel, rtol=1e-15) + res = _tanhsinh(f, a, b, **kwargs) + assert not res.success + assert res.maxlevel == maxlevel + + def callback(res): + callback.iter += 1 + callback.res = res + assert hasattr(res, 'integral') + assert res.status == 1 + if callback.iter == maxiter: + raise StopIteration + callback.iter = -1 # callback called once before first iteration + callback.res = None + + del kwargs['maxlevel'] + res2 = _tanhsinh(f, a, b, **kwargs, callback=callback) + # terminating with callback is identical to terminating due to maxiter + # (except for `status`) + for key in res.keys(): + if key == 'status': + assert res[key] == -2 + assert res2[key] == -4 + else: + assert res2[key] == callback.res[key] == res[key] + + def test_jumpstart(self, xp): + # The intermediate results at each level i should be the same as the + # final results when jumpstarting at level i; i.e. minlevel=maxlevel=i + a = xp.asarray(-xp.inf, dtype=xp.float64) + b = xp.asarray(xp.inf, dtype=xp.float64) + + def f(x): + return xp.exp(-x*x) + + def callback(res): + callback.integrals.append(xp_copy(res.integral)[()]) + callback.errors.append(xp_copy(res.error)[()]) + callback.integrals = [] + callback.errors = [] + + maxlevel = 4 + _tanhsinh(f, a, b, minlevel=0, maxlevel=maxlevel, callback=callback) + + for i in range(maxlevel + 1): + res = _tanhsinh(f, a, b, minlevel=i, maxlevel=i) + xp_assert_close(callback.integrals[1+i], res.integral, rtol=1e-15) + xp_assert_close(callback.errors[1+i], res.error, rtol=1e-15, atol=1e-16) + + def test_special_cases(self, xp): + # Test edge cases and other special cases + a, b = xp.asarray(0), xp.asarray(1) + xp_test = array_namespace(a, b) # need `xp.isdtype` + + def f(x): + assert xp_test.isdtype(x.dtype, "real floating") + return x + + res = _tanhsinh(f, a, b) + assert res.success + xp_assert_close(res.integral, xp.asarray(0.5)) + + # Test levels 0 and 1; error is NaN + res = _tanhsinh(f, a, b, maxlevel=0) + assert res.integral > 0 + xp_assert_equal(res.error, xp.asarray(xp.nan)) + res = _tanhsinh(f, a, b, maxlevel=1) + assert res.integral > 0 + xp_assert_equal(res.error, xp.asarray(xp.nan)) + + # Test equal left and right integration limits + res = _tanhsinh(f, b, b) + assert res.success + assert res.maxlevel == -1 + xp_assert_close(res.integral, xp.asarray(0.)) + + # Test scalar `args` (not in tuple) + def f(x, c): + return x**c + + res = _tanhsinh(f, a, b, args=29) + xp_assert_close(res.integral, xp.asarray(1/30)) + + # Test NaNs + a = xp.asarray([xp.nan, 0, 0, 0]) + b = xp.asarray([1, xp.nan, 1, 1]) + c = xp.asarray([1, 1, xp.nan, 1]) + res = _tanhsinh(f, a, b, args=(c,)) + xp_assert_close(res.integral, xp.asarray([xp.nan, xp.nan, xp.nan, 0.5])) + xp_assert_equal(res.error[:3], xp.full((3,), xp.nan)) + xp_assert_equal(res.status, xp.asarray([-3, -3, -3, 0], dtype=xp.int32)) + xp_assert_equal(res.success, xp.asarray([False, False, False, True])) + xp_assert_equal(res.nfev[:3], xp.full((3,), 1, dtype=xp.int32)) + + # Test complex integral followed by real integral + # Previously, h0 was of the result dtype. If the `dtype` were complex, + # this could lead to complex cached abscissae/weights. If these get + # cast to real dtype for a subsequent real integral, we would get a + # ComplexWarning. Check that this is avoided. + _pair_cache.xjc = xp.empty(0) + _pair_cache.wj = xp.empty(0) + _pair_cache.indices = [0] + _pair_cache.h0 = None + a, b = xp.asarray(0), xp.asarray(1) + res = _tanhsinh(lambda x: xp.asarray(x*1j), a, b) + xp_assert_close(res.integral, xp.asarray(0.5*1j)) + res = _tanhsinh(lambda x: x, a, b) + xp_assert_close(res.integral, xp.asarray(0.5)) + + # Test zero-size + shape = (0, 3) + res = _tanhsinh(lambda x: x, xp.asarray(0), xp.zeros(shape)) + attrs = ['integral', 'error', 'success', 'status', 'nfev', 'maxlevel'] + for attr in attrs: + assert res[attr].shape == shape + + @pytest.mark.skip_xp_backends(np_only=True) + def test_compress_nodes_weights_gh21496(self, xp): + # See discussion in: + # https://github.com/scipy/scipy/pull/21496#discussion_r1878681049 + # This would cause "ValueError: attempt to get argmax of an empty sequence" + # Check that this has been resolved. + x = np.full(65, 3) + x[-1] = 1000 + _tanhsinh(np.sin, 1, x) + + +@array_api_compatible +@pytest.mark.usefixtures("skip_xp_backends") +@pytest.mark.skip_xp_backends('array_api_strict', reason='No fancy indexing.') +@pytest.mark.skip_xp_backends('jax.numpy', reason='No mutation.') +class TestNSum: + rng = np.random.default_rng(5895448232066142650) + p = rng.uniform(1, 10, size=10).tolist() + + def f1(self, k): + # Integers are never passed to `f1`; if they were, we'd get + # integer to negative integer power error + return k**(-2) + + f1.ref = np.pi**2/6 + f1.a = 1 + f1.b = np.inf + f1.args = tuple() + + def f2(self, k, p): + return 1 / k**p + + f2.ref = special.zeta(p, 1) + f2.a = 1. + f2.b = np.inf + f2.args = (p,) + + def f3(self, k, p): + return 1 / k**p + + f3.a = 1 + f3.b = rng.integers(5, 15, size=(3, 1)) + f3.ref = _gen_harmonic_gt1(f3.b, p) + f3.args = (p,) + + def test_input_validation(self, xp): + f = self.f1 + a, b = xp.asarray(f.a), xp.asarray(f.b) + + message = '`f` must be callable.' + with pytest.raises(ValueError, match=message): + nsum(42, a, b) + + message = '...must be True or False.' + with pytest.raises(ValueError, match=message): + nsum(f, a, b, log=2) + + message = '...must be real numbers.' + with pytest.raises(ValueError, match=message): + nsum(f, xp.asarray(1+1j), b) + with pytest.raises(ValueError, match=message): + nsum(f, a, xp.asarray(1+1j)) + with pytest.raises(ValueError, match=message): + nsum(f, a, b, step=xp.asarray(1+1j)) + with pytest.raises(ValueError, match=message): + nsum(f, a, b, tolerances=dict(atol='ekki')) + with pytest.raises(ValueError, match=message): + nsum(f, a, b, tolerances=dict(rtol=pytest)) + + with np.errstate(all='ignore'): + res = nsum(f, xp.asarray([np.nan, np.inf]), xp.asarray(1.)) + assert xp.all((res.status == -1) & xp.isnan(res.sum) + & xp.isnan(res.error) & ~res.success & res.nfev == 1) + res = nsum(f, xp.asarray(10.), xp.asarray([np.nan, 1])) + assert xp.all((res.status == -1) & xp.isnan(res.sum) + & xp.isnan(res.error) & ~res.success & res.nfev == 1) + res = nsum(f, xp.asarray(1.), xp.asarray(10.), + step=xp.asarray([xp.nan, -xp.inf, xp.inf, -1, 0])) + assert xp.all((res.status == -1) & xp.isnan(res.sum) + & xp.isnan(res.error) & ~res.success & res.nfev == 1) + + message = '...must be non-negative and finite.' + with pytest.raises(ValueError, match=message): + nsum(f, a, b, tolerances=dict(rtol=-1)) + with pytest.raises(ValueError, match=message): + nsum(f, a, b, tolerances=dict(atol=np.inf)) + + message = '...may not be positive infinity.' + with pytest.raises(ValueError, match=message): + nsum(f, a, b, tolerances=dict(rtol=np.inf), log=True) + with pytest.raises(ValueError, match=message): + nsum(f, a, b, tolerances=dict(atol=np.inf), log=True) + + message = '...must be a non-negative integer.' + with pytest.raises(ValueError, match=message): + nsum(f, a, b, maxterms=3.5) + with pytest.raises(ValueError, match=message): + nsum(f, a, b, maxterms=-2) + + @pytest.mark.parametrize('f_number', range(1, 4)) + def test_basic(self, f_number, xp): + dtype = xp.asarray(1.).dtype + f = getattr(self, f"f{f_number}") + a, b = xp.asarray(f.a), xp.asarray(f.b), + args = tuple(xp.asarray(arg) for arg in f.args) + ref = xp.asarray(f.ref, dtype=dtype) + res = nsum(f, a, b, args=args) + xp_assert_close(res.sum, ref) + xp_assert_equal(res.status, xp.zeros(ref.shape, dtype=xp.int32)) + xp_test = array_namespace(a) # CuPy doesn't have `bool` + xp_assert_equal(res.success, xp.ones(ref.shape, dtype=xp_test.bool)) + + with np.errstate(divide='ignore'): + logres = nsum(lambda *args: xp.log(f(*args)), + a, b, log=True, args=args) + xp_assert_close(xp.exp(logres.sum), res.sum) + xp_assert_close(xp.exp(logres.error), res.error, atol=1e-15) + xp_assert_equal(logres.status, res.status) + xp_assert_equal(logres.success, res.success) + + @pytest.mark.parametrize('maxterms', [0, 1, 10, 20, 100]) + def test_integral(self, maxterms, xp): + # test precise behavior of integral approximation + f = self.f1 + + def logf(x): + return -2*xp.log(x) + + def F(x): + return -1 / x + + a = xp.asarray([1, 5], dtype=xp.float64)[:, xp.newaxis] + b = xp.asarray([20, 100, xp.inf], dtype=xp.float64)[:, xp.newaxis, xp.newaxis] + step = xp.asarray([0.5, 1, 2], dtype=xp.float64).reshape((-1, 1, 1, 1)) + nsteps = xp.floor((b - a)/step) + b_original = b + b = a + nsteps*step + + k = a + maxterms*step + # partial sum + direct = xp.sum(f(a + xp.arange(maxterms)*step), axis=-1, keepdims=True) + integral = (F(b) - F(k))/step # integral approximation of remainder + low = direct + integral + f(b) # theoretical lower bound + high = direct + integral + f(k) # theoretical upper bound + ref_sum = (low + high)/2 # nsum uses average of the two + ref_err = (high - low)/2 # error (assuming perfect quadrature) + + # correct reference values where number of terms < maxterms + xp_test = array_namespace(a) # torch needs broadcast_arrays + a, b, step = xp_test.broadcast_arrays(a, b, step) + for i in np.ndindex(a.shape): + ai, bi, stepi = float(a[i]), float(b[i]), float(step[i]) + if (bi - ai)/stepi + 1 <= maxterms: + direct = xp.sum(f(xp.arange(ai, bi+stepi, stepi, dtype=xp.float64))) + ref_sum[i] = direct + ref_err[i] = direct * xp.finfo(direct.dtype).eps + + rtol = 1e-12 + res = nsum(f, a, b_original, step=step, maxterms=maxterms, + tolerances=dict(rtol=rtol)) + xp_assert_close(res.sum, ref_sum, rtol=10*rtol) + xp_assert_close(res.error, ref_err, rtol=100*rtol) + + i = ((b_original - a)/step + 1 <= maxterms) + xp_assert_close(res.sum[i], ref_sum[i], rtol=1e-15) + xp_assert_close(res.error[i], ref_err[i], rtol=1e-15) + + logres = nsum(logf, a, b_original, step=step, log=True, + tolerances=dict(rtol=math.log(rtol)), maxterms=maxterms) + xp_assert_close(xp.exp(logres.sum), res.sum) + xp_assert_close(xp.exp(logres.error), res.error) + + @pytest.mark.parametrize('shape', [tuple(), (12,), (3, 4), (3, 2, 2)]) + def test_vectorization(self, shape, xp): + # Test for correct functionality, output shapes, and dtypes for various + # input shapes. + rng = np.random.default_rng(82456839535679456794) + a = rng.integers(1, 10, size=shape) + # when the sum can be computed directly or `maxterms` is large enough + # to meet `atol`, there are slight differences (for good reason) + # between vectorized call and looping. + b = np.inf + p = rng.random(shape) + 1 + n = math.prod(shape) + + def f(x, p): + f.feval += 1 if (x.size == n or x.ndim <= 1) else x.shape[-1] + return 1 / x ** p + + f.feval = 0 + + @np.vectorize + def nsum_single(a, b, p, maxterms): + return nsum(lambda x: 1 / x**p, a, b, maxterms=maxterms) + + res = nsum(f, xp.asarray(a), xp.asarray(b), maxterms=1000, + args=(xp.asarray(p),)) + refs = nsum_single(a, b, p, maxterms=1000).ravel() + + attrs = ['sum', 'error', 'success', 'status', 'nfev'] + for attr in attrs: + ref_attr = [xp.asarray(getattr(ref, attr)) for ref in refs] + res_attr = getattr(res, attr) + xp_assert_close(xp_ravel(res_attr), xp.asarray(ref_attr), rtol=1e-15) + assert res_attr.shape == shape + + xp_test = array_namespace(xp.asarray(1.)) + assert xp_test.isdtype(res.success.dtype, 'bool') + assert xp_test.isdtype(res.status.dtype, 'integral') + assert xp_test.isdtype(res.nfev.dtype, 'integral') + if is_numpy(xp): # other libraries might have different number + assert int(xp.max(res.nfev)) == f.feval + + def test_status(self, xp): + f = self.f2 + + p = [2, 2, 0.9, 1.1, 2, 2] + a = xp.asarray([0, 0, 1, 1, 1, np.nan], dtype=xp.float64) + b = xp.asarray([10, np.inf, np.inf, np.inf, np.inf, np.inf], dtype=xp.float64) + ref = special.zeta(p, 1) + p = xp.asarray(p, dtype=xp.float64) + + with np.errstate(divide='ignore'): # intentionally dividing by zero + res = nsum(f, a, b, args=(p,)) + + ref_success = xp.asarray([False, False, False, False, True, False]) + ref_status = xp.asarray([-3, -3, -2, -4, 0, -1], dtype=xp.int32) + xp_assert_equal(res.success, ref_success) + xp_assert_equal(res.status, ref_status) + xp_assert_close(res.sum[res.success], xp.asarray(ref)[res.success]) + + def test_nfev(self, xp): + def f(x): + f.nfev += xp_size(x) + return 1 / x**2 + + f.nfev = 0 + res = nsum(f, xp.asarray(1), xp.asarray(10)) + assert res.nfev == f.nfev + + f.nfev = 0 + res = nsum(f, xp.asarray(1), xp.asarray(xp.inf), tolerances=dict(atol=1e-6)) + assert res.nfev == f.nfev + + def test_inclusive(self, xp): + # There was an edge case off-by one bug when `_direct` was called with + # `inclusive=True`. Check that this is resolved. + a = xp.asarray([1, 4]) + b = xp.asarray(xp.inf) + res = nsum(lambda k: 1 / k ** 2, a, b, + maxterms=500, tolerances=dict(atol=0.1)) + ref = nsum(lambda k: 1 / k ** 2, a, b) + assert xp.all(res.sum > (ref.sum - res.error)) + assert xp.all(res.sum < (ref.sum + res.error)) + + @pytest.mark.parametrize('log', [True, False]) + def test_infinite_bounds(self, log, xp): + a = xp.asarray([1, -np.inf, -np.inf]) + b = xp.asarray([np.inf, -1, np.inf]) + c = xp.asarray([1, 2, 3]) + + def f(x, a): + return (xp.log(xp.tanh(a / 2)) - a*xp.abs(x) if log + else xp.tanh(a/2) * xp.exp(-a*xp.abs(x))) + + res = nsum(f, a, b, args=(c,), log=log) + ref = xp.asarray([stats.dlaplace.sf(0, 1), stats.dlaplace.sf(0, 2), 1]) + ref = xp.log(ref) if log else ref + atol = (1e-10 if a.dtype==xp.float64 else 1e-5) if log else 0 + xp_assert_close(res.sum, xp.asarray(ref, dtype=a.dtype), atol=atol) + + # # Make sure the sign of `x` passed into `f` is correct. + def f(x, c): + return -3*xp.log(c*x) if log else 1 / (c*x)**3 + + a = xp.asarray([1, -np.inf]) + b = xp.asarray([np.inf, -1]) + arg = xp.asarray([1, -1]) + res = nsum(f, a, b, args=(arg,), log=log) + ref = np.log(special.zeta(3)) if log else special.zeta(3) + xp_assert_close(res.sum, xp.full(a.shape, ref, dtype=a.dtype)) + + def test_decreasing_check(self, xp): + # Test accuracy when we start sum on an uphill slope. + # Without the decreasing check, the terms would look small enough to + # use the integral approximation. Because the function is not decreasing, + # the error is not bounded by the magnitude of the last term of the + # partial sum. In this case, the error would be ~1e-4, causing the test + # to fail. + def f(x): + return xp.exp(-x ** 2) + + a, b = xp.asarray(-25, dtype=xp.float64), xp.asarray(np.inf, dtype=xp.float64) + res = nsum(f, a, b) + + # Reference computed with mpmath: + # from mpmath import mp + # mp.dps = 50 + # def fmp(x): return mp.exp(-x**2) + # ref = mp.nsum(fmp, (-25, 0)) + mp.nsum(fmp, (1, mp.inf)) + ref = xp.asarray(1.772637204826652, dtype=xp.float64) + + xp_assert_close(res.sum, ref, rtol=1e-15) + + def test_special_case(self, xp): + # test equal lower/upper limit + f = self.f1 + a = b = xp.asarray(2) + res = nsum(f, a, b) + xp_assert_equal(res.sum, xp.asarray(f(2))) + + # Test scalar `args` (not in tuple) + res = nsum(self.f2, xp.asarray(1), xp.asarray(np.inf), args=xp.asarray(2)) + xp_assert_close(res.sum, xp.asarray(self.f1.ref)) # f1.ref is correct w/ args=2 + + # Test 0 size input + a = xp.empty((3, 1, 1)) # arbitrary broadcastable shapes + b = xp.empty((0, 1)) # could use Hypothesis + p = xp.empty(4) # but it's overkill + shape = np.broadcast_shapes(a.shape, b.shape, p.shape) + res = nsum(self.f2, a, b, args=(p,)) + assert res.sum.shape == shape + assert res.status.shape == shape + assert res.nfev.shape == shape + + # Test maxterms=0 + def f(x): + with np.errstate(divide='ignore'): + return 1 / x + + res = nsum(f, xp.asarray(0), xp.asarray(10), maxterms=0) + assert xp.isnan(res.sum) + assert xp.isnan(res.error) + assert res.status == -2 + + res = nsum(f, xp.asarray(0), xp.asarray(10), maxterms=1) + assert xp.isnan(res.sum) + assert xp.isnan(res.error) + assert res.status == -3 + + # Test NaNs + # should skip both direct and integral methods if there are NaNs + a = xp.asarray([xp.nan, 1, 1, 1]) + b = xp.asarray([xp.inf, xp.nan, xp.inf, xp.inf]) + p = xp.asarray([2, 2, xp.nan, 2]) + res = nsum(self.f2, a, b, args=(p,)) + xp_assert_close(res.sum, xp.asarray([xp.nan, xp.nan, xp.nan, self.f1.ref])) + xp_assert_close(res.error[:3], xp.full((3,), xp.nan)) + xp_assert_equal(res.status, xp.asarray([-1, -1, -3, 0], dtype=xp.int32)) + xp_assert_equal(res.success, xp.asarray([False, False, False, True])) + # Ideally res.nfev[2] would be 1, but `tanhsinh` has some function evals + xp_assert_equal(res.nfev[:2], xp.full((2,), 1, dtype=xp.int32)) + + @pytest.mark.parametrize('dtype', ['float32', 'float64']) + def test_dtype(self, dtype, xp): + dtype = getattr(xp, dtype) + + def f(k): + assert k.dtype == dtype + return 1 / k ** xp.asarray(2, dtype=dtype) + + a = xp.asarray(1, dtype=dtype) + b = xp.asarray([10, xp.inf], dtype=dtype) + res = nsum(f, a, b) + assert res.sum.dtype == dtype + assert res.error.dtype == dtype + + rtol = 1e-12 if dtype == xp.float64 else 1e-6 + ref = _gen_harmonic_gt1(np.asarray([10, xp.inf]), 2) + xp_assert_close(res.sum, xp.asarray(ref, dtype=dtype), rtol=rtol) + + @pytest.mark.parametrize('case', [(10, 100), (100, 10)]) + def test_nondivisible_interval(self, case, xp): + # When the limits of the sum are such that (b - a)/step + # is not exactly integral, check that only floor((b - a)/step) + # terms are included. + n, maxterms = case + + def f(k): + return 1 / k ** 2 + + a = np.e + step = 1 / 3 + b0 = a + n * step + i = np.arange(-2, 3) + b = b0 + i * np.spacing(b0) + ns = np.floor((b - a) / step) + assert len(set(ns)) == 2 + + a, b = xp.asarray(a, dtype=xp.float64), xp.asarray(b, dtype=xp.float64) + step, ns = xp.asarray(step, dtype=xp.float64), xp.asarray(ns, dtype=xp.float64) + res = nsum(f, a, b, step=step, maxterms=maxterms) + xp_assert_equal(xp.diff(ns) > 0, xp.diff(res.sum) > 0) + xp_assert_close(res.sum[-1], res.sum[0] + f(b0)) + + @pytest.mark.skip_xp_backends(np_only=True, reason='Needs beta function.') + def test_logser_kurtosis_gh20648(self, xp): + # Some functions return NaN at infinity rather than 0 like they should. + # Check that this is accounted for. + ref = stats.yulesimon.moment(4, 5) + def f(x): + return stats.yulesimon._pmf(x, 5) * x**4 + + with np.errstate(invalid='ignore'): + assert np.isnan(f(np.inf)) + + res = nsum(f, 1, np.inf) + assert_allclose(res.sum, ref) diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_backward.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_backward.h new file mode 100644 index 0000000000000000000000000000000000000000..1ba88cf3e26a2cc3adba8cff236dc20b0bab77f2 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_backward.h @@ -0,0 +1,26 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_cudnn_rnn.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_cudnn_rnn.h new file mode 100644 index 0000000000000000000000000000000000000000..e6bdb3f54ae1bf5831b9c97a9b055f82acd76d1a --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_cudnn_rnn.h @@ -0,0 +1,91 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_cudnn_rnn(Tensor input, Tensor[] weight, int weight_stride0, Tensor? weight_buf, Tensor hx, Tensor? cx, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, float dropout, bool train, bool bidirectional, SymInt[] batch_sizes, Tensor? dropout_state) -> (Tensor, Tensor, Tensor, Tensor, Tensor) +inline ::std::tuple _cudnn_rnn(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, at::IntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, c10::fromIntArrayRefSlow(batch_sizes), dropout_state); +} +namespace symint { + template ::value>> + ::std::tuple _cudnn_rnn(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, at::IntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, c10::fromIntArrayRefSlow(batch_sizes), dropout_state); + } +} + +// aten::_cudnn_rnn(Tensor input, Tensor[] weight, int weight_stride0, Tensor? weight_buf, Tensor hx, Tensor? cx, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, float dropout, bool train, bool bidirectional, SymInt[] batch_sizes, Tensor? dropout_state) -> (Tensor, Tensor, Tensor, Tensor, Tensor) +inline ::std::tuple _cudnn_rnn_symint(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, c10::SymIntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, batch_sizes, dropout_state); +} +namespace symint { + template ::value>> + ::std::tuple _cudnn_rnn(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, c10::SymIntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, batch_sizes, dropout_state); + } +} + +// aten::_cudnn_rnn.out(Tensor input, Tensor[] weight, int weight_stride0, Tensor? weight_buf, Tensor hx, Tensor? cx, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, float dropout, bool train, bool bidirectional, SymInt[] batch_sizes, Tensor? dropout_state, *, Tensor(a!) out0, Tensor(b!) out1, Tensor(c!) out2, Tensor(d!) out3, Tensor(e!) out4) -> (Tensor(a!), Tensor(b!), Tensor(c!), Tensor(d!), Tensor(e!)) +inline ::std::tuple _cudnn_rnn_out(at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4, const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, at::IntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, c10::fromIntArrayRefSlow(batch_sizes), dropout_state, out0, out1, out2, out3, out4); +} +namespace symint { + template ::value>> + ::std::tuple _cudnn_rnn_out(at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4, const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, at::IntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, c10::fromIntArrayRefSlow(batch_sizes), dropout_state, out0, out1, out2, out3, out4); + } +} + +// aten::_cudnn_rnn.out(Tensor input, Tensor[] weight, int weight_stride0, Tensor? weight_buf, Tensor hx, Tensor? cx, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, float dropout, bool train, bool bidirectional, SymInt[] batch_sizes, Tensor? dropout_state, *, Tensor(a!) out0, Tensor(b!) out1, Tensor(c!) out2, Tensor(d!) out3, Tensor(e!) out4) -> (Tensor(a!), Tensor(b!), Tensor(c!), Tensor(d!), Tensor(e!)) +inline ::std::tuple _cudnn_rnn_outf(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, at::IntArrayRef batch_sizes, const ::std::optional & dropout_state, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, c10::fromIntArrayRefSlow(batch_sizes), dropout_state, out0, out1, out2, out3, out4); +} +namespace symint { + template ::value>> + ::std::tuple _cudnn_rnn_outf(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, at::IntArrayRef batch_sizes, const ::std::optional & dropout_state, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, c10::fromIntArrayRefSlow(batch_sizes), dropout_state, out0, out1, out2, out3, out4); + } +} + +// aten::_cudnn_rnn.out(Tensor input, Tensor[] weight, int weight_stride0, Tensor? weight_buf, Tensor hx, Tensor? cx, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, float dropout, bool train, bool bidirectional, SymInt[] batch_sizes, Tensor? dropout_state, *, Tensor(a!) out0, Tensor(b!) out1, Tensor(c!) out2, Tensor(d!) out3, Tensor(e!) out4) -> (Tensor(a!), Tensor(b!), Tensor(c!), Tensor(d!), Tensor(e!)) +inline ::std::tuple _cudnn_rnn_symint_out(at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4, const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, c10::SymIntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, batch_sizes, dropout_state, out0, out1, out2, out3, out4); +} +namespace symint { + template ::value>> + ::std::tuple _cudnn_rnn_out(at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4, const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, c10::SymIntArrayRef batch_sizes, const ::std::optional & dropout_state) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, batch_sizes, dropout_state, out0, out1, out2, out3, out4); + } +} + +// aten::_cudnn_rnn.out(Tensor input, Tensor[] weight, int weight_stride0, Tensor? weight_buf, Tensor hx, Tensor? cx, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, float dropout, bool train, bool bidirectional, SymInt[] batch_sizes, Tensor? dropout_state, *, Tensor(a!) out0, Tensor(b!) out1, Tensor(c!) out2, Tensor(d!) out3, Tensor(e!) out4) -> (Tensor(a!), Tensor(b!), Tensor(c!), Tensor(d!), Tensor(e!)) +inline ::std::tuple _cudnn_rnn_symint_outf(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, c10::SymIntArrayRef batch_sizes, const ::std::optional & dropout_state, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, batch_sizes, dropout_state, out0, out1, out2, out3, out4); +} +namespace symint { + template ::value>> + ::std::tuple _cudnn_rnn_outf(const at::Tensor & input, at::TensorList weight, int64_t weight_stride0, const ::std::optional & weight_buf, const at::Tensor & hx, const ::std::optional & cx, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, c10::SymIntArrayRef batch_sizes, const ::std::optional & dropout_state, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, at::Tensor & out3, at::Tensor & out4) { + return at::_ops::_cudnn_rnn_out::call(input, weight, weight_stride0, weight_buf, hx, cx, mode, hidden_size, proj_size, num_layers, batch_first, dropout, train, bidirectional, batch_sizes, dropout_state, out0, out1, out2, out3, out4); + } +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_cummax_helper.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_cummax_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..bdffb81a2eb7760aa1dc7d820d15eb9f4714d6f0 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_cummax_helper.h @@ -0,0 +1,30 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_cummax_helper(Tensor self, Tensor(a!) values, Tensor(b!) indices, int dim) -> () +inline void _cummax_helper(const at::Tensor & self, at::Tensor & values, at::Tensor & indices, int64_t dim) { + return at::_ops::_cummax_helper::call(self, values, indices, dim); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_fake_quantize_learnable_per_channel_affine_backward_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_fake_quantize_learnable_per_channel_affine_backward_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..e62de158b0b8edb8ee4a4a16345eaf4fb01d6e33 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_fake_quantize_learnable_per_channel_affine_backward_ops.h @@ -0,0 +1,28 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API _fake_quantize_learnable_per_channel_affine_backward { + using schema = ::std::tuple (const at::Tensor &, const at::Tensor &, const at::Tensor &, const at::Tensor &, int64_t, int64_t, int64_t, double); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_fake_quantize_learnable_per_channel_affine_backward") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_fake_quantize_learnable_per_channel_affine_backward(Tensor grad, Tensor self, Tensor scale, Tensor zero_point, int axis, int quant_min, int quant_max, float grad_factor=1.0) -> (Tensor, Tensor, Tensor)") + static ::std::tuple call(const at::Tensor & grad, const at::Tensor & self, const at::Tensor & scale, const at::Tensor & zero_point, int64_t axis, int64_t quant_min, int64_t quant_max, double grad_factor); + static ::std::tuple redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad, const at::Tensor & self, const at::Tensor & scale, const at::Tensor & zero_point, int64_t axis, int64_t quant_min, int64_t quant_max, double grad_factor); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_sin_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_sin_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..199dc8a95ed828808c760bd76a41123513a9a6c6 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_sin_ops.h @@ -0,0 +1,50 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API _foreach_sin { + using schema = ::std::vector (at::TensorList); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_foreach_sin") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_foreach_sin(Tensor[] self) -> Tensor[]") + static ::std::vector call(at::TensorList self); + static ::std::vector redispatch(c10::DispatchKeySet dispatchKeySet, at::TensorList self); +}; + +struct TORCH_API _foreach_sin_ { + using schema = void (at::TensorList); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_foreach_sin_") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_foreach_sin_(Tensor(a!)[] self) -> ()") + static void call(at::TensorList self); + static void redispatch(c10::DispatchKeySet dispatchKeySet, at::TensorList self); +}; + +struct TORCH_API _foreach_sin_out { + using schema = void (at::TensorList, at::TensorList); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_foreach_sin") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_foreach_sin.out(Tensor[] self, *, Tensor(a!)[] out) -> ()") + static void call(at::TensorList self, at::TensorList out); + static void redispatch(c10::DispatchKeySet dispatchKeySet, at::TensorList self, at::TensorList out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_tan.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_tan.h new file mode 100644 index 0000000000000000000000000000000000000000..f3b47f6f5aa589945bce349bebcfa25c76941eb9 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_tan.h @@ -0,0 +1,44 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_foreach_tan(Tensor[] self) -> Tensor[] +inline ::std::vector _foreach_tan(at::TensorList self) { + return at::_ops::_foreach_tan::call(self); +} + +// aten::_foreach_tan_(Tensor(a!)[] self) -> () +inline void _foreach_tan_(at::TensorList self) { + return at::_ops::_foreach_tan_::call(self); +} + +// aten::_foreach_tan.out(Tensor[] self, *, Tensor(a!)[] out) -> () +inline void _foreach_tan_out(at::TensorList out, at::TensorList self) { + return at::_ops::_foreach_tan_out::call(self, out); +} +// aten::_foreach_tan.out(Tensor[] self, *, Tensor(a!)[] out) -> () +inline void _foreach_tan_outf(at::TensorList self, at::TensorList out) { + return at::_ops::_foreach_tan_out::call(self, out); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_fw_primal_copy_compositeexplicitautogradnonfunctional_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_fw_primal_copy_compositeexplicitautogradnonfunctional_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..837cbdb157ace79160d6103c1730e8fffb7dbaa7 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_fw_primal_copy_compositeexplicitautogradnonfunctional_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautogradnonfunctional { + +TORCH_API at::Tensor _fw_primal_copy(const at::Tensor & self, int64_t level); + +} // namespace compositeexplicitautogradnonfunctional +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_linalg_eigh_cpu_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_linalg_eigh_cpu_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..34ce1d188551928520447d8844b3fe99fe206c60 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_linalg_eigh_cpu_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cpu { + +TORCH_API ::std::tuple _linalg_eigh(const at::Tensor & A, c10::string_view UPLO="L", bool compute_v=true); +TORCH_API ::std::tuple _linalg_eigh_out(at::Tensor & eigenvalues, at::Tensor & eigenvectors, const at::Tensor & A, c10::string_view UPLO="L", bool compute_v=true); +TORCH_API ::std::tuple _linalg_eigh_outf(const at::Tensor & A, c10::string_view UPLO, bool compute_v, at::Tensor & eigenvalues, at::Tensor & eigenvectors); + +} // namespace cpu +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_linalg_solve_ex_compositeexplicitautogradnonfunctional_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_linalg_solve_ex_compositeexplicitautogradnonfunctional_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..ee7ea5a01eb8336cbaf13750113e5ca765694922 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_linalg_solve_ex_compositeexplicitautogradnonfunctional_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautogradnonfunctional { + +TORCH_API ::std::tuple _linalg_solve_ex(const at::Tensor & A, const at::Tensor & B, bool left=true, bool check_errors=false); + +} // namespace compositeexplicitautogradnonfunctional +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_masked_scale_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_masked_scale_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..278750621cc24b58b9c7fe9cebb0e84e16d5f086 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_masked_scale_ops.h @@ -0,0 +1,39 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API _masked_scale { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &, double); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_masked_scale") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_masked_scale(Tensor self, Tensor mask, float scale) -> Tensor") + static at::Tensor call(const at::Tensor & self, const at::Tensor & mask, double scale); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & mask, double scale); +}; + +struct TORCH_API _masked_scale_out { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, double, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_masked_scale") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_masked_scale.out(Tensor self, Tensor mask, float scale, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & self, const at::Tensor & mask, double scale, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & mask, double scale, at::Tensor & out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_sum_backward.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_sum_backward.h new file mode 100644 index 0000000000000000000000000000000000000000..93f4738c5e461644a996d3e9bf190cbf99b3ce38 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_sum_backward.h @@ -0,0 +1,30 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_nested_sum_backward(Tensor grad, Tensor self, int[1]? dim, bool keepdim=False) -> Tensor +inline at::Tensor _nested_sum_backward(const at::Tensor & grad, const at::Tensor & self, at::OptionalIntArrayRef dim, bool keepdim=false) { + return at::_ops::_nested_sum_backward::call(grad, self, dim, keepdim); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_view_from_buffer_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_view_from_buffer_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..211b9fe4ebf60200af1b28578de77e8015c672c4 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_view_from_buffer_ops.h @@ -0,0 +1,28 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API _nested_view_from_buffer { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &, const at::Tensor &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_nested_view_from_buffer") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_nested_view_from_buffer(Tensor(a) self, Tensor nested_size, Tensor nested_strides, Tensor offsets) -> Tensor(a)") + static at::Tensor call(const at::Tensor & self, const at::Tensor & nested_size, const at::Tensor & nested_strides, const at::Tensor & offsets); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & nested_size, const at::Tensor & nested_strides, const at::Tensor & offsets); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_pack_padded_sequence_native.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_pack_padded_sequence_native.h new file mode 100644 index 0000000000000000000000000000000000000000..da48665e2876fdfd1cf8f02874ea155767dbdd77 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_pack_padded_sequence_native.h @@ -0,0 +1,22 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace at { +namespace native { +TORCH_API ::std::tuple _pack_padded_sequence(const at::Tensor & input, const at::Tensor & lengths, bool batch_first); +TORCH_API ::std::tuple _pack_padded_sequence_out(const at::Tensor & input, const at::Tensor & lengths, bool batch_first, at::Tensor & out0, at::Tensor & out1); +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_cudnn_attention_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_cudnn_attention_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..0c4f59a5c39125b7832c94f078e16ee471356511 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_cudnn_attention_cuda_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API ::std::tuple _scaled_dot_product_cudnn_attention(const at::Tensor & query, const at::Tensor & key, const at::Tensor & value, const ::std::optional & attn_bias, bool compute_log_sumexp, double dropout_p=0.0, bool is_causal=false, bool return_debug_mask=false, ::std::optional scale=::std::nullopt); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_flash_attention_for_cpu_backward_cpu_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_flash_attention_for_cpu_backward_cpu_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..ce6f76b21f72fb675215a5824397ceff4ce5b742 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_flash_attention_for_cpu_backward_cpu_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cpu { + +TORCH_API ::std::tuple _scaled_dot_product_flash_attention_for_cpu_backward(const at::Tensor & grad_out, const at::Tensor & query, const at::Tensor & key, const at::Tensor & value, const at::Tensor & out, const at::Tensor & logsumexp, double dropout_p, bool is_causal, const ::std::optional & attn_mask={}, ::std::optional scale=::std::nullopt); + +} // namespace cpu +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_csc_tensor_unsafe.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_csc_tensor_unsafe.h new file mode 100644 index 0000000000000000000000000000000000000000..2db395d6c288cfa74145380176a93470171f2c46 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_csc_tensor_unsafe.h @@ -0,0 +1,34 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_sparse_csc_tensor_unsafe(Tensor ccol_indices, Tensor row_indices, Tensor values, int[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor +inline at::Tensor _sparse_csc_tensor_unsafe(const at::Tensor & ccol_indices, const at::Tensor & row_indices, const at::Tensor & values, at::IntArrayRef size, at::TensorOptions options={}) { + return at::_ops::_sparse_csc_tensor_unsafe::call(ccol_indices, row_indices, values, size, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt()); +} +// aten::_sparse_csc_tensor_unsafe(Tensor ccol_indices, Tensor row_indices, Tensor values, int[] size, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor +inline at::Tensor _sparse_csc_tensor_unsafe(const at::Tensor & ccol_indices, const at::Tensor & row_indices, const at::Tensor & values, at::IntArrayRef size, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory) { + return at::_ops::_sparse_csc_tensor_unsafe::call(ccol_indices, row_indices, values, size, dtype, layout, device, pin_memory); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_semi_structured_mm_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_semi_structured_mm_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..52fdbb77a2791be1ff146fab6effbbee7d600695 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_sparse_semi_structured_mm_cuda_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor _sparse_semi_structured_mm(const at::Tensor & mat1, const at::Tensor & mat1_meta, const at::Tensor & mat2, ::std::optional out_dtype=::std::nullopt); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_test_autograd_multiple_dispatch_view_copy_compositeexplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_test_autograd_multiple_dispatch_view_copy_compositeexplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..bebeeb126d48388d8ebf694aeea74cc0f2d33f66 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_test_autograd_multiple_dispatch_view_copy_compositeexplicitautograd_dispatch.h @@ -0,0 +1,24 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautograd { + +TORCH_API at::Tensor & _test_autograd_multiple_dispatch_view_copy_out(at::Tensor & out, const at::Tensor & self); +TORCH_API at::Tensor & _test_autograd_multiple_dispatch_view_copy_outf(const at::Tensor & self, at::Tensor & out); + +} // namespace compositeexplicitautograd +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_thnn_fused_lstm_cell_backward.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_thnn_fused_lstm_cell_backward.h new file mode 100644 index 0000000000000000000000000000000000000000..53fcd8583001c66b7a62685bdb9bab763f80d021 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_thnn_fused_lstm_cell_backward.h @@ -0,0 +1,30 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_thnn_fused_lstm_cell_backward(Tensor? grad_hy, Tensor? grad_cy, Tensor cx, Tensor cy, Tensor workspace, bool has_bias) -> (Tensor, Tensor, Tensor, Tensor, Tensor) +inline ::std::tuple _thnn_fused_lstm_cell_backward(const ::std::optional & grad_hy, const ::std::optional & grad_cy, const at::Tensor & cx, const at::Tensor & cy, const at::Tensor & workspace, bool has_bias) { + return at::_ops::_thnn_fused_lstm_cell_backward::call(grad_hy, grad_cy, cx, cy, workspace, has_bias); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_to_sparse_csr_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_to_sparse_csr_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..0b311424a26d4916bb63d7b6608ccde3c009e986 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_to_sparse_csr_ops.h @@ -0,0 +1,39 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API _to_sparse_csr { + using schema = at::Tensor (const at::Tensor &, ::std::optional); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_to_sparse_csr") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_to_sparse_csr(Tensor self, int? dense_dim=None) -> Tensor") + static at::Tensor call(const at::Tensor & self, ::std::optional dense_dim); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, ::std::optional dense_dim); +}; + +struct TORCH_API _to_sparse_csr_out { + using schema = at::Tensor & (const at::Tensor &, ::std::optional, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_to_sparse_csr") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_to_sparse_csr.out(Tensor self, int? dense_dim=None, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & self, ::std::optional dense_dim, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, ::std::optional dense_dim, at::Tensor & out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_unsafe_masked_index.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_unsafe_masked_index.h new file mode 100644 index 0000000000000000000000000000000000000000..855d2e085fca22de704d73f238225fbdb4eac805 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/_unsafe_masked_index.h @@ -0,0 +1,30 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::_unsafe_masked_index(Tensor self, Tensor mask, Tensor?[] indices, Scalar fill) -> Tensor +inline at::Tensor _unsafe_masked_index(const at::Tensor & self, const at::Tensor & mask, const c10::List<::std::optional> & indices, const at::Scalar & fill) { + return at::_ops::_unsafe_masked_index::call(self, mask, indices, fill); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/addr_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/addr_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..b6e2ad0b10e0c7ac89438072c897fdbe239a8caf --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/addr_ops.h @@ -0,0 +1,50 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API addr { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &, const at::Tensor &, const at::Scalar &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::addr") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "addr(Tensor self, Tensor vec1, Tensor vec2, *, Scalar beta=1, Scalar alpha=1) -> Tensor") + static at::Tensor call(const at::Tensor & self, const at::Tensor & vec1, const at::Tensor & vec2, const at::Scalar & beta, const at::Scalar & alpha); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & vec1, const at::Tensor & vec2, const at::Scalar & beta, const at::Scalar & alpha); +}; + +struct TORCH_API addr_ { + using schema = at::Tensor & (at::Tensor &, const at::Tensor &, const at::Tensor &, const at::Scalar &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::addr_") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "addr_(Tensor(a!) self, Tensor vec1, Tensor vec2, *, Scalar beta=1, Scalar alpha=1) -> Tensor(a!)") + static at::Tensor & call(at::Tensor & self, const at::Tensor & vec1, const at::Tensor & vec2, const at::Scalar & beta, const at::Scalar & alpha); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const at::Tensor & vec1, const at::Tensor & vec2, const at::Scalar & beta, const at::Scalar & alpha); +}; + +struct TORCH_API addr_out { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, const at::Tensor &, const at::Scalar &, const at::Scalar &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::addr") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "addr.out(Tensor self, Tensor vec1, Tensor vec2, *, Scalar beta=1, Scalar alpha=1, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & self, const at::Tensor & vec1, const at::Tensor & vec2, const at::Scalar & beta, const at::Scalar & alpha, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & vec1, const at::Tensor & vec2, const at::Scalar & beta, const at::Scalar & alpha, at::Tensor & out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/all_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/all_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..0313b4e988d4f288d7dc6bb10212608dcb92f673 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/all_cuda_dispatch.h @@ -0,0 +1,31 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor all(const at::Tensor & self, int64_t dim, bool keepdim=false); +TORCH_API at::Tensor & all_out(at::Tensor & out, const at::Tensor & self, int64_t dim, bool keepdim=false); +TORCH_API at::Tensor & all_outf(const at::Tensor & self, int64_t dim, bool keepdim, at::Tensor & out); +TORCH_API at::Tensor all(const at::Tensor & self, at::OptionalIntArrayRef dim, bool keepdim=false); +TORCH_API at::Tensor & all_out(at::Tensor & out, const at::Tensor & self, at::OptionalIntArrayRef dim, bool keepdim=false); +TORCH_API at::Tensor & all_outf(const at::Tensor & self, at::OptionalIntArrayRef dim, bool keepdim, at::Tensor & out); +TORCH_API at::Tensor all(const at::Tensor & self); +TORCH_API at::Tensor & all_out(at::Tensor & out, const at::Tensor & self); +TORCH_API at::Tensor & all_outf(const at::Tensor & self, at::Tensor & out); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/binary_cross_entropy.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/binary_cross_entropy.h new file mode 100644 index 0000000000000000000000000000000000000000..8c405caaf5327d9f3b97be71dd80c2895a7c3302 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/binary_cross_entropy.h @@ -0,0 +1,39 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::binary_cross_entropy(Tensor self, Tensor target, Tensor? weight=None, int reduction=Mean) -> Tensor +inline at::Tensor binary_cross_entropy(const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight={}, int64_t reduction=at::Reduction::Mean) { + return at::_ops::binary_cross_entropy::call(self, target, weight, reduction); +} + +// aten::binary_cross_entropy.out(Tensor self, Tensor target, Tensor? weight=None, int reduction=Mean, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & binary_cross_entropy_out(at::Tensor & out, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight={}, int64_t reduction=at::Reduction::Mean) { + return at::_ops::binary_cross_entropy_out::call(self, target, weight, reduction, out); +} +// aten::binary_cross_entropy.out(Tensor self, Tensor target, Tensor? weight=None, int reduction=Mean, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & binary_cross_entropy_outf(const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, at::Tensor & out) { + return at::_ops::binary_cross_entropy_out::call(self, target, weight, reduction, out); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/cat_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/cat_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..d92ace2d563ab99964d19742f8caa3593c6abbaa --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/cat_cuda_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor cat(const at::ITensorListRef & tensors, int64_t dim=0); +TORCH_API at::Tensor & cat_out(at::Tensor & out, const at::ITensorListRef & tensors, int64_t dim=0); +TORCH_API at::Tensor & cat_outf(const at::ITensorListRef & tensors, int64_t dim, at::Tensor & out); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/conv_transpose1d_native.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/conv_transpose1d_native.h new file mode 100644 index 0000000000000000000000000000000000000000..36bfcff07bcae65c775f02b0f68ac9280fe75458 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/conv_transpose1d_native.h @@ -0,0 +1,21 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace at { +namespace native { +TORCH_API at::Tensor conv_transpose1d_symint(const at::Tensor & input, const at::Tensor & weight, const ::std::optional & bias={}, c10::SymIntArrayRef stride=c10::SymInt(1), c10::SymIntArrayRef padding=c10::SymInt(0), c10::SymIntArrayRef output_padding=c10::SymInt(0), c10::SymInt groups=1, c10::SymIntArrayRef dilation=c10::SymInt(1)); +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/elu_backward_cpu_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/elu_backward_cpu_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..1f8822c072f1f7a7f31a06157ab3a09712ae494e --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/elu_backward_cpu_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cpu { + +TORCH_API at::Tensor elu_backward(const at::Tensor & grad_output, const at::Scalar & alpha, const at::Scalar & scale, const at::Scalar & input_scale, bool is_result, const at::Tensor & self_or_result); +TORCH_API at::Tensor & elu_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Scalar & alpha, const at::Scalar & scale, const at::Scalar & input_scale, bool is_result, const at::Tensor & self_or_result); +TORCH_API at::Tensor & elu_backward_outf(const at::Tensor & grad_output, const at::Scalar & alpha, const at::Scalar & scale, const at::Scalar & input_scale, bool is_result, const at::Tensor & self_or_result, at::Tensor & grad_input); + +} // namespace cpu +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fft_irfft2.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fft_irfft2.h new file mode 100644 index 0000000000000000000000000000000000000000..67f1dceea37136983cf3b6fecc3a88498ea59c10 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fft_irfft2.h @@ -0,0 +1,91 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::fft_irfft2(Tensor self, SymInt[1]? s=None, int[1] dim=[-2,-1], str? norm=None) -> Tensor +inline at::Tensor fft_irfft2(const at::Tensor & self, at::OptionalIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2::call(self, s.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*s)) : ::std::nullopt, dim, norm); +} +namespace symint { + template ::value>> + at::Tensor fft_irfft2(const at::Tensor & self, at::OptionalIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2::call(self, s.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*s)) : ::std::nullopt, dim, norm); + } +} + +// aten::fft_irfft2(Tensor self, SymInt[1]? s=None, int[1] dim=[-2,-1], str? norm=None) -> Tensor +inline at::Tensor fft_irfft2_symint(const at::Tensor & self, at::OptionalSymIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2::call(self, s, dim, norm); +} +namespace symint { + template ::value>> + at::Tensor fft_irfft2(const at::Tensor & self, at::OptionalSymIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2::call(self, s, dim, norm); + } +} + +// aten::fft_irfft2.out(Tensor self, SymInt[1]? s=None, int[1] dim=[-2,-1], str? norm=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & fft_irfft2_out(at::Tensor & out, const at::Tensor & self, at::OptionalIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2_out::call(self, s.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*s)) : ::std::nullopt, dim, norm, out); +} +namespace symint { + template ::value>> + at::Tensor & fft_irfft2_out(at::Tensor & out, const at::Tensor & self, at::OptionalIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2_out::call(self, s.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*s)) : ::std::nullopt, dim, norm, out); + } +} + +// aten::fft_irfft2.out(Tensor self, SymInt[1]? s=None, int[1] dim=[-2,-1], str? norm=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & fft_irfft2_outf(const at::Tensor & self, at::OptionalIntArrayRef s, at::IntArrayRef dim, ::std::optional norm, at::Tensor & out) { + return at::_ops::fft_irfft2_out::call(self, s.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*s)) : ::std::nullopt, dim, norm, out); +} +namespace symint { + template ::value>> + at::Tensor & fft_irfft2_outf(const at::Tensor & self, at::OptionalIntArrayRef s, at::IntArrayRef dim, ::std::optional norm, at::Tensor & out) { + return at::_ops::fft_irfft2_out::call(self, s.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*s)) : ::std::nullopt, dim, norm, out); + } +} + +// aten::fft_irfft2.out(Tensor self, SymInt[1]? s=None, int[1] dim=[-2,-1], str? norm=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & fft_irfft2_symint_out(at::Tensor & out, const at::Tensor & self, at::OptionalSymIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2_out::call(self, s, dim, norm, out); +} +namespace symint { + template ::value>> + at::Tensor & fft_irfft2_out(at::Tensor & out, const at::Tensor & self, at::OptionalSymIntArrayRef s=::std::nullopt, at::IntArrayRef dim={-2,-1}, ::std::optional norm=::std::nullopt) { + return at::_ops::fft_irfft2_out::call(self, s, dim, norm, out); + } +} + +// aten::fft_irfft2.out(Tensor self, SymInt[1]? s=None, int[1] dim=[-2,-1], str? norm=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & fft_irfft2_symint_outf(const at::Tensor & self, at::OptionalSymIntArrayRef s, at::IntArrayRef dim, ::std::optional norm, at::Tensor & out) { + return at::_ops::fft_irfft2_out::call(self, s, dim, norm, out); +} +namespace symint { + template ::value>> + at::Tensor & fft_irfft2_outf(const at::Tensor & self, at::OptionalSymIntArrayRef s, at::IntArrayRef dim, ::std::optional norm, at::Tensor & out) { + return at::_ops::fft_irfft2_out::call(self, s, dim, norm, out); + } +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fractional_max_pool2d_backward_meta_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fractional_max_pool2d_backward_meta_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..64561c87b0da88a0458f9b0a07963a82b9da4b23 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fractional_max_pool2d_backward_meta_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace meta { + +TORCH_API at::Tensor fractional_max_pool2d_backward(const at::Tensor & grad_output, const at::Tensor & self, at::IntArrayRef kernel_size, at::IntArrayRef output_size, const at::Tensor & indices); +TORCH_API at::Tensor & fractional_max_pool2d_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & self, at::IntArrayRef kernel_size, at::IntArrayRef output_size, const at::Tensor & indices); +TORCH_API at::Tensor & fractional_max_pool2d_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, at::IntArrayRef kernel_size, at::IntArrayRef output_size, const at::Tensor & indices, at::Tensor & grad_input); + +} // namespace meta +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fractional_max_pool3d_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fractional_max_pool3d_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..7ea591768bd37f66e5918f6dd021d352a5cd2941 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/fractional_max_pool3d_cuda_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API ::std::tuple fractional_max_pool3d(const at::Tensor & self, at::IntArrayRef kernel_size, at::IntArrayRef output_size, const at::Tensor & random_samples); +TORCH_API ::std::tuple fractional_max_pool3d_out(at::Tensor & output, at::Tensor & indices, const at::Tensor & self, at::IntArrayRef kernel_size, at::IntArrayRef output_size, const at::Tensor & random_samples); +TORCH_API ::std::tuple fractional_max_pool3d_outf(const at::Tensor & self, at::IntArrayRef kernel_size, at::IntArrayRef output_size, const at::Tensor & random_samples, at::Tensor & output, at::Tensor & indices); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/hardtanh_backward_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/hardtanh_backward_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..56da58886c8c7a4cb9f037f17e1e0df27ba78250 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/hardtanh_backward_ops.h @@ -0,0 +1,39 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API hardtanh_backward_grad_input { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, const at::Scalar &, const at::Scalar &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::hardtanh_backward") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "grad_input") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "hardtanh_backward.grad_input(Tensor grad_output, Tensor self, Scalar min_val, Scalar max_val, *, Tensor(a!) grad_input) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & min_val, const at::Scalar & max_val, at::Tensor & grad_input); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & min_val, const at::Scalar & max_val, at::Tensor & grad_input); +}; + +struct TORCH_API hardtanh_backward { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &, const at::Scalar &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::hardtanh_backward") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "hardtanh_backward(Tensor grad_output, Tensor self, Scalar min_val, Scalar max_val) -> Tensor") + static at::Tensor call(const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & min_val, const at::Scalar & max_val); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & min_val, const at::Scalar & max_val); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/huber_loss_backward_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/huber_loss_backward_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..534fd4019d4547dca8c8d7d498233daeac7124a2 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/huber_loss_backward_cuda_dispatch.h @@ -0,0 +1,24 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor & huber_loss_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, int64_t reduction, double delta); +TORCH_API at::Tensor & huber_loss_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, int64_t reduction, double delta, at::Tensor & grad_input); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_add_compositeimplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_add_compositeimplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..df159d65c6a9a6ee02aa3c91082f018aa9fb47d2 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_add_compositeimplicitautograd_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeimplicitautograd { + +TORCH_API at::Tensor index_add(const at::Tensor & self, at::Dimname dim, const at::Tensor & index, const at::Tensor & source, const at::Scalar & alpha=1); + +} // namespace compositeimplicitautograd +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_meta.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_meta.h new file mode 100644 index 0000000000000000000000000000000000000000..ad9463bcb16ca692a8ade7bb56afe428b86b6e1d --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_meta.h @@ -0,0 +1,50 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeMetaFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace at { +namespace meta { + +struct TORCH_API structured_index_Tensor : public TensorIteratorBase { + + template + struct TORCH_API precompute_out { + + precompute_out set_sizes(at::DimVector value) { + static_assert(SIZES == false, "sizes already set"); + precompute_out ret; +ret.sizes = value; +ret.strides = this->strides; +return ret; + } + + + precompute_out set_strides(at::DimVector value) { + static_assert(STRIDES == false, "strides already set"); + precompute_out ret; +ret.sizes = this->sizes; +ret.strides = value; +return ret; + } + + at::DimVector sizes; +at::DimVector strides; + }; + using meta_return_ty = precompute_out ; + meta_return_ty meta(const at::Tensor & self, at::IOptTensorListRef indices); +}; + +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_reduce_meta_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_reduce_meta_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..3a00a88d2ae924fec00dff4a255dd40aa4fe1912 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/index_reduce_meta_dispatch.h @@ -0,0 +1,26 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace meta { + +TORCH_API at::Tensor index_reduce(const at::Tensor & self, int64_t dim, const at::Tensor & index, const at::Tensor & source, c10::string_view reduce, bool include_self=true); +TORCH_API at::Tensor & index_reduce_out(at::Tensor & out, const at::Tensor & self, int64_t dim, const at::Tensor & index, const at::Tensor & source, c10::string_view reduce, bool include_self=true); +TORCH_API at::Tensor & index_reduce_outf(const at::Tensor & self, int64_t dim, const at::Tensor & index, const at::Tensor & source, c10::string_view reduce, bool include_self, at::Tensor & out); +TORCH_API at::Tensor & index_reduce_(at::Tensor & self, int64_t dim, const at::Tensor & index, const at::Tensor & source, c10::string_view reduce, bool include_self=true); + +} // namespace meta +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/is_pinned_compositeexplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/is_pinned_compositeexplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..fb0152474ec8c70f7e5e5d21980ec6f84b71172c --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/is_pinned_compositeexplicitautograd_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautograd { + +TORCH_API bool is_pinned(const at::Tensor & self, ::std::optional device=::std::nullopt); + +} // namespace compositeexplicitautograd +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/logaddexp_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/logaddexp_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..a03fe4e01b22c0214234bb89a3077c92808fda56 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/logaddexp_cuda_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor logaddexp(const at::Tensor & self, const at::Tensor & other); +TORCH_API at::Tensor & logaddexp_out(at::Tensor & out, const at::Tensor & self, const at::Tensor & other); +TORCH_API at::Tensor & logaddexp_outf(const at::Tensor & self, const at::Tensor & other, at::Tensor & out); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/logical_or_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/logical_or_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..dfe5eb3ca58f5968f2629fd1abd81eba1a7b88b9 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/logical_or_ops.h @@ -0,0 +1,50 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API logical_or { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::logical_or") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "logical_or(Tensor self, Tensor other) -> Tensor") + static at::Tensor call(const at::Tensor & self, const at::Tensor & other); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & other); +}; + +struct TORCH_API logical_or_ { + using schema = at::Tensor & (at::Tensor &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::logical_or_") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "logical_or_(Tensor(a!) self, Tensor other) -> Tensor(a!)") + static at::Tensor & call(at::Tensor & self, const at::Tensor & other); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const at::Tensor & other); +}; + +struct TORCH_API logical_or_out { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::logical_or") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "logical_or.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & self, const at::Tensor & other, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & other, at::Tensor & out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/minimum_compositeexplicitautogradnonfunctional_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/minimum_compositeexplicitautogradnonfunctional_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..b87be6278a0c7e38199cd1e1f5f176a32c07517d --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/minimum_compositeexplicitautogradnonfunctional_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautogradnonfunctional { + +TORCH_API at::Tensor minimum(const at::Tensor & self, const at::Tensor & other); + +} // namespace compositeexplicitautogradnonfunctional +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/nanmedian_compositeexplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/nanmedian_compositeexplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..d333c663d6e66c359871ef41ad46cdcf6224a62c --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/nanmedian_compositeexplicitautograd_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautograd { + +TORCH_API at::Tensor & nanmedian_out(at::Tensor & out, const at::Tensor & self); +TORCH_API at::Tensor & nanmedian_outf(const at::Tensor & self, at::Tensor & out); +TORCH_API ::std::tuple nanmedian(const at::Tensor & self, int64_t dim, bool keepdim=false); + +} // namespace compositeexplicitautograd +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/native_group_norm_backward_native.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/native_group_norm_backward_native.h new file mode 100644 index 0000000000000000000000000000000000000000..a6f83a76be9397b7aa5e9a6b797e03f4ebcca85d --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/native_group_norm_backward_native.h @@ -0,0 +1,22 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace at { +namespace native { +TORCH_API ::std::tuple native_group_norm_backward_out_symint(const at::Tensor & grad_out, const at::Tensor & input, const at::Tensor & mean, const at::Tensor & rstd, const ::std::optional & weight, c10::SymInt N, c10::SymInt C, c10::SymInt HxW, int64_t group, ::std::array output_mask, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2); +TORCH_API ::std::tuple native_group_norm_backward(const at::Tensor & grad_out, const at::Tensor & input, const at::Tensor & mean, const at::Tensor & rstd, const ::std::optional & weight, int64_t N, int64_t C, int64_t HxW, int64_t group, ::std::array output_mask); +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/ne_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/ne_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..e34c5ef359ee4eef7061344b5d6f1206cfb0de19 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/ne_ops.h @@ -0,0 +1,83 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API ne_Scalar_out { + using schema = at::Tensor & (const at::Tensor &, const at::Scalar &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::ne") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Scalar_out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "ne.Scalar_out(Tensor self, Scalar other, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & self, const at::Scalar & other, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Scalar & other, at::Tensor & out); +}; + +struct TORCH_API ne_Scalar { + using schema = at::Tensor (const at::Tensor &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::ne") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Scalar") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "ne.Scalar(Tensor self, Scalar other) -> Tensor") + static at::Tensor call(const at::Tensor & self, const at::Scalar & other); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Scalar & other); +}; + +struct TORCH_API ne_Tensor_out { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::ne") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Tensor_out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "ne.Tensor_out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & self, const at::Tensor & other, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & other, at::Tensor & out); +}; + +struct TORCH_API ne_Tensor { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::ne") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Tensor") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "ne.Tensor(Tensor self, Tensor other) -> Tensor") + static at::Tensor call(const at::Tensor & self, const at::Tensor & other); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const at::Tensor & other); +}; + +struct TORCH_API ne__Scalar { + using schema = at::Tensor & (at::Tensor &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::ne_") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Scalar") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "ne_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)") + static at::Tensor & call(at::Tensor & self, const at::Scalar & other); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const at::Scalar & other); +}; + +struct TORCH_API ne__Tensor { + using schema = at::Tensor & (at::Tensor &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::ne_") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Tensor") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "ne_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)") + static at::Tensor & call(at::Tensor & self, const at::Tensor & other); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const at::Tensor & other); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/nll_loss_backward.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/nll_loss_backward.h new file mode 100644 index 0000000000000000000000000000000000000000..823683ccf9d99c46cf760faa9998ca6c218d1dc6 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/nll_loss_backward.h @@ -0,0 +1,91 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::nll_loss_backward.grad_input(Tensor grad_output, Tensor self, Tensor target, Tensor? weight, int reduction, SymInt ignore_index, Tensor total_weight, *, Tensor(a!) grad_input) -> Tensor(a!) +inline at::Tensor & nll_loss_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, int64_t ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); +} +namespace symint { + template ::value>> + at::Tensor & nll_loss_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, int64_t ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); + } +} + +// aten::nll_loss_backward.grad_input(Tensor grad_output, Tensor self, Tensor target, Tensor? weight, int reduction, SymInt ignore_index, Tensor total_weight, *, Tensor(a!) grad_input) -> Tensor(a!) +inline at::Tensor & nll_loss_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, int64_t ignore_index, const at::Tensor & total_weight, at::Tensor & grad_input) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); +} +namespace symint { + template ::value>> + at::Tensor & nll_loss_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, int64_t ignore_index, const at::Tensor & total_weight, at::Tensor & grad_input) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); + } +} + +// aten::nll_loss_backward.grad_input(Tensor grad_output, Tensor self, Tensor target, Tensor? weight, int reduction, SymInt ignore_index, Tensor total_weight, *, Tensor(a!) grad_input) -> Tensor(a!) +inline at::Tensor & nll_loss_backward_symint_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, c10::SymInt ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); +} +namespace symint { + template ::value>> + at::Tensor & nll_loss_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, c10::SymInt ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); + } +} + +// aten::nll_loss_backward.grad_input(Tensor grad_output, Tensor self, Tensor target, Tensor? weight, int reduction, SymInt ignore_index, Tensor total_weight, *, Tensor(a!) grad_input) -> Tensor(a!) +inline at::Tensor & nll_loss_backward_symint_outf(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, c10::SymInt ignore_index, const at::Tensor & total_weight, at::Tensor & grad_input) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); +} +namespace symint { + template ::value>> + at::Tensor & nll_loss_backward_outf(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, c10::SymInt ignore_index, const at::Tensor & total_weight, at::Tensor & grad_input) { + return at::_ops::nll_loss_backward_grad_input::call(grad_output, self, target, weight, reduction, ignore_index, total_weight, grad_input); + } +} + +// aten::nll_loss_backward(Tensor grad_output, Tensor self, Tensor target, Tensor? weight, int reduction, SymInt ignore_index, Tensor total_weight) -> Tensor +inline at::Tensor nll_loss_backward(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, int64_t ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward::call(grad_output, self, target, weight, reduction, ignore_index, total_weight); +} +namespace symint { + template ::value>> + at::Tensor nll_loss_backward(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, int64_t ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward::call(grad_output, self, target, weight, reduction, ignore_index, total_weight); + } +} + +// aten::nll_loss_backward(Tensor grad_output, Tensor self, Tensor target, Tensor? weight, int reduction, SymInt ignore_index, Tensor total_weight) -> Tensor +inline at::Tensor nll_loss_backward_symint(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, c10::SymInt ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward::call(grad_output, self, target, weight, reduction, ignore_index, total_weight); +} +namespace symint { + template ::value>> + at::Tensor nll_loss_backward(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & target, const ::std::optional & weight, int64_t reduction, c10::SymInt ignore_index, const at::Tensor & total_weight) { + return at::_ops::nll_loss_backward::call(grad_output, self, target, weight, reduction, ignore_index, total_weight); + } +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/normal_compositeexplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/normal_compositeexplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..9926cf0ce46ca092930b1567503bd4f43e61bb1a --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/normal_compositeexplicitautograd_dispatch.h @@ -0,0 +1,33 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautograd { + +TORCH_API at::Tensor normal_functional(const at::Tensor & self, double mean=0, double std=1, ::std::optional generator=::std::nullopt); +TORCH_API at::Tensor & normal_out(at::Tensor & out, const at::Tensor & self, double mean=0, double std=1, ::std::optional generator=::std::nullopt); +TORCH_API at::Tensor & normal_outf(const at::Tensor & self, double mean, double std, ::std::optional generator, at::Tensor & out); +TORCH_API at::Tensor normal(double mean, double std, at::IntArrayRef size, ::std::optional generator=::std::nullopt, at::TensorOptions options={}); +TORCH_API at::Tensor normal(double mean, double std, at::IntArrayRef size, ::std::optional generator, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory); +TORCH_API at::Tensor normal_symint(double mean, double std, c10::SymIntArrayRef size, ::std::optional generator=::std::nullopt, at::TensorOptions options={}); +TORCH_API at::Tensor normal_symint(double mean, double std, c10::SymIntArrayRef size, ::std::optional generator, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory); +TORCH_API at::Tensor & normal_out(at::Tensor & out, double mean, double std, at::IntArrayRef size, ::std::optional generator=::std::nullopt); +TORCH_API at::Tensor & normal_outf(double mean, double std, at::IntArrayRef size, ::std::optional generator, at::Tensor & out); +TORCH_API at::Tensor & normal_symint_out(at::Tensor & out, double mean, double std, c10::SymIntArrayRef size, ::std::optional generator=::std::nullopt); +TORCH_API at::Tensor & normal_symint_outf(double mean, double std, c10::SymIntArrayRef size, ::std::optional generator, at::Tensor & out); + +} // namespace compositeexplicitautograd +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/pixel_unshuffle_compositeexplicitautogradnonfunctional_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/pixel_unshuffle_compositeexplicitautogradnonfunctional_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..afa8e142702362de4ef26a8c0484561a20ea2ade --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/pixel_unshuffle_compositeexplicitautogradnonfunctional_dispatch.h @@ -0,0 +1,23 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautogradnonfunctional { + +TORCH_API at::Tensor pixel_unshuffle(const at::Tensor & self, int64_t downscale_factor); + +} // namespace compositeexplicitautogradnonfunctional +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/prod_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/prod_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..61d170c1db469d9ac1bfa5f68ca24b32b1f7303e --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/prod_cuda_dispatch.h @@ -0,0 +1,26 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor prod(const at::Tensor & self, ::std::optional dtype=::std::nullopt); +TORCH_API at::Tensor prod(const at::Tensor & self, int64_t dim, bool keepdim=false, ::std::optional dtype=::std::nullopt); +TORCH_API at::Tensor & prod_out(at::Tensor & out, const at::Tensor & self, int64_t dim, bool keepdim=false, ::std::optional dtype=::std::nullopt); +TORCH_API at::Tensor & prod_outf(const at::Tensor & self, int64_t dim, bool keepdim, ::std::optional dtype, at::Tensor & out); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/randint_like.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/randint_like.h new file mode 100644 index 0000000000000000000000000000000000000000..aff8d4d7eccc701ef60b25a80562e638ce070c03 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/randint_like.h @@ -0,0 +1,201 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::randint_like(Tensor self, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like(const at::Tensor & self, int64_t high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like::call(self, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, int64_t high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like::call(self, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); + } +} + +// aten::randint_like(Tensor self, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like(const at::Tensor & self, int64_t high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like::call(self, high, dtype, layout, device, pin_memory, memory_format); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, int64_t high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like::call(self, high, dtype, layout, device, pin_memory, memory_format); + } +} + +// aten::randint_like(Tensor self, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like_symint(const at::Tensor & self, c10::SymInt high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like::call(self, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, c10::SymInt high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like::call(self, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); + } +} + +// aten::randint_like(Tensor self, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like_symint(const at::Tensor & self, c10::SymInt high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like::call(self, high, dtype, layout, device, pin_memory, memory_format); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, c10::SymInt high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like::call(self, high, dtype, layout, device, pin_memory, memory_format); + } +} + +// aten::randint_like.low_dtype(Tensor self, SymInt low, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like(const at::Tensor & self, int64_t low, int64_t high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype::call(self, low, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, int64_t low, int64_t high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype::call(self, low, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); + } +} + +// aten::randint_like.low_dtype(Tensor self, SymInt low, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like(const at::Tensor & self, int64_t low, int64_t high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like_low_dtype::call(self, low, high, dtype, layout, device, pin_memory, memory_format); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, int64_t low, int64_t high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like_low_dtype::call(self, low, high, dtype, layout, device, pin_memory, memory_format); + } +} + +// aten::randint_like.low_dtype(Tensor self, SymInt low, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like_symint(const at::Tensor & self, c10::SymInt low, c10::SymInt high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype::call(self, low, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, c10::SymInt low, c10::SymInt high, at::TensorOptions options={}, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype::call(self, low, high, c10::optTypeMetaToScalarType(options.dtype_opt()), options.layout_opt(), options.device_opt(), options.pinned_memory_opt(), c10::impl::check_tensor_options_and_extract_memory_format(options, memory_format)); + } +} + +// aten::randint_like.low_dtype(Tensor self, SymInt low, SymInt high, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None, MemoryFormat? memory_format=None) -> Tensor +inline at::Tensor randint_like_symint(const at::Tensor & self, c10::SymInt low, c10::SymInt high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like_low_dtype::call(self, low, high, dtype, layout, device, pin_memory, memory_format); +} +namespace symint { + template ::value>> + at::Tensor randint_like(const at::Tensor & self, c10::SymInt low, c10::SymInt high, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory, ::std::optional memory_format) { + return at::_ops::randint_like_low_dtype::call(self, low, high, dtype, layout, device, pin_memory, memory_format); + } +} + +// aten::randint_like.out(Tensor self, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_out(at::Tensor & out, const at::Tensor & self, int64_t high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_out(at::Tensor & out, const at::Tensor & self, int64_t high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); + } +} + +// aten::randint_like.out(Tensor self, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_outf(const at::Tensor & self, int64_t high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_outf(const at::Tensor & self, int64_t high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); + } +} + +// aten::randint_like.out(Tensor self, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymInt high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_out(at::Tensor & out, const at::Tensor & self, c10::SymInt high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); + } +} + +// aten::randint_like.out(Tensor self, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_symint_outf(const at::Tensor & self, c10::SymInt high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_outf(const at::Tensor & self, c10::SymInt high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_out::call(self, high, memory_format, out); + } +} + +// aten::randint_like.low_dtype_out(Tensor self, SymInt low, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_out(at::Tensor & out, const at::Tensor & self, int64_t low, int64_t high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_out(at::Tensor & out, const at::Tensor & self, int64_t low, int64_t high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); + } +} + +// aten::randint_like.low_dtype_out(Tensor self, SymInt low, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_outf(const at::Tensor & self, int64_t low, int64_t high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_outf(const at::Tensor & self, int64_t low, int64_t high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); + } +} + +// aten::randint_like.low_dtype_out(Tensor self, SymInt low, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymInt low, c10::SymInt high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_out(at::Tensor & out, const at::Tensor & self, c10::SymInt low, c10::SymInt high, ::std::optional memory_format=::std::nullopt) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); + } +} + +// aten::randint_like.low_dtype_out(Tensor self, SymInt low, SymInt high, *, MemoryFormat? memory_format=None, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & randint_like_symint_outf(const at::Tensor & self, c10::SymInt low, c10::SymInt high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); +} +namespace symint { + template ::value>> + at::Tensor & randint_like_outf(const at::Tensor & self, c10::SymInt low, c10::SymInt high, ::std::optional memory_format, at::Tensor & out) { + return at::_ops::randint_like_low_dtype_out::call(self, low, high, memory_format, out); + } +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/rrelu_with_noise.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/rrelu_with_noise.h new file mode 100644 index 0000000000000000000000000000000000000000..dd1e359688a71e34866e41d5d10cf677fc5ea54d --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/rrelu_with_noise.h @@ -0,0 +1,44 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::rrelu_with_noise.out(Tensor self, Tensor noise, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & rrelu_with_noise_out(at::Tensor & out, const at::Tensor & self, const at::Tensor & noise, const at::Scalar & lower=0.125, const at::Scalar & upper=0.3333333333333333, bool training=false, ::std::optional generator=::std::nullopt) { + return at::_ops::rrelu_with_noise_out::call(self, noise, lower, upper, training, generator, out); +} +// aten::rrelu_with_noise.out(Tensor self, Tensor noise, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & rrelu_with_noise_outf(const at::Tensor & self, const at::Tensor & noise, const at::Scalar & lower, const at::Scalar & upper, bool training, ::std::optional generator, at::Tensor & out) { + return at::_ops::rrelu_with_noise_out::call(self, noise, lower, upper, training, generator, out); +} + +// aten::rrelu_with_noise(Tensor self, Tensor noise, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None) -> Tensor +inline at::Tensor rrelu_with_noise(const at::Tensor & self, const at::Tensor & noise, const at::Scalar & lower=0.125, const at::Scalar & upper=0.3333333333333333, bool training=false, ::std::optional generator=::std::nullopt) { + return at::_ops::rrelu_with_noise::call(self, noise, lower, upper, training, generator); +} + +// aten::rrelu_with_noise_(Tensor(a!) self, Tensor noise, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None) -> Tensor(a!) +inline at::Tensor & rrelu_with_noise_(at::Tensor & self, const at::Tensor & noise, const at::Scalar & lower=0.125, const at::Scalar & upper=0.3333333333333333, bool training=false, ::std::optional generator=::std::nullopt) { + return at::_ops::rrelu_with_noise_::call(self, noise, lower, upper, training, generator); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/rsqrt_cuda_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/rsqrt_cuda_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..ae9c9959cb2ba8db74000c2bb08d145b7f766724 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/rsqrt_cuda_dispatch.h @@ -0,0 +1,26 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cuda { + +TORCH_API at::Tensor rsqrt(const at::Tensor & self); +TORCH_API at::Tensor & rsqrt_out(at::Tensor & out, const at::Tensor & self); +TORCH_API at::Tensor & rsqrt_outf(const at::Tensor & self, at::Tensor & out); +TORCH_API at::Tensor & rsqrt_(at::Tensor & self); + +} // namespace cuda +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/softplus_meta_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/softplus_meta_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..ad4380868908401b3764570aefeb27d1bf7e8cee --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/softplus_meta_dispatch.h @@ -0,0 +1,25 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace meta { + +TORCH_API at::Tensor softplus(const at::Tensor & self, const at::Scalar & beta=1, const at::Scalar & threshold=20); +TORCH_API at::Tensor & softplus_out(at::Tensor & out, const at::Tensor & self, const at::Scalar & beta=1, const at::Scalar & threshold=20); +TORCH_API at::Tensor & softplus_outf(const at::Tensor & self, const at::Scalar & beta, const at::Scalar & threshold, at::Tensor & out); + +} // namespace meta +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/softshrink_backward_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/softshrink_backward_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..72baaa7c7470f189b3dbf0fc731771d31991da1e --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/softshrink_backward_ops.h @@ -0,0 +1,39 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API softshrink_backward_grad_input { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, const at::Scalar &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::softshrink_backward") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "grad_input") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "softshrink_backward.grad_input(Tensor grad_output, Tensor self, Scalar lambd, *, Tensor(a!) grad_input) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & lambd, at::Tensor & grad_input); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & lambd, at::Tensor & grad_input); +}; + +struct TORCH_API softshrink_backward { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::softshrink_backward") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "softshrink_backward(Tensor grad_output, Tensor self, Scalar lambd) -> Tensor") + static at::Tensor call(const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & lambd); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & grad_output, const at::Tensor & self, const at::Scalar & lambd); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sort.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sort.h new file mode 100644 index 0000000000000000000000000000000000000000..07334a94f5365f2c7a1dc7c228a47fdee664ae8e --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sort.h @@ -0,0 +1,81 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +// aten::sort.values(Tensor self, int dim=-1, bool descending=False, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_out(at::Tensor & values, at::Tensor & indices, const at::Tensor & self, int64_t dim=-1, bool descending=false) { + return at::_ops::sort_values::call(self, dim, descending, values, indices); +} +// aten::sort.values(Tensor self, int dim=-1, bool descending=False, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_outf(const at::Tensor & self, int64_t dim, bool descending, at::Tensor & values, at::Tensor & indices) { + return at::_ops::sort_values::call(self, dim, descending, values, indices); +} + +// aten::sort.values_stable(Tensor self, *, bool? stable, int dim=-1, bool descending=False, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_out(at::Tensor & values, at::Tensor & indices, const at::Tensor & self, ::std::optional stable, int64_t dim=-1, bool descending=false) { + return at::_ops::sort_values_stable::call(self, stable, dim, descending, values, indices); +} +// aten::sort.values_stable(Tensor self, *, bool? stable, int dim=-1, bool descending=False, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_outf(const at::Tensor & self, ::std::optional stable, int64_t dim, bool descending, at::Tensor & values, at::Tensor & indices) { + return at::_ops::sort_values_stable::call(self, stable, dim, descending, values, indices); +} + +// aten::sort(Tensor self, int dim=-1, bool descending=False) -> (Tensor values, Tensor indices) +inline ::std::tuple sort(const at::Tensor & self, int64_t dim=-1, bool descending=false) { + return at::_ops::sort::call(self, dim, descending); +} + +// aten::sort.stable(Tensor self, *, bool? stable, int dim=-1, bool descending=False) -> (Tensor values, Tensor indices) +inline ::std::tuple sort(const at::Tensor & self, ::std::optional stable, int64_t dim=-1, bool descending=false) { + return at::_ops::sort_stable::call(self, stable, dim, descending); +} + +// aten::sort.dimname_values(Tensor self, Dimname dim, bool descending=False, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_out(at::Tensor & values, at::Tensor & indices, const at::Tensor & self, at::Dimname dim, bool descending=false) { + return at::_ops::sort_dimname_values::call(self, dim, descending, values, indices); +} +// aten::sort.dimname_values(Tensor self, Dimname dim, bool descending=False, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_outf(const at::Tensor & self, at::Dimname dim, bool descending, at::Tensor & values, at::Tensor & indices) { + return at::_ops::sort_dimname_values::call(self, dim, descending, values, indices); +} + +// aten::sort.dimname_values_stable(Tensor self, *, bool? stable, Dimname dim, bool descending=False, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_out(at::Tensor & values, at::Tensor & indices, const at::Tensor & self, ::std::optional stable, at::Dimname dim, bool descending=false) { + return at::_ops::sort_dimname_values_stable::call(self, stable, dim, descending, values, indices); +} +// aten::sort.dimname_values_stable(Tensor self, *, bool? stable, Dimname dim, bool descending=False, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices) +inline ::std::tuple sort_outf(const at::Tensor & self, ::std::optional stable, at::Dimname dim, bool descending, at::Tensor & values, at::Tensor & indices) { + return at::_ops::sort_dimname_values_stable::call(self, stable, dim, descending, values, indices); +} + +// aten::sort.dimname(Tensor self, Dimname dim, bool descending=False) -> (Tensor values, Tensor indices) +inline ::std::tuple sort(const at::Tensor & self, at::Dimname dim, bool descending=false) { + return at::_ops::sort_dimname::call(self, dim, descending); +} + +// aten::sort.dimname_stable(Tensor self, *, bool? stable, Dimname dim, bool descending=False) -> (Tensor values, Tensor indices) +inline ::std::tuple sort(const at::Tensor & self, ::std::optional stable, at::Dimname dim, bool descending=false) { + return at::_ops::sort_dimname_stable::call(self, stable, dim, descending); +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sparse_sampled_addmm_native.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sparse_sampled_addmm_native.h new file mode 100644 index 0000000000000000000000000000000000000000..4dedea44099006ead54ec06347ad0d70b3132701 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sparse_sampled_addmm_native.h @@ -0,0 +1,24 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace at { +namespace native { +TORCH_API at::Tensor sparse_sampled_addmm_sparse_csr_cpu(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta=1, const at::Scalar & alpha=1); +TORCH_API at::Tensor & sparse_sampled_addmm_out_sparse_csr_cpu(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta, const at::Scalar & alpha, at::Tensor & out); +TORCH_API at::Tensor sparse_sampled_addmm_sparse_csr_cuda(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta=1, const at::Scalar & alpha=1); +TORCH_API at::Tensor & sparse_sampled_addmm_out_sparse_csr_cuda(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta, const at::Scalar & alpha, at::Tensor & out); +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_chebyshev_polynomial_v_meta.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_chebyshev_polynomial_v_meta.h new file mode 100644 index 0000000000000000000000000000000000000000..cd57d81c6ab0aaef3105a006cfb8d6ddf35c8ecd --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_chebyshev_polynomial_v_meta.h @@ -0,0 +1,27 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeMetaFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace at { +namespace meta { + +struct TORCH_API structured_special_chebyshev_polynomial_v : public TensorIteratorBase { + + + void meta(const at::Tensor & x, const at::Tensor & n); +}; + +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_laguerre_polynomial_l_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_laguerre_polynomial_l_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..ceb9c2c5004cc337de0e7069e325fd01263842b1 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_laguerre_polynomial_l_ops.h @@ -0,0 +1,83 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API special_laguerre_polynomial_l { + using schema = at::Tensor (const at::Tensor &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_laguerre_polynomial_l") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_laguerre_polynomial_l(Tensor x, Tensor n) -> Tensor") + static at::Tensor call(const at::Tensor & x, const at::Tensor & n); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & x, const at::Tensor & n); +}; + +struct TORCH_API special_laguerre_polynomial_l_x_scalar { + using schema = at::Tensor (const at::Scalar &, const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_laguerre_polynomial_l") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "x_scalar") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_laguerre_polynomial_l.x_scalar(Scalar x, Tensor n) -> Tensor") + static at::Tensor call(const at::Scalar & x, const at::Tensor & n); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Scalar & x, const at::Tensor & n); +}; + +struct TORCH_API special_laguerre_polynomial_l_n_scalar { + using schema = at::Tensor (const at::Tensor &, const at::Scalar &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_laguerre_polynomial_l") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "n_scalar") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_laguerre_polynomial_l.n_scalar(Tensor x, Scalar n) -> Tensor") + static at::Tensor call(const at::Tensor & x, const at::Scalar & n); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & x, const at::Scalar & n); +}; + +struct TORCH_API special_laguerre_polynomial_l_out { + using schema = at::Tensor & (const at::Tensor &, const at::Tensor &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_laguerre_polynomial_l") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_laguerre_polynomial_l.out(Tensor x, Tensor n, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & x, const at::Tensor & n, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & x, const at::Tensor & n, at::Tensor & out); +}; + +struct TORCH_API special_laguerre_polynomial_l_x_scalar_out { + using schema = at::Tensor & (const at::Scalar &, const at::Tensor &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_laguerre_polynomial_l") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "x_scalar_out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_laguerre_polynomial_l.x_scalar_out(Scalar x, Tensor n, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Scalar & x, const at::Tensor & n, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Scalar & x, const at::Tensor & n, at::Tensor & out); +}; + +struct TORCH_API special_laguerre_polynomial_l_n_scalar_out { + using schema = at::Tensor & (const at::Tensor &, const at::Scalar &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_laguerre_polynomial_l") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "n_scalar_out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_laguerre_polynomial_l.n_scalar_out(Tensor x, Scalar n, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & x, const at::Scalar & n, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & x, const at::Scalar & n, at::Tensor & out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_spherical_bessel_j0_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_spherical_bessel_j0_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..7fb626c20d23c09626e04750994bd40d815b4ea2 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/special_spherical_bessel_j0_ops.h @@ -0,0 +1,39 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API special_spherical_bessel_j0 { + using schema = at::Tensor (const at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_spherical_bessel_j0") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_spherical_bessel_j0(Tensor x) -> Tensor") + static at::Tensor call(const at::Tensor & x); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & x); +}; + +struct TORCH_API special_spherical_bessel_j0_out { + using schema = at::Tensor & (const at::Tensor &, at::Tensor &); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::special_spherical_bessel_j0") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "special_spherical_bessel_j0.out(Tensor x, *, Tensor(a!) out) -> Tensor(a!)") + static at::Tensor & call(const at::Tensor & x, at::Tensor & out); + static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & x, at::Tensor & out); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sub_meta.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sub_meta.h new file mode 100644 index 0000000000000000000000000000000000000000..e6deeff8fc63e8e01cc8c663344a2a5afe72d85c --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sub_meta.h @@ -0,0 +1,27 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeMetaFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace at { +namespace meta { + +struct TORCH_API structured_sub_Tensor : public TensorIteratorBase { + + + void meta(const at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha); +}; + +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sym_size_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sym_size_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..87b98db1bb8b19465105df22d7ceea633b7ee7f8 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/sym_size_ops.h @@ -0,0 +1,28 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API sym_size_int { + using schema = c10::SymInt (const at::Tensor &, int64_t); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::sym_size") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "int") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "sym_size.int(Tensor self, int dim) -> SymInt") + static c10::SymInt call(const at::Tensor & self, int64_t dim); + static c10::SymInt redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, int64_t dim); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/to_padded_tensor.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/to_padded_tensor.h new file mode 100644 index 0000000000000000000000000000000000000000..8a13a556404c76bef352a77f1650f2085e5cbfd6 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/to_padded_tensor.h @@ -0,0 +1,83 @@ +#pragma once + +// @generated by torchgen/gen.py from Function.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include + +namespace at { + + +namespace symint { + template ::value>> + at::Tensor to_padded_tensor(const at::Tensor & self, double padding, at::OptionalIntArrayRef output_size=::std::nullopt) { + return at::_ops::to_padded_tensor::call(self, padding, output_size.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*output_size)) : ::std::nullopt); + } +} + +namespace symint { + template ::value>> + at::Tensor to_padded_tensor(const at::Tensor & self, double padding, at::OptionalSymIntArrayRef output_size=::std::nullopt) { + return at::_ops::to_padded_tensor::call(self, padding, output_size); + } +} + +// aten::to_padded_tensor.out(Tensor self, float padding, SymInt[]? output_size=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & to_padded_tensor_out(at::Tensor & out, const at::Tensor & self, double padding, at::OptionalIntArrayRef output_size=::std::nullopt) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*output_size)) : ::std::nullopt, out); +} +namespace symint { + template ::value>> + at::Tensor & to_padded_tensor_out(at::Tensor & out, const at::Tensor & self, double padding, at::OptionalIntArrayRef output_size=::std::nullopt) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*output_size)) : ::std::nullopt, out); + } +} + +// aten::to_padded_tensor.out(Tensor self, float padding, SymInt[]? output_size=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & to_padded_tensor_outf(const at::Tensor & self, double padding, at::OptionalIntArrayRef output_size, at::Tensor & out) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*output_size)) : ::std::nullopt, out); +} +namespace symint { + template ::value>> + at::Tensor & to_padded_tensor_outf(const at::Tensor & self, double padding, at::OptionalIntArrayRef output_size, at::Tensor & out) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size.has_value() ? ::std::make_optional(c10::fromIntArrayRefSlow(*output_size)) : ::std::nullopt, out); + } +} + +// aten::to_padded_tensor.out(Tensor self, float padding, SymInt[]? output_size=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & to_padded_tensor_symint_out(at::Tensor & out, const at::Tensor & self, double padding, at::OptionalSymIntArrayRef output_size=::std::nullopt) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size, out); +} +namespace symint { + template ::value>> + at::Tensor & to_padded_tensor_out(at::Tensor & out, const at::Tensor & self, double padding, at::OptionalSymIntArrayRef output_size=::std::nullopt) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size, out); + } +} + +// aten::to_padded_tensor.out(Tensor self, float padding, SymInt[]? output_size=None, *, Tensor(a!) out) -> Tensor(a!) +inline at::Tensor & to_padded_tensor_symint_outf(const at::Tensor & self, double padding, at::OptionalSymIntArrayRef output_size, at::Tensor & out) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size, out); +} +namespace symint { + template ::value>> + at::Tensor & to_padded_tensor_outf(const at::Tensor & self, double padding, at::OptionalSymIntArrayRef output_size, at::Tensor & out) { + return at::_ops::to_padded_tensor_out::call(self, padding, output_size, out); + } +} + +} diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/to_sparse_bsc_ops.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/to_sparse_bsc_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..1fb511082e270571890c98667781ffac85d3e4d1 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/to_sparse_bsc_ops.h @@ -0,0 +1,28 @@ +#pragma once + +// @generated by torchgen/gen.py from Operator.h + +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { +namespace _ops { + + +struct TORCH_API to_sparse_bsc { + using schema = at::Tensor (const at::Tensor &, at::IntArrayRef, ::std::optional); + using ptr_schema = schema*; + // See Note [static constexpr char* members for windows NVCC] + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::to_sparse_bsc") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "") + STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "to_sparse_bsc(Tensor self, int[2] blocksize, int? dense_dim=None) -> Tensor") + static at::Tensor call(const at::Tensor & self, at::IntArrayRef blocksize, ::std::optional dense_dim); + static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, at::IntArrayRef blocksize, ::std::optional dense_dim); +}; + +}} // namespace at::_ops diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/trace_backward_native.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/trace_backward_native.h new file mode 100644 index 0000000000000000000000000000000000000000..fb8066ac50c9c6ee8d2282caf1c8502259e1a29a --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/trace_backward_native.h @@ -0,0 +1,21 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace at { +namespace native { +TORCH_API at::Tensor trace_backward_symint(const at::Tensor & grad, c10::SymIntArrayRef sizes); +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/triu_indices_compositeexplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/triu_indices_compositeexplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..4f8b922fd1a2d4b97b8322328461c2b5dd528dcc --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/triu_indices_compositeexplicitautograd_dispatch.h @@ -0,0 +1,24 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautograd { + +TORCH_API at::Tensor & triu_indices_out(at::Tensor & out, int64_t row, int64_t col, int64_t offset=0); +TORCH_API at::Tensor & triu_indices_outf(int64_t row, int64_t col, int64_t offset, at::Tensor & out); + +} // namespace compositeexplicitautograd +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/triu_indices_cpu_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/triu_indices_cpu_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..aedc8efc7e51b841a7ed0630efd72e353da1e0e4 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/triu_indices_cpu_dispatch.h @@ -0,0 +1,24 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace cpu { + +TORCH_API at::Tensor triu_indices(int64_t row, int64_t col, int64_t offset=0, at::TensorOptions options=at::kLong); +TORCH_API at::Tensor triu_indices(int64_t row, int64_t col, int64_t offset, ::std::optional dtype, ::std::optional layout, ::std::optional device, ::std::optional pin_memory); + +} // namespace cpu +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/unique_dim_native.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/unique_dim_native.h new file mode 100644 index 0000000000000000000000000000000000000000..6a2391f1d6d820792bad0f2f1f9915667c017645 --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/unique_dim_native.h @@ -0,0 +1,23 @@ +#pragma once + +// @generated by torchgen/gen.py from NativeFunction.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace at { +namespace native { +TORCH_API ::std::tuple unique_dim_out(const at::Tensor & self, int64_t dim, bool sorted, bool return_inverse, bool return_counts, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2); +TORCH_API ::std::tuple unique_dim_cpu(const at::Tensor & self, int64_t dim, bool sorted=true, bool return_inverse=false, bool return_counts=false); +TORCH_API ::std::tuple unique_dim_cuda(const at::Tensor & self, int64_t dim, bool sorted=true, bool return_inverse=false, bool return_counts=false); +} // namespace native +} // namespace at diff --git a/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/var_mean_compositeexplicitautograd_dispatch.h b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/var_mean_compositeexplicitautograd_dispatch.h new file mode 100644 index 0000000000000000000000000000000000000000..70971e8c8d4c8a2782c4cbcad23167dc49c9edfb --- /dev/null +++ b/pllava/lib/python3.10/site-packages/torch/include/ATen/ops/var_mean_compositeexplicitautograd_dispatch.h @@ -0,0 +1,24 @@ +#pragma once +// @generated by torchgen/gen.py from DispatchKeyFunction.h + +// NB: The implementing C++ file is RegisterDispatchKey.cpp + +// The only #includes we need are for custom classes that have defaults in the C++ API +#include +#include +#include + +// Forward declarations of any types needed in the operator signatures. +// We can't directly include these classes because it will cause circular include dependencies. +// This file is included by TensorBody.h, which defines the Tensor class. +#include + +namespace at { + +namespace compositeexplicitautograd { + +TORCH_API ::std::tuple var_mean_out(at::Tensor & out0, at::Tensor & out1, const at::Tensor & self, at::OptionalIntArrayRef dim=::std::nullopt, const ::std::optional & correction=::std::nullopt, bool keepdim=false); +TORCH_API ::std::tuple var_mean_outf(const at::Tensor & self, at::OptionalIntArrayRef dim, const ::std::optional & correction, bool keepdim, at::Tensor & out0, at::Tensor & out1); + +} // namespace compositeexplicitautograd +} // namespace at