Caffe2 - C++ API
A deep learning, cross platform ML framework
python_torch_functions_dispatch.h
1 #pragma once
2 
3 // ${generated_comment}
4 
5 #include "torch/csrc/autograd/generated/VariableType.h"
6 #include "torch/csrc/autograd/generated/variable_factories.h"
7 #include "torch/csrc/tensor/python_tensor.h"
8 #include "torch/csrc/utils/auto_gil.h"
9 #include "torch/csrc/utils/cuda_lazy_init.h"
10 
11 #include <ATen/ATen.h>
12 
13 // Contains inline wrappers around ATen functions that release the GIL and
14 // switch to the correct CUDA device.
15 
16 namespace torch { namespace autograd {
17 
18 using at::Tensor;
19 using at::Scalar;
20 using at::TensorList;
21 using at::IntArrayRef;
22 using at::Generator;
24 using at::Storage;
25 using at::TensorOptions;
26 
27 static at::Type& default_type() {
28  return torch::tensors::get_default_tensor_type();
29 }
30 
31 static void maybe_initialize_cuda(const at::TensorOptions& options) {
32  if (options.device().is_cuda()) {
33  torch::utils::cuda_lazy_init();
34  }
35 }
36 
37 ${py_method_dispatch}
38 
39 }} // namespace torch::autograd
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...
Scalar represents a 0-dimensional tensor which contains a single element.
Definition: Scalar.h:22
Definition: jit_type.h:17
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41