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::tensorwith 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.tensorbehavior.NOTE: C++
torch::tensorwith 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.tensorbehavior.NOTE: The following dtypes are not supported by
torch::tensorcurrently:unsigned intunsigned long intunsigned long long intlong long int