1#pragma once
2
3#include <torch/csrc/python_headers.h>
4#include <torch/csrc/utils/python_arg_parser.h>
5
6#include <ATen/core/Tensor.h>
7
8namespace torch {
9namespace utils {
10
11at::Tensor base_tensor_ctor(PyObject* args, PyObject* kwargs);
12at::Tensor legacy_tensor_ctor(
13 c10::DispatchKey dispatch_key,
14 at::ScalarType scalar_type,
15 PyObject* args,
16 PyObject* kwargs);
17at::Tensor legacy_tensor_new(
18 c10::DispatchKey dispatch_key,
19 at::ScalarType scalar_type,
20 PyObject* args,
21 PyObject* kwargs);
22at::Tensor indexing_tensor_from_data(
23 c10::TensorOptions options,
24 at::ScalarType scalar_type,
25 c10::optional<at::Device> device,
26 PyObject* data);
27at::Tensor sparse_coo_tensor_ctor(
28 c10::DispatchKey dispatch_key,
29 at::ScalarType scalar_type,
30 PythonArgs& r);
31void _validate_sparse_coo_tensor_args(
32 c10::DispatchKey dispatch_key,
33 at::ScalarType scalar_type,
34 PyObject* args,
35 PyObject* kwargs);
36
37at::Tensor sparse_compressed_tensor_ctor(
38 c10::DispatchKey dispatch_key,
39 at::ScalarType scalar_type,
40 PythonArgs& r);
41at::Tensor sparse_csr_tensor_ctor(
42 c10::DispatchKey dispatch_key,
43 at::ScalarType scalar_type,
44 PythonArgs& r);
45at::Tensor sparse_csc_tensor_ctor(
46 c10::DispatchKey dispatch_key,
47 at::ScalarType scalar_type,
48 PythonArgs& r);
49at::Tensor sparse_bsr_tensor_ctor(
50 c10::DispatchKey dispatch_key,
51 at::ScalarType scalar_type,
52 PythonArgs& r);
53at::Tensor sparse_bsc_tensor_ctor(
54 c10::DispatchKey dispatch_key,
55 at::ScalarType scalar_type,
56 PythonArgs& r);
57
58void _validate_sparse_compressed_tensor_args(
59 c10::DispatchKey dispatch_key,
60 at::ScalarType scalar_type,
61 PyObject* args,
62 PyObject* kwargs);
63void _validate_sparse_csr_tensor_args(
64 c10::DispatchKey dispatch_key,
65 at::ScalarType scalar_type,
66 PyObject* args,
67 PyObject* kwargs);
68void _validate_sparse_csc_tensor_args(
69 c10::DispatchKey dispatch_key,
70 at::ScalarType scalar_type,
71 PyObject* args,
72 PyObject* kwargs);
73void _validate_sparse_bsr_tensor_args(
74 c10::DispatchKey dispatch_key,
75 at::ScalarType scalar_type,
76 PyObject* args,
77 PyObject* kwargs);
78void _validate_sparse_bsc_tensor_args(
79 c10::DispatchKey dispatch_key,
80 at::ScalarType scalar_type,
81 PyObject* args,
82 PyObject* kwargs);
83
84at::Tensor tensor_ctor(
85 c10::DispatchKey dispatch_key,
86 at::ScalarType scalar_type,
87 PythonArgs& r);
88at::Tensor as_tensor(
89 c10::DispatchKey dispatch_key,
90 at::ScalarType scalar_type,
91 PythonArgs& r);
92at::Tensor new_tensor(
93 c10::DispatchKey dispatch_key,
94 at::ScalarType scalar_type,
95 PyObject* args,
96 PyObject* kwargs);
97at::Tensor new_ones(
98 c10::DispatchKey dispatch_key,
99 at::ScalarType scalar_type,
100 PyObject* args,
101 PyObject* kwargs);
102at::Tensor tensor_frombuffer(
103 PyObject* buffer,
104 at::ScalarType dtype,
105 int64_t count,
106 int64_t offset,
107 bool requires_grad);
108at::Tensor tensor_fromDLPack(PyObject* data);
109at::Tensor asarray(
110 PyObject* obj,
111 c10::optional<c10::ScalarType> dtype,
112 c10::optional<c10::Device> device,
113 c10::optional<bool> copy,
114 bool requires_grad);
115} // namespace utils
116} // namespace torch
117