Skip to content

Commit

Permalink
Simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 11, 2024
1 parent a1b7b77 commit e3b38de
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions ext/torch/torch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ torch::Tensor make_tensor(Rice::Array a, const std::vector<int64_t> &size, const
vec.push_back(Rice::detail::From_Ruby<T>().convert(a[i].value()));
}

// hack for requires_grad error
auto requires_grad = options.requires_grad();
torch::Tensor t = torch::tensor(vec, options.requires_grad(c10::nullopt));
if (requires_grad) {
t.set_requires_grad(true);
}

torch::Tensor t = torch::tensor(vec, options);
return t.reshape(size);
}

Expand Down

0 comments on commit e3b38de

Please sign in to comment.