mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Make torch::Tensor -> at::Tensor (#10516)
Summary: This PR removes the `using Tensor = autograd::Variable;` alias from `torch/tensor.h`, which means `torch::Tensor` is now `at::Tensor`. This PR fixes up some last uses of `.data()` and tidies up the resulting code. For example, I was able to remove `TensorListView` such that code like ``` auto loss = torch::stack(torch::TensorListView(policy_loss)).sum() + torch::stack(torch::TensorListView(value_loss)).sum(); ``` is now ``` auto loss = torch::stack(policy_loss).sum() + torch::stack(value_loss).sum(); ``` CC jgehring ebetica Pull Request resolved: https://github.com/pytorch/pytorch/pull/10516 Differential Revision: D9324691 Pulled By: goldsborough fbshipit-source-id: a7c1cb779c9c829f89cea55f07ac539b00c78449
This commit is contained in:
committed by
Facebook Github Bot
parent
8013dac43d
commit
2e0dd86903
@ -184,8 +184,7 @@ TEST_CASE("Tensor/UsesOptionsThatAreSupplied") {
|
||||
|
||||
TEST_CASE("FromBlob") {
|
||||
std::vector<int32_t> v = {1, 2, 3};
|
||||
auto tensor = torch::from_blob(
|
||||
reinterpret_cast<void*>(v.data()), v.size(), torch::kInt32);
|
||||
auto tensor = torch::from_blob(v.data(), v.size(), torch::kInt32);
|
||||
REQUIRE(tensor.is_variable());
|
||||
REQUIRE(tensor.numel() == 3);
|
||||
REQUIRE(tensor[0].toCInt() == 1);
|
||||
|
Reference in New Issue
Block a user