Caffe2 - C++ API
A deep learning, cross platform ML framework
TensorMethods.h
1 #pragma once
2 
3 #include <ATen/core/Tensor.h>
4 #include <c10/core/Scalar.h>
5 #include <c10/macros/Macros.h>
6 #include <ATen/core/SparseTensorRef.h>
7 #include <ATen/core/Type.h>
8 #include <c10/core/TensorOptions.h>
9 
10 namespace at {
11 
12 inline Tensor Tensor::toType(const Type & t, bool non_blocking) const {
13  if(type() == t)
14  return *this;
15  return t.copy(*this, non_blocking);
16 }
17 
18 inline Tensor Tensor::cpu() const {
19  return toType(type().cpu());
20 }
21 
22 inline Tensor Tensor::cuda() const {
23  return toType(type().cuda());
24 }
25 
26 inline Tensor Tensor::hip() const {
27  return toType(type().hip());
28 }
29 
30 inline Tensor & Tensor::copy_(const Tensor & src, bool non_blocking) {
31  return type().copy_(*this, src, non_blocking);
32 }
33 
34 inline Tensor Tensor::toType(ScalarType t) const {
35  return toType(type().toScalarType(t));
36 }
37 
38 inline Tensor Tensor::toBackend(Backend b) const {
39  return toType(type().toBackend(b));
40 }
41 
43  return TensorOptions().dtype(dtype())
44  .device(device())
45  .layout(layout())
47 }
48 
49 inline void Tensor::backward(
50  c10::optional<Tensor> gradient,
51  bool keep_graph,
52  bool create_graph) {
53  type().backward(*this, std::move(gradient), keep_graph, create_graph);
54 }
55 
56 inline void Tensor::set_data(Tensor new_data) {
57  type().set_data(*this, new_data);
58 }
59 
60 // all static inline to allow for inlining of the non-dynamic part of dispatch
61 inline Tensor Tensor::abs() const {
62  return type().abs(*this);
63 }
64 inline Tensor & Tensor::abs_() {
65  return type().abs_(*this);
66 }
67 inline Tensor Tensor::acos() const {
68  return type().acos(*this);
69 }
70 inline Tensor & Tensor::acos_() {
71  return type().acos_(*this);
72 }
73 inline Tensor Tensor::add(const Tensor & other, Scalar alpha) const {
74  return type().add(*this, other, alpha);
75 }
76 inline Tensor & Tensor::add_(const Tensor & other, Scalar alpha) {
77  return type().add_(*this, other, alpha);
78 }
79 inline Tensor Tensor::add(Scalar other, Scalar alpha) const {
80  return type().add(*this, other, alpha);
81 }
82 inline Tensor & Tensor::add_(Scalar other, Scalar alpha) {
83  return type().add_(*this, other, alpha);
84 }
85 inline Tensor Tensor::addmv(const Tensor & mat, const Tensor & vec, Scalar beta, Scalar alpha) const {
86  return type().addmv(*this, mat, vec, beta, alpha);
87 }
88 inline Tensor & Tensor::addmv_(const Tensor & mat, const Tensor & vec, Scalar beta, Scalar alpha) {
89  return type().addmv_(*this, mat, vec, beta, alpha);
90 }
91 inline Tensor Tensor::addr(const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) const {
92  return type().addr(*this, vec1, vec2, beta, alpha);
93 }
94 inline Tensor & Tensor::addr_(const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) {
95  return type().addr_(*this, vec1, vec2, beta, alpha);
96 }
97 inline Tensor Tensor::all(int64_t dim, bool keepdim) const {
98  return type().all(*this, dim, keepdim);
99 }
100 inline bool Tensor::allclose(const Tensor & other, double rtol, double atol, bool equal_nan) const {
101  return type().allclose(*this, other, rtol, atol, equal_nan);
102 }
103 inline Tensor Tensor::any(int64_t dim, bool keepdim) const {
104  return type().any(*this, dim, keepdim);
105 }
106 inline Tensor Tensor::argmax(c10::optional<int64_t> dim, bool keepdim) const {
107  return type().argmax(*this, dim, keepdim);
108 }
109 inline Tensor Tensor::argmin(c10::optional<int64_t> dim, bool keepdim) const {
110  return type().argmin(*this, dim, keepdim);
111 }
112 inline Tensor Tensor::as_strided(IntArrayRef size, IntArrayRef stride, c10::optional<int64_t> storage_offset) const {
113  return type().as_strided(*this, size, stride, storage_offset);
114 }
115 inline Tensor & Tensor::as_strided_(IntArrayRef size, IntArrayRef stride, c10::optional<int64_t> storage_offset) {
116  return type().as_strided_(*this, size, stride, storage_offset);
117 }
118 inline Tensor Tensor::asin() const {
119  return type().asin(*this);
120 }
121 inline Tensor & Tensor::asin_() {
122  return type().asin_(*this);
123 }
124 inline Tensor Tensor::atan() const {
125  return type().atan(*this);
126 }
127 inline Tensor & Tensor::atan_() {
128  return type().atan_(*this);
129 }
130 inline Tensor Tensor::baddbmm(const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) const {
131  return type().baddbmm(*this, batch1, batch2, beta, alpha);
132 }
133 inline Tensor & Tensor::baddbmm_(const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) {
134  return type().baddbmm_(*this, batch1, batch2, beta, alpha);
135 }
136 inline Tensor Tensor::bernoulli(Generator * generator) const {
137  return type().bernoulli(*this, generator);
138 }
139 inline Tensor & Tensor::bernoulli_(const Tensor & p, Generator * generator) {
140  return type().bernoulli_(*this, p, generator);
141 }
142 inline Tensor & Tensor::bernoulli_(double p, Generator * generator) {
143  return type().bernoulli_(*this, p, generator);
144 }
145 inline Tensor Tensor::bernoulli(double p, Generator * generator) const {
146  return type().bernoulli(*this, p, generator);
147 }
148 inline Tensor Tensor::bincount(const Tensor & weights, int64_t minlength) const {
149  return type().bincount(*this, weights, minlength);
150 }
151 inline Tensor Tensor::bmm(const Tensor & mat2) const {
152  return type().bmm(*this, mat2);
153 }
154 inline Tensor Tensor::ceil() const {
155  return type().ceil(*this);
156 }
157 inline Tensor & Tensor::ceil_() {
158  return type().ceil_(*this);
159 }
160 inline std::vector<Tensor> Tensor::chunk(int64_t chunks, int64_t dim) const {
161  return type().chunk(*this, chunks, dim);
162 }
163 inline Tensor Tensor::clamp(c10::optional<Scalar> min, c10::optional<Scalar> max) const {
164  return type().clamp(*this, min, max);
165 }
166 inline Tensor & Tensor::clamp_(c10::optional<Scalar> min, c10::optional<Scalar> max) {
167  return type().clamp_(*this, min, max);
168 }
169 inline Tensor Tensor::clamp_max(Scalar max) const {
170  return type().clamp_max(*this, max);
171 }
172 inline Tensor & Tensor::clamp_max_(Scalar max) {
173  return type().clamp_max_(*this, max);
174 }
175 inline Tensor Tensor::clamp_min(Scalar min) const {
176  return type().clamp_min(*this, min);
177 }
178 inline Tensor & Tensor::clamp_min_(Scalar min) {
179  return type().clamp_min_(*this, min);
180 }
181 inline Tensor Tensor::contiguous() const {
182  return type().contiguous(*this);
183 }
184 inline Tensor Tensor::cos() const {
185  return type().cos(*this);
186 }
187 inline Tensor & Tensor::cos_() {
188  return type().cos_(*this);
189 }
190 inline Tensor Tensor::cosh() const {
191  return type().cosh(*this);
192 }
193 inline Tensor & Tensor::cosh_() {
194  return type().cosh_(*this);
195 }
196 inline Tensor Tensor::cumsum(int64_t dim, ScalarType dtype) const {
197  return type().cumsum(*this, dim, dtype);
198 }
199 inline Tensor Tensor::cumsum(int64_t dim) const {
200  return type().cumsum(*this, dim);
201 }
202 inline Tensor Tensor::cumprod(int64_t dim, ScalarType dtype) const {
203  return type().cumprod(*this, dim, dtype);
204 }
205 inline Tensor Tensor::cumprod(int64_t dim) const {
206  return type().cumprod(*this, dim);
207 }
208 inline Tensor Tensor::det() const {
209  return type().det(*this);
210 }
211 inline Tensor Tensor::diag_embed(int64_t offset, int64_t dim1, int64_t dim2) const {
212  return type().diag_embed(*this, offset, dim1, dim2);
213 }
214 inline Tensor Tensor::diagflat(int64_t offset) const {
215  return type().diagflat(*this, offset);
216 }
217 inline Tensor Tensor::diagonal(int64_t offset, int64_t dim1, int64_t dim2) const {
218  return type().diagonal(*this, offset, dim1, dim2);
219 }
220 inline Tensor Tensor::div(const Tensor & other) const {
221  return type().div(*this, other);
222 }
223 inline Tensor & Tensor::div_(const Tensor & other) {
224  return type().div_(*this, other);
225 }
226 inline Tensor Tensor::div(Scalar other) const {
227  return type().div(*this, other);
228 }
229 inline Tensor & Tensor::div_(Scalar other) {
230  return type().div_(*this, other);
231 }
232 inline Tensor Tensor::dot(const Tensor & tensor) const {
233  return type().dot(*this, tensor);
234 }
235 inline Tensor & Tensor::resize_(IntArrayRef size) {
236  return type().resize_(*this, size);
237 }
238 inline Tensor Tensor::erf() const {
239  return type().erf(*this);
240 }
241 inline Tensor & Tensor::erf_() {
242  return type().erf_(*this);
243 }
244 inline Tensor Tensor::erfc() const {
245  return type().erfc(*this);
246 }
247 inline Tensor & Tensor::erfc_() {
248  return type().erfc_(*this);
249 }
250 inline Tensor Tensor::exp() const {
251  return type().exp(*this);
252 }
253 inline Tensor & Tensor::exp_() {
254  return type().exp_(*this);
255 }
256 inline Tensor Tensor::expm1() const {
257  return type().expm1(*this);
258 }
259 inline Tensor & Tensor::expm1_() {
260  return type().expm1_(*this);
261 }
262 inline Tensor Tensor::expand(IntArrayRef size, bool implicit) const {
263  return type().expand(*this, size, implicit);
264 }
265 inline Tensor Tensor::expand_as(const Tensor & other) const {
266  return type().expand_as(*this, other);
267 }
268 inline Tensor Tensor::flatten(int64_t start_dim, int64_t end_dim) const {
269  return type().flatten(*this, start_dim, end_dim);
270 }
271 inline Tensor & Tensor::fill_(Scalar value) {
272  return type().fill_(*this, value);
273 }
274 inline Tensor & Tensor::fill_(const Tensor & value) {
275  return type().fill_(*this, value);
276 }
277 inline Tensor Tensor::floor() const {
278  return type().floor(*this);
279 }
280 inline Tensor & Tensor::floor_() {
281  return type().floor_(*this);
282 }
283 inline Tensor Tensor::ger(const Tensor & vec2) const {
284  return type().ger(*this, vec2);
285 }
286 inline Tensor Tensor::fft(int64_t signal_ndim, bool normalized) const {
287  return type().fft(*this, signal_ndim, normalized);
288 }
289 inline Tensor Tensor::ifft(int64_t signal_ndim, bool normalized) const {
290  return type().ifft(*this, signal_ndim, normalized);
291 }
292 inline Tensor Tensor::rfft(int64_t signal_ndim, bool normalized, bool onesided) const {
293  return type().rfft(*this, signal_ndim, normalized, onesided);
294 }
295 inline Tensor Tensor::irfft(int64_t signal_ndim, bool normalized, bool onesided, IntArrayRef signal_sizes) const {
296  return type().irfft(*this, signal_ndim, normalized, onesided, signal_sizes);
297 }
298 inline Tensor Tensor::index(TensorList indices) const {
299  return type().index(*this, indices);
300 }
301 inline Tensor & Tensor::index_copy_(int64_t dim, const Tensor & index, const Tensor & source) {
302  return type().index_copy_(*this, dim, index, source);
303 }
304 inline Tensor Tensor::index_copy(int64_t dim, const Tensor & index, const Tensor & source) const {
305  return type().index_copy(*this, dim, index, source);
306 }
307 inline Tensor & Tensor::index_put_(TensorList indices, const Tensor & values, bool accumulate) {
308  return type().index_put_(*this, indices, values, accumulate);
309 }
310 inline Tensor Tensor::index_put(TensorList indices, const Tensor & values, bool accumulate) const {
311  return type().index_put(*this, indices, values, accumulate);
312 }
313 inline Tensor Tensor::inverse() const {
314  return type().inverse(*this);
315 }
316 inline Tensor Tensor::isclose(const Tensor & other, double rtol, double atol, bool equal_nan) const {
317  return type().isclose(*this, other, rtol, atol, equal_nan);
318 }
319 inline bool Tensor::is_distributed() const {
320  return type().is_distributed(*this);
321 }
322 inline bool Tensor::is_floating_point() const {
323  return type().is_floating_point(*this);
324 }
325 inline bool Tensor::is_complex() const {
326  return type().is_complex(*this);
327 }
328 inline bool Tensor::is_nonzero() const {
329  return type().is_nonzero(*this);
330 }
331 inline bool Tensor::is_same_size(const Tensor & other) const {
332  return type().is_same_size(*this, other);
333 }
334 inline bool Tensor::is_signed() const {
335  return type().is_signed(*this);
336 }
337 inline std::tuple<Tensor,Tensor> Tensor::kthvalue(int64_t k, int64_t dim, bool keepdim) const {
338  return type().kthvalue(*this, k, dim, keepdim);
339 }
340 inline Tensor Tensor::log() const {
341  return type().log(*this);
342 }
343 inline Tensor & Tensor::log_() {
344  return type().log_(*this);
345 }
346 inline Tensor Tensor::log10() const {
347  return type().log10(*this);
348 }
349 inline Tensor & Tensor::log10_() {
350  return type().log10_(*this);
351 }
352 inline Tensor Tensor::log1p() const {
353  return type().log1p(*this);
354 }
355 inline Tensor & Tensor::log1p_() {
356  return type().log1p_(*this);
357 }
358 inline Tensor Tensor::log2() const {
359  return type().log2(*this);
360 }
361 inline Tensor & Tensor::log2_() {
362  return type().log2_(*this);
363 }
364 inline Tensor Tensor::logdet() const {
365  return type().logdet(*this);
366 }
367 inline Tensor Tensor::log_softmax(int64_t dim, ScalarType dtype) const {
368  return type().log_softmax(*this, dim, dtype);
369 }
370 inline Tensor Tensor::log_softmax(int64_t dim) const {
371  return type().log_softmax(*this, dim);
372 }
373 inline Tensor Tensor::logsumexp(IntArrayRef dim, bool keepdim) const {
374  return type().logsumexp(*this, dim, keepdim);
375 }
376 inline Tensor Tensor::matmul(const Tensor & other) const {
377  return type().matmul(*this, other);
378 }
379 inline Tensor Tensor::matrix_power(int64_t n) const {
380  return type().matrix_power(*this, n);
381 }
382 inline std::tuple<Tensor,Tensor> Tensor::max(int64_t dim, bool keepdim) const {
383  return type().max(*this, dim, keepdim);
384 }
385 inline Tensor Tensor::max_values(IntArrayRef dim, bool keepdim) const {
386  return type().max_values(*this, dim, keepdim);
387 }
388 inline Tensor Tensor::mean(ScalarType dtype) const {
389  return type().mean(*this, dtype);
390 }
391 inline Tensor Tensor::mean() const {
392  return type().mean(*this);
393 }
394 inline Tensor Tensor::mean(IntArrayRef dim, bool keepdim, ScalarType dtype) const {
395  return type().mean(*this, dim, keepdim, dtype);
396 }
397 inline Tensor Tensor::mean(IntArrayRef dim, bool keepdim) const {
398  return type().mean(*this, dim, keepdim);
399 }
400 inline Tensor Tensor::mean(IntArrayRef dim, ScalarType dtype) const {
401  return type().mean(*this, dim, dtype);
402 }
403 inline std::tuple<Tensor,Tensor> Tensor::median(int64_t dim, bool keepdim) const {
404  return type().median(*this, dim, keepdim);
405 }
406 inline std::tuple<Tensor,Tensor> Tensor::min(int64_t dim, bool keepdim) const {
407  return type().min(*this, dim, keepdim);
408 }
409 inline Tensor Tensor::min_values(IntArrayRef dim, bool keepdim) const {
410  return type().min_values(*this, dim, keepdim);
411 }
412 inline Tensor Tensor::mm(const Tensor & mat2) const {
413  return type().mm(*this, mat2);
414 }
415 inline std::tuple<Tensor,Tensor> Tensor::mode(int64_t dim, bool keepdim) const {
416  return type().mode(*this, dim, keepdim);
417 }
418 inline Tensor Tensor::mul(const Tensor & other) const {
419  return type().mul(*this, other);
420 }
421 inline Tensor & Tensor::mul_(const Tensor & other) {
422  return type().mul_(*this, other);
423 }
424 inline Tensor Tensor::mul(Scalar other) const {
425  return type().mul(*this, other);
426 }
427 inline Tensor & Tensor::mul_(Scalar other) {
428  return type().mul_(*this, other);
429 }
430 inline Tensor Tensor::mv(const Tensor & vec) const {
431  return type().mv(*this, vec);
432 }
433 inline Tensor Tensor::mvlgamma(int64_t p) const {
434  return type().mvlgamma(*this, p);
435 }
436 inline Tensor & Tensor::mvlgamma_(int64_t p) {
437  return type().mvlgamma_(*this, p);
438 }
439 inline Tensor Tensor::narrow_copy(int64_t dim, int64_t start, int64_t length) const {
440  return type().narrow_copy(*this, dim, start, length);
441 }
442 inline Tensor Tensor::narrow(int64_t dim, int64_t start, int64_t length) const {
443  return type().narrow(*this, dim, start, length);
444 }
445 inline Tensor Tensor::permute(IntArrayRef dims) const {
446  return type().permute(*this, dims);
447 }
448 inline Tensor Tensor::pin_memory() const {
449  return type().pin_memory(*this);
450 }
451 inline Tensor Tensor::pinverse(double rcond) const {
452  return type().pinverse(*this, rcond);
453 }
454 inline Tensor Tensor::repeat(IntArrayRef repeats) const {
455  return type().repeat(*this, repeats);
456 }
457 inline Tensor Tensor::reshape(IntArrayRef shape) const {
458  return type().reshape(*this, shape);
459 }
460 inline Tensor Tensor::reshape_as(const Tensor & other) const {
461  return type().reshape_as(*this, other);
462 }
463 inline Tensor Tensor::round() const {
464  return type().round(*this);
465 }
466 inline Tensor & Tensor::round_() {
467  return type().round_(*this);
468 }
469 inline Tensor Tensor::relu() const {
470  return type().relu(*this);
471 }
472 inline Tensor & Tensor::relu_() {
473  return type().relu_(*this);
474 }
475 inline Tensor Tensor::prelu(const Tensor & weight) const {
476  return type().prelu(*this, weight);
477 }
478 inline std::tuple<Tensor,Tensor> Tensor::prelu_backward(const Tensor & grad_output, const Tensor & weight) const {
479  return type().prelu_backward(grad_output, *this, weight);
480 }
481 inline Tensor Tensor::hardshrink(Scalar lambd) const {
482  return type().hardshrink(*this, lambd);
483 }
484 inline Tensor Tensor::hardshrink_backward(const Tensor & grad_out, Scalar lambd) const {
485  return type().hardshrink_backward(grad_out, *this, lambd);
486 }
487 inline Tensor Tensor::rsqrt() const {
488  return type().rsqrt(*this);
489 }
490 inline Tensor & Tensor::rsqrt_() {
491  return type().rsqrt_(*this);
492 }
493 inline Tensor Tensor::select(int64_t dim, int64_t index) const {
494  return type().select(*this, dim, index);
495 }
496 inline Tensor Tensor::sigmoid() const {
497  return type().sigmoid(*this);
498 }
499 inline Tensor & Tensor::sigmoid_() {
500  return type().sigmoid_(*this);
501 }
502 inline Tensor Tensor::sin() const {
503  return type().sin(*this);
504 }
505 inline Tensor & Tensor::sin_() {
506  return type().sin_(*this);
507 }
508 inline Tensor Tensor::sinh() const {
509  return type().sinh(*this);
510 }
511 inline Tensor & Tensor::sinh_() {
512  return type().sinh_(*this);
513 }
514 inline Tensor Tensor::detach() const {
515  return type().detach(*this);
516 }
517 inline Tensor & Tensor::detach_() {
518  return type().detach_(*this);
519 }
520 inline int64_t Tensor::size(int64_t dim) const {
521  return type().size(*this, dim);
522 }
523 inline Tensor Tensor::slice(int64_t dim, int64_t start, int64_t end, int64_t step) const {
524  return type().slice(*this, dim, start, end, step);
525 }
526 inline std::tuple<Tensor,Tensor> Tensor::slogdet() const {
527  return type().slogdet(*this);
528 }
529 inline Tensor Tensor::smm(const Tensor & mat2) const {
530  return type().smm(*this, mat2);
531 }
532 inline Tensor Tensor::softmax(int64_t dim, ScalarType dtype) const {
533  return type().softmax(*this, dim, dtype);
534 }
535 inline Tensor Tensor::softmax(int64_t dim) const {
536  return type().softmax(*this, dim);
537 }
538 inline std::vector<Tensor> Tensor::split(int64_t split_size, int64_t dim) const {
539  return type().split(*this, split_size, dim);
540 }
541 inline std::vector<Tensor> Tensor::split_with_sizes(IntArrayRef split_sizes, int64_t dim) const {
542  return type().split_with_sizes(*this, split_sizes, dim);
543 }
544 inline Tensor Tensor::squeeze() const {
545  return type().squeeze(*this);
546 }
547 inline Tensor Tensor::squeeze(int64_t dim) const {
548  return type().squeeze(*this, dim);
549 }
550 inline Tensor & Tensor::squeeze_() {
551  return type().squeeze_(*this);
552 }
553 inline Tensor & Tensor::squeeze_(int64_t dim) {
554  return type().squeeze_(*this, dim);
555 }
556 inline Tensor Tensor::sspaddmm(const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) const {
557  return type().sspaddmm(*this, mat1, mat2, beta, alpha);
558 }
559 inline Tensor Tensor::stft(int64_t n_fft, c10::optional<int64_t> hop_length, c10::optional<int64_t> win_length, const Tensor & window, bool normalized, bool onesided) const {
560  return type().stft(*this, n_fft, hop_length, win_length, window, normalized, onesided);
561 }
562 inline int64_t Tensor::stride(int64_t dim) const {
563  return type().stride(*this, dim);
564 }
565 inline Tensor Tensor::sum(ScalarType dtype) const {
566  return type().sum(*this, dtype);
567 }
568 inline Tensor Tensor::sum() const {
569  return type().sum(*this);
570 }
571 inline Tensor Tensor::sum(IntArrayRef dim, bool keepdim, ScalarType dtype) const {
572  return type().sum(*this, dim, keepdim, dtype);
573 }
574 inline Tensor Tensor::sum(IntArrayRef dim, bool keepdim) const {
575  return type().sum(*this, dim, keepdim);
576 }
577 inline Tensor Tensor::sum(IntArrayRef dim, ScalarType dtype) const {
578  return type().sum(*this, dim, dtype);
579 }
580 inline Tensor Tensor::sum_to_size(IntArrayRef size) const {
581  return type().sum_to_size(*this, size);
582 }
583 inline Tensor Tensor::sqrt() const {
584  return type().sqrt(*this);
585 }
586 inline Tensor & Tensor::sqrt_() {
587  return type().sqrt_(*this);
588 }
589 inline Tensor Tensor::std(bool unbiased) const {
590  return type().std(*this, unbiased);
591 }
592 inline Tensor Tensor::std(IntArrayRef dim, bool unbiased, bool keepdim) const {
593  return type().std(*this, dim, unbiased, keepdim);
594 }
595 inline Tensor Tensor::prod(ScalarType dtype) const {
596  return type().prod(*this, dtype);
597 }
598 inline Tensor Tensor::prod() const {
599  return type().prod(*this);
600 }
601 inline Tensor Tensor::prod(int64_t dim, bool keepdim, ScalarType dtype) const {
602  return type().prod(*this, dim, keepdim, dtype);
603 }
604 inline Tensor Tensor::prod(int64_t dim, bool keepdim) const {
605  return type().prod(*this, dim, keepdim);
606 }
607 inline Tensor Tensor::prod(int64_t dim, ScalarType dtype) const {
608  return type().prod(*this, dim, dtype);
609 }
610 inline Tensor Tensor::t() const {
611  return type().t(*this);
612 }
613 inline Tensor & Tensor::t_() {
614  return type().t_(*this);
615 }
616 inline Tensor Tensor::tan() const {
617  return type().tan(*this);
618 }
619 inline Tensor & Tensor::tan_() {
620  return type().tan_(*this);
621 }
622 inline Tensor Tensor::tanh() const {
623  return type().tanh(*this);
624 }
625 inline Tensor & Tensor::tanh_() {
626  return type().tanh_(*this);
627 }
628 inline Tensor Tensor::transpose(int64_t dim0, int64_t dim1) const {
629  return type().transpose(*this, dim0, dim1);
630 }
631 inline Tensor & Tensor::transpose_(int64_t dim0, int64_t dim1) {
632  return type().transpose_(*this, dim0, dim1);
633 }
634 inline Tensor Tensor::flip(IntArrayRef dims) const {
635  return type().flip(*this, dims);
636 }
637 inline Tensor Tensor::roll(IntArrayRef shifts, IntArrayRef dims) const {
638  return type().roll(*this, shifts, dims);
639 }
640 inline Tensor Tensor::rot90(int64_t k, IntArrayRef dims) const {
641  return type().rot90(*this, k, dims);
642 }
643 inline Tensor Tensor::trunc() const {
644  return type().trunc(*this);
645 }
646 inline Tensor & Tensor::trunc_() {
647  return type().trunc_(*this);
648 }
649 inline Tensor Tensor::type_as(const Tensor & other) const {
650  return type().type_as(*this, other);
651 }
652 inline Tensor Tensor::unsqueeze(int64_t dim) const {
653  return type().unsqueeze(*this, dim);
654 }
655 inline Tensor & Tensor::unsqueeze_(int64_t dim) {
656  return type().unsqueeze_(*this, dim);
657 }
658 inline Tensor Tensor::var(bool unbiased) const {
659  return type().var(*this, unbiased);
660 }
661 inline Tensor Tensor::var(IntArrayRef dim, bool unbiased, bool keepdim) const {
662  return type().var(*this, dim, unbiased, keepdim);
663 }
664 inline Tensor Tensor::view_as(const Tensor & other) const {
665  return type().view_as(*this, other);
666 }
667 inline Tensor Tensor::where(const Tensor & condition, const Tensor & other) const {
668  return type().where(condition, *this, other);
669 }
670 inline Tensor Tensor::norm(c10::optional<Scalar> p, ScalarType dtype) const {
671  return type().norm(*this, p, dtype);
672 }
673 inline Tensor Tensor::norm(Scalar p) const {
674  return type().norm(*this, p);
675 }
676 inline Tensor Tensor::norm(c10::optional<Scalar> p, IntArrayRef dim, bool keepdim, ScalarType dtype) const {
677  return type().norm(*this, p, dim, keepdim, dtype);
678 }
679 inline Tensor Tensor::norm(c10::optional<Scalar> p, IntArrayRef dim, bool keepdim) const {
680  return type().norm(*this, p, dim, keepdim);
681 }
682 inline Tensor Tensor::clone() const {
683  return type().clone(*this);
684 }
685 inline Tensor & Tensor::resize_as_(const Tensor & the_template) {
686  return type().resize_as_(*this, the_template);
687 }
688 inline Tensor Tensor::pow(Scalar exponent) const {
689  return type().pow(*this, exponent);
690 }
691 inline Tensor & Tensor::zero_() {
692  return type().zero_(*this);
693 }
694 inline Tensor Tensor::sub(const Tensor & other, Scalar alpha) const {
695  return type().sub(*this, other, alpha);
696 }
697 inline Tensor & Tensor::sub_(const Tensor & other, Scalar alpha) {
698  return type().sub_(*this, other, alpha);
699 }
700 inline Tensor Tensor::sub(Scalar other, Scalar alpha) const {
701  return type().sub(*this, other, alpha);
702 }
703 inline Tensor & Tensor::sub_(Scalar other, Scalar alpha) {
704  return type().sub_(*this, other, alpha);
705 }
706 inline Tensor Tensor::addmm(const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) const {
707  return type().addmm(*this, mat1, mat2, beta, alpha);
708 }
709 inline Tensor & Tensor::addmm_(const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) {
710  return type().addmm_(*this, mat1, mat2, beta, alpha);
711 }
712 inline Tensor & Tensor::sparse_resize_(IntArrayRef size, int64_t sparse_dim, int64_t dense_dim) {
713  return type().sparse_resize_(*this, size, sparse_dim, dense_dim);
714 }
715 inline Tensor & Tensor::sparse_resize_and_clear_(IntArrayRef size, int64_t sparse_dim, int64_t dense_dim) {
716  return type().sparse_resize_and_clear_(*this, size, sparse_dim, dense_dim);
717 }
718 inline Tensor Tensor::sparse_mask(SparseTensorRef mask) const {
719  return type().sparse_mask(*this, mask);
720 }
721 inline Tensor Tensor::to_dense() const {
722  return type().to_dense(*this);
723 }
724 inline int64_t Tensor::sparse_dim() const {
725  return type().sparse_dim(*this);
726 }
727 inline int64_t Tensor::_dimI() const {
728  return type()._dimI(*this);
729 }
730 inline int64_t Tensor::dense_dim() const {
731  return type().dense_dim(*this);
732 }
733 inline int64_t Tensor::_dimV() const {
734  return type()._dimV(*this);
735 }
736 inline int64_t Tensor::_nnz() const {
737  return type()._nnz(*this);
738 }
739 inline Tensor Tensor::coalesce() const {
740  return type().coalesce(*this);
741 }
742 inline bool Tensor::is_coalesced() const {
743  return type().is_coalesced(*this);
744 }
745 inline Tensor Tensor::_indices() const {
746  return type()._indices(*this);
747 }
748 inline Tensor Tensor::_values() const {
749  return type()._values(*this);
750 }
751 inline Tensor & Tensor::_coalesced_(bool coalesced) {
752  return type()._coalesced_(*this, coalesced);
753 }
754 inline Tensor Tensor::indices() const {
755  return type().indices(*this);
756 }
757 inline Tensor Tensor::values() const {
758  return type().values(*this);
759 }
760 inline int64_t Tensor::numel() const {
761  return type().numel(*this);
762 }
763 inline std::vector<Tensor> Tensor::unbind(int64_t dim) const {
764  return type().unbind(*this, dim);
765 }
766 inline Tensor Tensor::to_sparse(int64_t sparse_dim) const {
767  return type().to_sparse(*this, sparse_dim);
768 }
769 inline Tensor Tensor::to_sparse() const {
770  return type().to_sparse(*this);
771 }
772 inline Tensor Tensor::to(const TensorOptions & options, bool non_blocking, bool copy) const {
773  return type().to(*this, options, non_blocking, copy);
774 }
775 inline Tensor Tensor::to(Device device, ScalarType dtype, bool non_blocking, bool copy) const {
776  return type().to(*this, device, dtype, non_blocking, copy);
777 }
778 inline Tensor Tensor::to(ScalarType dtype, bool non_blocking, bool copy) const {
779  return type().to(*this, dtype, non_blocking, copy);
780 }
781 inline Tensor Tensor::to(const Tensor & other, bool non_blocking, bool copy) const {
782  return type().to(*this, other, non_blocking, copy);
783 }
784 inline Scalar Tensor::item() const {
785  return type().item(*this);
786 }
787 inline void* Tensor::data_ptr() const {
788  return type().data_ptr(*this);
789 }
790 inline Tensor & Tensor::set_(Storage source) {
791  return type().set_(*this, source);
792 }
793 inline Tensor & Tensor::set_(Storage source, int64_t storage_offset, IntArrayRef size, IntArrayRef stride) {
794  return type().set_(*this, source, storage_offset, size, stride);
795 }
796 inline Tensor & Tensor::set_(const Tensor & source) {
797  return type().set_(*this, source);
798 }
799 inline Tensor & Tensor::set_() {
800  return type().set_(*this);
801 }
802 inline bool Tensor::is_set_to(const Tensor & tensor) const {
803  return type().is_set_to(*this, tensor);
804 }
805 inline Tensor & Tensor::masked_fill_(const Tensor & mask, Scalar value) {
806  return type().masked_fill_(*this, mask, value);
807 }
808 inline Tensor Tensor::masked_fill(const Tensor & mask, Scalar value) const {
809  return type().masked_fill(*this, mask, value);
810 }
811 inline Tensor & Tensor::masked_fill_(const Tensor & mask, const Tensor & value) {
812  return type().masked_fill_(*this, mask, value);
813 }
814 inline Tensor Tensor::masked_fill(const Tensor & mask, const Tensor & value) const {
815  return type().masked_fill(*this, mask, value);
816 }
817 inline Tensor & Tensor::masked_scatter_(const Tensor & mask, const Tensor & source) {
818  return type().masked_scatter_(*this, mask, source);
819 }
820 inline Tensor Tensor::masked_scatter(const Tensor & mask, const Tensor & source) const {
821  return type().masked_scatter(*this, mask, source);
822 }
823 inline Tensor Tensor::view(IntArrayRef size) const {
824  return type().view(*this, size);
825 }
826 inline Tensor & Tensor::put_(const Tensor & index, const Tensor & source, bool accumulate) {
827  return type().put_(*this, index, source, accumulate);
828 }
829 inline Tensor & Tensor::index_add_(int64_t dim, const Tensor & index, const Tensor & source) {
830  return type().index_add_(*this, dim, index, source);
831 }
832 inline Tensor Tensor::index_add(int64_t dim, const Tensor & index, const Tensor & source) const {
833  return type().index_add(*this, dim, index, source);
834 }
835 inline Tensor & Tensor::index_fill_(int64_t dim, const Tensor & index, Scalar value) {
836  return type().index_fill_(*this, dim, index, value);
837 }
838 inline Tensor Tensor::index_fill(int64_t dim, const Tensor & index, Scalar value) const {
839  return type().index_fill(*this, dim, index, value);
840 }
841 inline Tensor & Tensor::index_fill_(int64_t dim, const Tensor & index, const Tensor & value) {
842  return type().index_fill_(*this, dim, index, value);
843 }
844 inline Tensor Tensor::index_fill(int64_t dim, const Tensor & index, const Tensor & value) const {
845  return type().index_fill(*this, dim, index, value);
846 }
847 inline Tensor & Tensor::scatter_(int64_t dim, const Tensor & index, const Tensor & src) {
848  return type().scatter_(*this, dim, index, src);
849 }
850 inline Tensor Tensor::scatter(int64_t dim, const Tensor & index, const Tensor & src) const {
851  return type().scatter(*this, dim, index, src);
852 }
853 inline Tensor & Tensor::scatter_(int64_t dim, const Tensor & index, Scalar value) {
854  return type().scatter_(*this, dim, index, value);
855 }
856 inline Tensor Tensor::scatter(int64_t dim, const Tensor & index, Scalar value) const {
857  return type().scatter(*this, dim, index, value);
858 }
859 inline Tensor & Tensor::scatter_add_(int64_t dim, const Tensor & index, const Tensor & src) {
860  return type().scatter_add_(*this, dim, index, src);
861 }
862 inline Tensor Tensor::scatter_add(int64_t dim, const Tensor & index, const Tensor & src) const {
863  return type().scatter_add(*this, dim, index, src);
864 }
865 inline Tensor & Tensor::lt_(Scalar other) {
866  return type().lt_(*this, other);
867 }
868 inline Tensor & Tensor::lt_(const Tensor & other) {
869  return type().lt_(*this, other);
870 }
871 inline Tensor & Tensor::gt_(Scalar other) {
872  return type().gt_(*this, other);
873 }
874 inline Tensor & Tensor::gt_(const Tensor & other) {
875  return type().gt_(*this, other);
876 }
877 inline Tensor & Tensor::le_(Scalar other) {
878  return type().le_(*this, other);
879 }
880 inline Tensor & Tensor::le_(const Tensor & other) {
881  return type().le_(*this, other);
882 }
883 inline Tensor & Tensor::ge_(Scalar other) {
884  return type().ge_(*this, other);
885 }
886 inline Tensor & Tensor::ge_(const Tensor & other) {
887  return type().ge_(*this, other);
888 }
889 inline Tensor & Tensor::eq_(Scalar other) {
890  return type().eq_(*this, other);
891 }
892 inline Tensor & Tensor::eq_(const Tensor & other) {
893  return type().eq_(*this, other);
894 }
895 inline Tensor & Tensor::ne_(Scalar other) {
896  return type().ne_(*this, other);
897 }
898 inline Tensor & Tensor::ne_(const Tensor & other) {
899  return type().ne_(*this, other);
900 }
901 inline Tensor Tensor::__and__(Scalar other) const {
902  return type().__and__(*this, other);
903 }
904 inline Tensor Tensor::__and__(const Tensor & other) const {
905  return type().__and__(*this, other);
906 }
907 inline Tensor & Tensor::__iand__(Scalar other) {
908  return type().__iand__(*this, other);
909 }
910 inline Tensor & Tensor::__iand__(const Tensor & other) {
911  return type().__iand__(*this, other);
912 }
913 inline Tensor Tensor::__or__(Scalar other) const {
914  return type().__or__(*this, other);
915 }
916 inline Tensor Tensor::__or__(const Tensor & other) const {
917  return type().__or__(*this, other);
918 }
919 inline Tensor & Tensor::__ior__(Scalar other) {
920  return type().__ior__(*this, other);
921 }
922 inline Tensor & Tensor::__ior__(const Tensor & other) {
923  return type().__ior__(*this, other);
924 }
925 inline Tensor Tensor::__xor__(Scalar other) const {
926  return type().__xor__(*this, other);
927 }
928 inline Tensor Tensor::__xor__(const Tensor & other) const {
929  return type().__xor__(*this, other);
930 }
931 inline Tensor & Tensor::__ixor__(Scalar other) {
932  return type().__ixor__(*this, other);
933 }
934 inline Tensor & Tensor::__ixor__(const Tensor & other) {
935  return type().__ixor__(*this, other);
936 }
937 inline Tensor Tensor::__lshift__(Scalar other) const {
938  return type().__lshift__(*this, other);
939 }
940 inline Tensor Tensor::__lshift__(const Tensor & other) const {
941  return type().__lshift__(*this, other);
942 }
943 inline Tensor & Tensor::__ilshift__(Scalar other) {
944  return type().__ilshift__(*this, other);
945 }
946 inline Tensor & Tensor::__ilshift__(const Tensor & other) {
947  return type().__ilshift__(*this, other);
948 }
949 inline Tensor Tensor::__rshift__(Scalar other) const {
950  return type().__rshift__(*this, other);
951 }
952 inline Tensor Tensor::__rshift__(const Tensor & other) const {
953  return type().__rshift__(*this, other);
954 }
955 inline Tensor & Tensor::__irshift__(Scalar other) {
956  return type().__irshift__(*this, other);
957 }
958 inline Tensor & Tensor::__irshift__(const Tensor & other) {
959  return type().__irshift__(*this, other);
960 }
961 inline Tensor & Tensor::lgamma_() {
962  return type().lgamma_(*this);
963 }
964 inline Tensor & Tensor::atan2_(const Tensor & other) {
965  return type().atan2_(*this, other);
966 }
967 inline Tensor & Tensor::tril_(int64_t diagonal) {
968  return type().tril_(*this, diagonal);
969 }
970 inline Tensor & Tensor::triu_(int64_t diagonal) {
971  return type().triu_(*this, diagonal);
972 }
973 inline Tensor & Tensor::digamma_() {
974  return type().digamma_(*this);
975 }
976 inline Tensor & Tensor::polygamma_(int64_t n) {
977  return type().polygamma_(*this, n);
978 }
979 inline Tensor & Tensor::erfinv_() {
980  return type().erfinv_(*this);
981 }
982 inline Tensor & Tensor::frac_() {
983  return type().frac_(*this);
984 }
985 inline Tensor & Tensor::renorm_(Scalar p, int64_t dim, Scalar maxnorm) {
986  return type().renorm_(*this, p, dim, maxnorm);
987 }
988 inline Tensor & Tensor::reciprocal_() {
989  return type().reciprocal_(*this);
990 }
991 inline Tensor & Tensor::neg_() {
992  return type().neg_(*this);
993 }
994 inline Tensor & Tensor::pow_(Scalar exponent) {
995  return type().pow_(*this, exponent);
996 }
997 inline Tensor & Tensor::pow_(const Tensor & exponent) {
998  return type().pow_(*this, exponent);
999 }
1000 inline Tensor & Tensor::lerp_(const Tensor & end, Scalar weight) {
1001  return type().lerp_(*this, end, weight);
1002 }
1003 inline Tensor & Tensor::lerp_(const Tensor & end, const Tensor & weight) {
1004  return type().lerp_(*this, end, weight);
1005 }
1006 inline Tensor & Tensor::sign_() {
1007  return type().sign_(*this);
1008 }
1009 inline Tensor & Tensor::fmod_(Scalar other) {
1010  return type().fmod_(*this, other);
1011 }
1012 inline Tensor & Tensor::fmod_(const Tensor & other) {
1013  return type().fmod_(*this, other);
1014 }
1015 inline Tensor & Tensor::remainder_(Scalar other) {
1016  return type().remainder_(*this, other);
1017 }
1018 inline Tensor & Tensor::remainder_(const Tensor & other) {
1019  return type().remainder_(*this, other);
1020 }
1021 inline Tensor & Tensor::addbmm_(const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) {
1022  return type().addbmm_(*this, batch1, batch2, beta, alpha);
1023 }
1024 inline Tensor Tensor::addbmm(const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) const {
1025  return type().addbmm(*this, batch1, batch2, beta, alpha);
1026 }
1027 inline Tensor & Tensor::addcmul_(const Tensor & tensor1, const Tensor & tensor2, Scalar value) {
1028  return type().addcmul_(*this, tensor1, tensor2, value);
1029 }
1030 inline Tensor & Tensor::addcdiv_(const Tensor & tensor1, const Tensor & tensor2, Scalar value) {
1031  return type().addcdiv_(*this, tensor1, tensor2, value);
1032 }
1033 inline Tensor & Tensor::random_(int64_t from, int64_t to, Generator * generator) {
1034  return type().random_(*this, from, to, generator);
1035 }
1036 inline Tensor & Tensor::random_(int64_t to, Generator * generator) {
1037  return type().random_(*this, to, generator);
1038 }
1039 inline Tensor & Tensor::random_(Generator * generator) {
1040  return type().random_(*this, generator);
1041 }
1042 inline Tensor & Tensor::uniform_(double from, double to, Generator * generator) {
1043  return type().uniform_(*this, from, to, generator);
1044 }
1045 inline Tensor & Tensor::normal_(double mean, double std, Generator * generator) {
1046  return type().normal_(*this, mean, std, generator);
1047 }
1048 inline Tensor & Tensor::cauchy_(double median, double sigma, Generator * generator) {
1049  return type().cauchy_(*this, median, sigma, generator);
1050 }
1051 inline Tensor & Tensor::log_normal_(double mean, double std, Generator * generator) {
1052  return type().log_normal_(*this, mean, std, generator);
1053 }
1054 inline Tensor & Tensor::exponential_(double lambd, Generator * generator) {
1055  return type().exponential_(*this, lambd, generator);
1056 }
1057 inline Tensor & Tensor::geometric_(double p, Generator * generator) {
1058  return type().geometric_(*this, p, generator);
1059 }
1060 inline Tensor Tensor::diag(int64_t diagonal) const {
1061  return type().diag(*this, diagonal);
1062 }
1063 inline Tensor Tensor::cross(const Tensor & other, int64_t dim) const {
1064  return type().cross(*this, other, dim);
1065 }
1066 inline Tensor Tensor::triu(int64_t diagonal) const {
1067  return type().triu(*this, diagonal);
1068 }
1069 inline Tensor Tensor::tril(int64_t diagonal) const {
1070  return type().tril(*this, diagonal);
1071 }
1072 inline Tensor Tensor::trace() const {
1073  return type().trace(*this);
1074 }
1075 inline Tensor Tensor::ne(Scalar other) const {
1076  return type().ne(*this, other);
1077 }
1078 inline Tensor Tensor::ne(const Tensor & other) const {
1079  return type().ne(*this, other);
1080 }
1081 inline Tensor Tensor::eq(Scalar other) const {
1082  return type().eq(*this, other);
1083 }
1084 inline Tensor Tensor::eq(const Tensor & other) const {
1085  return type().eq(*this, other);
1086 }
1087 inline Tensor Tensor::ge(Scalar other) const {
1088  return type().ge(*this, other);
1089 }
1090 inline Tensor Tensor::ge(const Tensor & other) const {
1091  return type().ge(*this, other);
1092 }
1093 inline Tensor Tensor::le(Scalar other) const {
1094  return type().le(*this, other);
1095 }
1096 inline Tensor Tensor::le(const Tensor & other) const {
1097  return type().le(*this, other);
1098 }
1099 inline Tensor Tensor::gt(Scalar other) const {
1100  return type().gt(*this, other);
1101 }
1102 inline Tensor Tensor::gt(const Tensor & other) const {
1103  return type().gt(*this, other);
1104 }
1105 inline Tensor Tensor::lt(Scalar other) const {
1106  return type().lt(*this, other);
1107 }
1108 inline Tensor Tensor::lt(const Tensor & other) const {
1109  return type().lt(*this, other);
1110 }
1111 inline Tensor Tensor::take(const Tensor & index) const {
1112  return type().take(*this, index);
1113 }
1114 inline Tensor Tensor::index_select(int64_t dim, const Tensor & index) const {
1115  return type().index_select(*this, dim, index);
1116 }
1117 inline Tensor Tensor::masked_select(const Tensor & mask) const {
1118  return type().masked_select(*this, mask);
1119 }
1120 inline Tensor Tensor::nonzero() const {
1121  return type().nonzero(*this);
1122 }
1123 inline Tensor Tensor::gather(int64_t dim, const Tensor & index, bool sparse_grad) const {
1124  return type().gather(*this, dim, index, sparse_grad);
1125 }
1126 inline Tensor Tensor::addcmul(const Tensor & tensor1, const Tensor & tensor2, Scalar value) const {
1127  return type().addcmul(*this, tensor1, tensor2, value);
1128 }
1129 inline Tensor Tensor::addcdiv(const Tensor & tensor1, const Tensor & tensor2, Scalar value) const {
1130  return type().addcdiv(*this, tensor1, tensor2, value);
1131 }
1132 inline std::tuple<Tensor,Tensor> Tensor::gels(const Tensor & A) const {
1133  return type().gels(*this, A);
1134 }
1135 inline std::tuple<Tensor,Tensor> Tensor::trtrs(const Tensor & A, bool upper, bool transpose, bool unitriangular) const {
1136  return type().trtrs(*this, A, upper, transpose, unitriangular);
1137 }
1138 inline std::tuple<Tensor,Tensor> Tensor::symeig(bool eigenvectors, bool upper) const {
1139  return type().symeig(*this, eigenvectors, upper);
1140 }
1141 inline std::tuple<Tensor,Tensor> Tensor::eig(bool eigenvectors) const {
1142  return type().eig(*this, eigenvectors);
1143 }
1144 inline std::tuple<Tensor,Tensor,Tensor> Tensor::svd(bool some, bool compute_uv) const {
1145  return type().svd(*this, some, compute_uv);
1146 }
1147 inline Tensor Tensor::cholesky(bool upper) const {
1148  return type().cholesky(*this, upper);
1149 }
1150 inline Tensor Tensor::cholesky_solve(const Tensor & input2, bool upper) const {
1151  return type().cholesky_solve(*this, input2, upper);
1152 }
1153 inline std::tuple<Tensor,Tensor> Tensor::solve(const Tensor & A) const {
1154  return type().solve(*this, A);
1155 }
1156 inline Tensor Tensor::potri(bool upper) const {
1157  return type().potri(*this, upper);
1158 }
1159 inline std::tuple<Tensor,Tensor> Tensor::pstrf(bool upper, Scalar tol) const {
1160  return type().pstrf(*this, upper, tol);
1161 }
1162 inline std::tuple<Tensor,Tensor> Tensor::qr() const {
1163  return type().qr(*this);
1164 }
1165 inline std::tuple<Tensor,Tensor> Tensor::geqrf() const {
1166  return type().geqrf(*this);
1167 }
1168 inline Tensor Tensor::orgqr(const Tensor & input2) const {
1169  return type().orgqr(*this, input2);
1170 }
1171 inline Tensor Tensor::ormqr(const Tensor & input2, const Tensor & input3, bool left, bool transpose) const {
1172  return type().ormqr(*this, input2, input3, left, transpose);
1173 }
1174 inline std::tuple<Tensor,Tensor> Tensor::btrifact(bool pivot) const {
1175  return type().btrifact(*this, pivot);
1176 }
1177 inline std::tuple<Tensor,Tensor,Tensor> Tensor::btrifact_with_info(bool pivot) const {
1178  return type().btrifact_with_info(*this, pivot);
1179 }
1180 inline Tensor Tensor::btrisolve(const Tensor & LU_data, const Tensor & LU_pivots) const {
1181  return type().btrisolve(*this, LU_data, LU_pivots);
1182 }
1183 inline Tensor Tensor::multinomial(int64_t num_samples, bool replacement, Generator * generator) const {
1184  return type().multinomial(*this, num_samples, replacement, generator);
1185 }
1186 inline Tensor Tensor::lgamma() const {
1187  return type().lgamma(*this);
1188 }
1189 inline Tensor Tensor::digamma() const {
1190  return type().digamma(*this);
1191 }
1192 inline Tensor Tensor::polygamma(int64_t n) const {
1193  return type().polygamma(n, *this);
1194 }
1195 inline Tensor Tensor::erfinv() const {
1196  return type().erfinv(*this);
1197 }
1198 inline Tensor Tensor::frac() const {
1199  return type().frac(*this);
1200 }
1201 inline Tensor Tensor::dist(const Tensor & other, Scalar p) const {
1202  return type().dist(*this, other, p);
1203 }
1204 inline Tensor Tensor::reciprocal() const {
1205  return type().reciprocal(*this);
1206 }
1207 inline Tensor Tensor::neg() const {
1208  return type().neg(*this);
1209 }
1210 inline Tensor Tensor::atan2(const Tensor & other) const {
1211  return type().atan2(*this, other);
1212 }
1213 inline Tensor Tensor::lerp(const Tensor & end, Scalar weight) const {
1214  return type().lerp(*this, end, weight);
1215 }
1216 inline Tensor Tensor::lerp(const Tensor & end, const Tensor & weight) const {
1217  return type().lerp(*this, end, weight);
1218 }
1219 inline Tensor Tensor::histc(int64_t bins, Scalar min, Scalar max) const {
1220  return type().histc(*this, bins, min, max);
1221 }
1222 inline Tensor Tensor::sign() const {
1223  return type().sign(*this);
1224 }
1225 inline Tensor Tensor::fmod(Scalar other) const {
1226  return type().fmod(*this, other);
1227 }
1228 inline Tensor Tensor::fmod(const Tensor & other) const {
1229  return type().fmod(*this, other);
1230 }
1231 inline Tensor Tensor::remainder(Scalar other) const {
1232  return type().remainder(*this, other);
1233 }
1234 inline Tensor Tensor::remainder(const Tensor & other) const {
1235  return type().remainder(*this, other);
1236 }
1237 inline Tensor Tensor::min(const Tensor & other) const {
1238  return type().min(*this, other);
1239 }
1240 inline Tensor Tensor::min() const {
1241  return type().min(*this);
1242 }
1243 inline Tensor Tensor::max(const Tensor & other) const {
1244  return type().max(*this, other);
1245 }
1246 inline Tensor Tensor::max() const {
1247  return type().max(*this);
1248 }
1249 inline Tensor Tensor::median() const {
1250  return type().median(*this);
1251 }
1252 inline std::tuple<Tensor,Tensor> Tensor::sort(int64_t dim, bool descending) const {
1253  return type().sort(*this, dim, descending);
1254 }
1255 inline Tensor Tensor::argsort(int64_t dim, bool descending) const {
1256  return type().argsort(*this, dim, descending);
1257 }
1258 inline std::tuple<Tensor,Tensor> Tensor::topk(int64_t k, int64_t dim, bool largest, bool sorted) const {
1259  return type().topk(*this, k, dim, largest, sorted);
1260 }
1261 inline Tensor Tensor::all() const {
1262  return type().all(*this);
1263 }
1264 inline Tensor Tensor::any() const {
1265  return type().any(*this);
1266 }
1267 inline Tensor Tensor::renorm(Scalar p, int64_t dim, Scalar maxnorm) const {
1268  return type().renorm(*this, p, dim, maxnorm);
1269 }
1270 inline Tensor Tensor::unfold(int64_t dimension, int64_t size, int64_t step) const {
1271  return type().unfold(*this, dimension, size, step);
1272 }
1273 inline bool Tensor::equal(const Tensor & other) const {
1274  return type().equal(*this, other);
1275 }
1276 inline Tensor Tensor::pow(const Tensor & exponent) const {
1277  return type().pow(*this, exponent);
1278 }
1279 inline Tensor Tensor::alias() const {
1280  return type().alias(*this);
1281 }
1282 
1283 inline bool Tensor::is_variable() const noexcept {
1284  return impl_->is_variable();
1285 }
1286 
1287 inline caffe2::TypeMeta Tensor::dtype() const noexcept {
1288  return impl_->dtype();
1289 }
1290 
1291 inline Layout Tensor::layout() const noexcept {
1292  return impl_->layout();
1293 }
1294 
1295 inline Device Tensor::device() const {
1296  return impl_->device();
1297 }
1298 
1299 inline int64_t Tensor::get_device() const {
1300  // NB: this is not a native function to avoid dispatching overhead.
1301  return impl_->get_device();
1302 }
1303 
1304 inline int64_t get_device(Tensor self) {
1305  return self.get_device();
1306 }
1307 
1308 inline bool Tensor::is_cuda() const {
1309  // NB: this is not a native function to avoid dispatching overhead.
1310  return impl_->is_cuda();
1311 }
1312 
1313 inline bool is_cuda(Tensor self) {
1314  return self.is_cuda();
1315 }
1316 
1317 inline bool Tensor::is_hip() const {
1318  // NB: this is not a native function to avoid dispatching overhead.
1319  return impl_->is_hip();
1320 }
1321 
1322 inline bool is_hip(Tensor self) {
1323  return self.is_hip();
1324 }
1325 
1326 inline bool Tensor::is_sparse() const {
1327  // NB: this is not a native function to avoid dispatching overhead.
1328  return impl_->is_sparse();
1329 }
1330 
1331 inline bool is_sparse(Tensor self) {
1332  return self.is_sparse();
1333 }
1334 
1335 #define DEFINE_CAST(T, name, _) \
1336  template <> \
1337  inline T* Tensor::data() const { \
1338  AT_CHECK( \
1339  scalar_type() == ScalarType::name, \
1340  "expected scalar type ", \
1341  #name, \
1342  " but found ", \
1343  c10::toString(scalar_type())); \
1344  return static_cast<T*>(this->data_ptr()); \
1345  }
1346 
1347 AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_EXCEPT_COMPLEX_HALF(DEFINE_CAST)
1348 #undef DEFINE_CAST
1349 
1350 #define DEFINE_ITEM(T, name, _) \
1351  template <> \
1352  inline T Tensor::item() const { \
1353  return item().to##name(); \
1354  }
1355 
1356 AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_EXCEPT_COMPLEX_HALF(DEFINE_ITEM)
1357 #undef DEFINE_ITEM
1358 
1359 } //namespace at
void backward(c10::optional< Tensor > gradient=c10::nullopt, bool keep_graph=false, bool create_graph=false)
Computes the gradient of current tensor w.r.t. graph leaves.
Definition: TensorMethods.h:49
C10_NODISCARD TensorOptions device(c10::optional< Device > device) const noexcept
Return a copy of TensorOptions with device set to the given one, or cleared if device is nullopt...
bool is_variable() const
True if a tensor is a variable.
Definition: TensorImpl.h:809
bool is_hip() const
Returns if a Tensor has HIP backend.
TensorOptions options() const
Returns the TensorOptions corresponding to this Tensor.
Definition: TensorMethods.h:42
Scalar represents a 0-dimensional tensor which contains a single element.
Definition: Scalar.h:22
const caffe2::TypeMeta & dtype() const
Returns the TypeMeta of a tensor, which describes what data type it is (e.g., int, float, ...)
Definition: TensorImpl.h:629
int64_t get_device() const
Returns a Tensor&#39;s device index.
Layout layout() const noexcept
Returns a Tensor&#39;s layout. Defined in Type.h.
caffe2::TypeMeta dtype() const noexcept
Returns a Tensor&#39;s dtype (TypeMeta). Defined in TensorMethods.h.
Represents a a compute device on which a tensor is located.
Definition: Device.h:30
bool is_variable() const noexcept
Returns true if the Tensor is actually a torch::autograd::Variable.
bool is_cuda() const
Returns if a Tensor has CUDA backend.
Device device() const
Returns a Tensor&#39;s device.
Definition: static.cpp:52
bool is_sparse() const
Returns if a Tensor has sparse backend.
C10_NODISCARD TensorOptions dtype(c10::optional< caffe2::TypeMeta > dtype) const noexcept
Return a copy of TensorOptions with dtype set to the given one.
C10_NODISCARD TensorOptions is_variable(c10::optional< bool > is_variable) const noexcept
Sets the is_variable property on the TensorOptions.
Flush-To-Zero and Denormals-Are-Zero mode.
TypeMeta is a thin class that allows us to store the type of a container such as a blob...
Definition: typeid.h:324
C10_NODISCARD TensorOptions layout(c10::optional< Layout > layout) const noexcept
Sets the layout of the TensorOptions.