Fix issues in torch::tensor constructor#26890
Conversation
bd28b86 to
427ea40
Compare
This reverts commit 427ea40.
641cde6 to
23401f2
Compare
23401f2 to
8cb239e
Compare
What is the ambiguous overload problem? |
| scalar_type_(at::k##S), \ | ||
| type_(InitListTensorType::Scalar) {} | ||
| // 2. A Tensor represented in `std::vector<ListInitTensor>` form, with value | ||
| // `vec()`, Tensor scalar type `scalar_type()`, and Tensor sizes `sizes()`. |
There was a problem hiding this comment.
It might be better to name vec something more descriptive, like values
| sizes_(), \ | ||
| scalar_type_(at::k##S), \ | ||
| type_(ListInitTensorType::Scalar) {} \ | ||
| ListInitTensor(std::vector<T> values) : \ |
There was a problem hiding this comment.
Why do we need this constructor? std::vector<T> is implicitly convertible to at::ArrayRef<T>, so isn't it sufficient to just have that constructor?
There was a problem hiding this comment.
I tried removing the constructor that takes in std::vector<T>, but got the following error:
../aten/src/ATen/test/pow_test.cpp:225:39: required from here
../aten/src/ATen/test/pow_test.cpp:111:36: error: no matching function for call to ‘tensor(const std::vector<int>&)’
const auto tensor = torch::tensor(vals);
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../aten/src/ATen/test/pow_test.cpp:5:
../torch/csrc/autograd/generated/variable_factories.h:177:19: note: candidate: at::Tensor torch::tensor(torch::detail::ListInitTensor, const c10::TensorOptions&)
inline at::Tensor tensor(detail::ListInitTensor list_init_tensor, const at::TensorOptions& options) {
^
../torch/csrc/autograd/generated/variable_factories.h:177:19: note: candidate expects 2 arguments, 1 provided
../torch/csrc/autograd/generated/variable_factories.h:181:19: note: candidate: at::Tensor torch::tensor(torch::detail::ListInitTensor)
inline at::Tensor tensor(detail::ListInitTensor list_init_tensor) {
^
../torch/csrc/autograd/generated/variable_factories.h:181:19: note: no known conversion for argument 1 from ‘const std::vector<int>’ to ‘torch::detail::ListInitTensor’
I suspect the issue is that there might be too many conversions going on that the compiler just refuses to do it...
There was a problem hiding this comment.
Yikes. Could we make it take const std::vector<T>& values so that we don't incur an additional copy?
In addition, could we just call the ArrayRef ctor here? Something like
ListInitTensor(const std::vector<T>& values) : ListInitTensor(ArrayRef<T>(values)) {}`
| type_(ListInitTensorType::Vector) { \ | ||
| vec_.reserve(values.size()); \ | ||
| for (const auto& elem : values) { \ | ||
| vec_.push_back(ListInitTensor(elem)); \ |
There was a problem hiding this comment.
Discussed offline: there might be a performance regression here. For an ArrayRef with 1000 elements, before we would call at::tensor. Now the code calls tensor.fill_ 1000 times. With 1us dispatch overhead this takes 1(!)ms, which is probably slower than what at::tensor can do (I imagine it does a memcpy).
There was a problem hiding this comment.
Oh, interesting. Previously, torch::tensor({1, 2, 3, 4, 5, 6}) went through the ArrayRef ctor. Now, it goes through the ListInitTensor ctor. This means that there might be a performance regression for people who used to use torch::tensor({1, 2, 3, 4, 5, 6})
zou3519
left a comment
There was a problem hiding this comment.
Code looks correct but we can improve it more. I'm not sure how much a perf regression this actually gives (compared to calling at::tensor), it would be good to benchmark and conclude if we should make a fast-path or not.
| " with sizes: ", | ||
| elem.sizes_); | ||
| type_(ListInitTensorType::Vector) { | ||
| if (init_list.size() > 0) { |
There was a problem hiding this comment.
Nit: you can avoid the additional indentation (and reduce the number of lines changed) by doing something like:
if (init_list.size() == 0) {
scalar_type_ = c10::ScalarType::Undefined;
sizes_ = {0};
return;
}
// existing code here
d179b41 to
d917f5f
Compare
40527fb to
d9481ad
Compare
This reverts commit c6d29d1.
d9481ad to
d9ef7b1
Compare
|
@zou3519 I reduced the scope of this PR to just add support for |
This reverts commit cb134ac.
710927f to
45c4339
Compare
| TORCH_CHECK(init_list.size() > 0, "Empty init-list is not supported"); | ||
| TORCH_CHECK( | ||
| init_list.size() > 0, | ||
| "Empty init-list is not yet supported. We can create tensors with zero-size dimensions in the following way:\n", |
There was a problem hiding this comment.
I know I asked you to add this error message, but I'm wondering: what actually happens if a user tries to call torch::tensor({})? Is it a compilation error or does this error message get triggered?
If this error message gets triggered, could we add a test for it?
There was a problem hiding this comment.
Compiling torch::tensor({}) gives an "ambiguous overload" compilation error:
../test/cpp/api/tensor.cpp:232:35: error: call of overloaded ‘tensor(<brace-enclosed initializer list>)’ is ambiguous
auto tensor = torch::tensor({});
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:181:644: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<unsigned char>)
../torch/csrc/autograd/generated/variable_factories.h:181:766: note: candidate: at::Tensor torch::tensor(std::initializer_list<unsigned char>)
../torch/csrc/autograd/generated/variable_factories.h:181:887: note: candidate: at::Tensor torch::tensor(uint8_t)
../torch/csrc/autograd/generated/variable_factories.h:181:1603: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<signed char>)
../torch/csrc/autograd/generated/variable_factories.h:181:1724: note: candidate: at::Tensor torch::tensor(std::initializer_list<signed char>)
../torch/csrc/autograd/generated/variable_factories.h:181:1843: note: candidate: at::Tensor torch::tensor(int8_t)
../torch/csrc/autograd/generated/variable_factories.h:181:2562: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<short int>)
../torch/csrc/autograd/generated/variable_factories.h:181:2685: note: candidate: at::Tensor torch::tensor(std::initializer_list<short int>)
../torch/csrc/autograd/generated/variable_factories.h:181:2806: note: candidate: at::Tensor torch::tensor(int16_t)
../torch/csrc/autograd/generated/variable_factories.h:181:3507: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<int>)
../torch/csrc/autograd/generated/variable_factories.h:181:3624: note: candidate: at::Tensor torch::tensor(std::initializer_list<int>)
../torch/csrc/autograd/generated/variable_factories.h:181:3737: note: candidate: at::Tensor torch::tensor(int)
../torch/csrc/autograd/generated/variable_factories.h:181:4450: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<long int>)
../torch/csrc/autograd/generated/variable_factories.h:181:4572: note: candidate: at::Tensor torch::tensor(std::initializer_list<long int>)
../torch/csrc/autograd/generated/variable_factories.h:181:4693: note: candidate: at::Tensor torch::tensor(int64_t)
../torch/csrc/autograd/generated/variable_factories.h:181:5404: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<float>)
../torch/csrc/autograd/generated/variable_factories.h:181:5525: note: candidate: at::Tensor torch::tensor(std::initializer_list<float>)
../torch/csrc/autograd/generated/variable_factories.h:181:5642: note: candidate: at::Tensor torch::tensor(float)
../torch/csrc/autograd/generated/variable_factories.h:181:6354: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<double>)
../torch/csrc/autograd/generated/variable_factories.h:181:6477: note: candidate: at::Tensor torch::tensor(std::initializer_list<double>)
../torch/csrc/autograd/generated/variable_factories.h:181:6596: note: candidate: at::Tensor torch::tensor(double)
../torch/csrc/autograd/generated/variable_factories.h:181:7630: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<bool>)
../torch/csrc/autograd/generated/variable_factories.h:181:7815: note: candidate: at::Tensor torch::tensor(std::initializer_list<bool>)
../torch/csrc/autograd/generated/variable_factories.h:181:8062: note: candidate: at::Tensor torch::tensor(c10::impl::ScalarTypeToCPPType<(c10::ScalarType)11>::type)
../torch/csrc/autograd/generated/variable_factories.h:181:9224: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::Half>)
../torch/csrc/autograd/generated/variable_factories.h:181:9409: note: candidate: at::Tensor torch::tensor(std::initializer_list<c10::Half>)
../torch/csrc/autograd/generated/variable_factories.h:181:9656: note: candidate: at::Tensor torch::tensor(c10::impl::ScalarTypeToCPPType<(c10::ScalarType)5>::type)
../torch/csrc/autograd/generated/variable_factories.h:181:10838: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::BFloat16>)
../torch/csrc/autograd/generated/variable_factories.h:181:11031: note: candidate: at::Tensor torch::tensor(std::initializer_list<c10::BFloat16>)
../torch/csrc/autograd/generated/variable_factories.h:181:11286: note: candidate: at::Tensor torch::tensor(c10::impl::ScalarTypeToCPPType<(c10::ScalarType)15>::type)
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:197:19: note: candidate: at::Tensor torch::tensor(torch::detail::InitListTensor)
inline at::Tensor tensor(detail::InitListTensor init_list_tensor) {
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:212:19: note: candidate: at::Tensor torch::tensor(std::initializer_list<torch::detail::InitListTensor>)
inline at::Tensor tensor(std::initializer_list<detail::InitListTensor> init_list) {
^
Compiling torch::tensor({{}, {}}) also gives an "ambiguous overload" compilation error:
../test/cpp/api/tensor.cpp:232:41: error: call of overloaded ‘tensor(<brace-enclosed initializer list>)’ is ambiguous
auto tensor = torch::tensor({{}, {}});
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:181:644: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<unsigned char>)
../torch/csrc/autograd/generated/variable_factories.h:181:766: note: candidate: at::Tensor torch::tensor(std::initializer_list<unsigned char>)
../torch/csrc/autograd/generated/variable_factories.h:181:1603: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<signed char>)
../torch/csrc/autograd/generated/variable_factories.h:181:1724: note: candidate: at::Tensor torch::tensor(std::initializer_list<signed char>)
../torch/csrc/autograd/generated/variable_factories.h:181:2562: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<short int>)
../torch/csrc/autograd/generated/variable_factories.h:181:2685: note: candidate: at::Tensor torch::tensor(std::initializer_list<short int>)
../torch/csrc/autograd/generated/variable_factories.h:181:3507: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<int>)
../torch/csrc/autograd/generated/variable_factories.h:181:3624: note: candidate: at::Tensor torch::tensor(std::initializer_list<int>)
../torch/csrc/autograd/generated/variable_factories.h:181:4450: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<long int>)
../torch/csrc/autograd/generated/variable_factories.h:181:4572: note: candidate: at::Tensor torch::tensor(std::initializer_list<long int>)
../torch/csrc/autograd/generated/variable_factories.h:181:5404: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<float>)
../torch/csrc/autograd/generated/variable_factories.h:181:5525: note: candidate: at::Tensor torch::tensor(std::initializer_list<float>)
../torch/csrc/autograd/generated/variable_factories.h:181:6354: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<double>)
../torch/csrc/autograd/generated/variable_factories.h:181:6477: note: candidate: at::Tensor torch::tensor(std::initializer_list<double>)
../torch/csrc/autograd/generated/variable_factories.h:181:7630: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<bool>)
../torch/csrc/autograd/generated/variable_factories.h:181:7815: note: candidate: at::Tensor torch::tensor(std::initializer_list<bool>)
../torch/csrc/autograd/generated/variable_factories.h:181:9224: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::Half>)
../torch/csrc/autograd/generated/variable_factories.h:181:9409: note: candidate: at::Tensor torch::tensor(std::initializer_list<c10::Half>)
../torch/csrc/autograd/generated/variable_factories.h:181:9656: note: candidate: at::Tensor torch::tensor(c10::impl::ScalarTypeToCPPType<(c10::ScalarType)5>::type)
../torch/csrc/autograd/generated/variable_factories.h:181:10838: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::BFloat16>)
../torch/csrc/autograd/generated/variable_factories.h:181:11031: note: candidate: at::Tensor torch::tensor(std::initializer_list<c10::BFloat16>)
../torch/csrc/autograd/generated/variable_factories.h:181:11286: note: candidate: at::Tensor torch::tensor(c10::impl::ScalarTypeToCPPType<(c10::ScalarType)15>::type)
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:197:19: note: candidate: at::Tensor torch::tensor(torch::detail::InitListTensor)
inline at::Tensor tensor(detail::InitListTensor init_list_tensor) {
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:212:19: note: candidate: at::Tensor torch::tensor(std::initializer_list<torch::detail::InitListTensor>)
inline at::Tensor tensor(std::initializer_list<detail::InitListTensor> init_list) {
^
I think improving the error message here is still a good idea, in case people try to look at the source code to figure out what they should do to create tensors with zero-size dimensions.
There was a problem hiding this comment.
Is it clearly documented somewhere that we don't support {}?
There was a problem hiding this comment.
Currently it's documented in https://github.com/pytorch/pytorch/pull/26890/files#diff-11228124349c21669d7262f207725b41R184-R188. I will also update https://pytorch.org/cppdocs/notes/tensor_creation.html to document this, after merging this PR.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@yf225 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary:
This PR contains the following:
1. Fix ambiguous overload problem when `torch::tensor({{1, 2}})` is used:
```
../test/cpp/api/tensor.cpp: In member function ‘virtual void TensorTest_MultidimTensorCtor_Test::TestBody()’:
../test/cpp/api/tensor.cpp:202:41: error: call of overloaded ‘tensor(<brace-enclosed initializer list>)’ is ambiguous
auto tensor = torch::tensor({{1, 2}});
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:177:644: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<unsigned char>)
../torch/csrc/autograd/generated/variable_factories.h:177:1603: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<signed char>)
../torch/csrc/autograd/generated/variable_factories.h:177:2562: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<short int>)
../torch/csrc/autograd/generated/variable_factories.h:177:3507: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<int>)
../torch/csrc/autograd/generated/variable_factories.h:177:4450: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<long int>)
../torch/csrc/autograd/generated/variable_factories.h:177:5404: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<float>)
../torch/csrc/autograd/generated/variable_factories.h:177:6354: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<double>)
../torch/csrc/autograd/generated/variable_factories.h:177:7630: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<bool>)
../torch/csrc/autograd/generated/variable_factories.h:177:9224: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::Half>)
../torch/csrc/autograd/generated/variable_factories.h:177:10838: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::BFloat16>)
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:193:19: note: candidate: at::Tensor torch::tensor(torch::detail::InitListTensor)
inline at::Tensor tensor(detail::InitListTensor list_init_tensor) {
^
```
After this PR, the multidim tensor constructor `torch::tensor(...)` should be ready for general use.
Pull Request resolved: pytorch#26890
Differential Revision: D17632608
Pulled By: yf225
fbshipit-source-id: 2e653d4ad85729d052328a124004d64994bec782
Summary:
This PR contains the following:
1. Fix ambiguous overload problem when `torch::tensor({{1, 2}})` is used:
```
../test/cpp/api/tensor.cpp: In member function ‘virtual void TensorTest_MultidimTensorCtor_Test::TestBody()’:
../test/cpp/api/tensor.cpp:202:41: error: call of overloaded ‘tensor(<brace-enclosed initializer list>)’ is ambiguous
auto tensor = torch::tensor({{1, 2}});
^
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:177:644: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<unsigned char>)
../torch/csrc/autograd/generated/variable_factories.h:177:1603: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<signed char>)
../torch/csrc/autograd/generated/variable_factories.h:177:2562: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<short int>)
../torch/csrc/autograd/generated/variable_factories.h:177:3507: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<int>)
../torch/csrc/autograd/generated/variable_factories.h:177:4450: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<long int>)
../torch/csrc/autograd/generated/variable_factories.h:177:5404: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<float>)
../torch/csrc/autograd/generated/variable_factories.h:177:6354: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<double>)
../torch/csrc/autograd/generated/variable_factories.h:177:7630: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<bool>)
../torch/csrc/autograd/generated/variable_factories.h:177:9224: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::Half>)
../torch/csrc/autograd/generated/variable_factories.h:177:10838: note: candidate: at::Tensor torch::tensor(c10::ArrayRef<c10::BFloat16>)
In file included from ../caffe2/../torch/csrc/api/include/torch/types.h:7:0,
from ../caffe2/../torch/csrc/api/include/torch/detail/static.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/pimpl.h:4,
from ../caffe2/../torch/csrc/api/include/torch/nn/module.h:3,
from ../caffe2/../torch/csrc/api/include/torch/nn/cloneable.h:3,
from ../test/cpp/api/support.h:7,
from ../test/cpp/api/tensor.cpp:2:
../torch/csrc/autograd/generated/variable_factories.h:193:19: note: candidate: at::Tensor torch::tensor(torch::detail::InitListTensor)
inline at::Tensor tensor(detail::InitListTensor list_init_tensor) {
^
```
After this PR, the multidim tensor constructor `torch::tensor(...)` should be ready for general use.
Pull Request resolved: pytorch#26890
Differential Revision: D17632608
Pulled By: yf225
fbshipit-source-id: 2e653d4ad85729d052328a124004d64994bec782
This PR contains the following:
torch::tensor({{1, 2}})is used:After this PR, the multidim tensor constructor
torch::tensor(...)should be ready for general use.