Function torch::tensor¶
Defined in File variable_factories.h
Function Documentation¶
-
inline at::Tensor torch::tensor(detail::TensorDataContainer tensor_data_container, const at::TensorOptions &options = {})¶
NOTE: Currently
torch::tensor(...)
doesn’t support mixed data types (i.e.torch::tensor({{bool, 2.0}})
doesn’t work). We might be able to support it in the future by iterating over all sub-lists to find the largest data type that can represent all of the elements, or by using variadic templates.NOTE: C++
torch::tensor
with a floating-point type or anat::ArrayRef
/std::vector
/ (nested) braced-init-list of floating-point types always produces a tensor of dtypetorch::get_default_dtype()
, matching Pythontorch.tensor
behavior.NOTE: C++
torch::tensor
with an integer type or anat::ArrayRef
/std::vector
/ (nested) braced-init-list of integer types always produces a tensor of dtypeat::kLong
(aka. int64_t), matching Pythontorch.tensor
behavior.NOTE: The following dtypes are not supported by
torch::tensor
currently:unsigned int
unsigned long int
unsigned long long int
long long int