mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
* Revert "Add missing brace (#7762)" This reverts commitea27c5af50. * Revert "[C++ API] Add backward() to Tensor and Variable (#7750)" This reverts commit1e2762796f.
This commit is contained in:
committed by
Peter Goldsborough
parent
8d91a602cc
commit
60745b3380
+1
-23
@@ -16,7 +16,7 @@ TEST_CASE("misc") {
|
||||
auto y = model->forward({x})[0];
|
||||
Variable s = y.sum();
|
||||
|
||||
s.backward();
|
||||
backward(s);
|
||||
REQUIRE(!model->parameters()["weight"].grad().defined());
|
||||
}
|
||||
|
||||
@@ -45,28 +45,6 @@ TEST_CASE("misc_cuda", "[cuda]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("autograd") {
|
||||
auto x = autograd::make_variable(
|
||||
at::randn(at::CPU(at::kFloat), {3, 3}), /*requires_grad=*/true);
|
||||
auto y = autograd::make_variable(
|
||||
at::randn(at::CPU(at::kFloat), {3, 3}), /*requires_grad=*/false);
|
||||
auto z = x * y;
|
||||
SECTION("derivatives of zero-dim tensors") {
|
||||
z.sum().backward();
|
||||
REQUIRE(x.grad().allclose(y));
|
||||
}
|
||||
SECTION("derivatives of tensors") {
|
||||
z.backward();
|
||||
REQUIRE(x.grad().allclose(y));
|
||||
}
|
||||
SECTION("custom gradient inputs") {
|
||||
z.sum().backward(
|
||||
autograd::make_variable(at::ones(at::CPU(at::kFloat), {1}) * 2));
|
||||
REQUIRE(x.grad().allclose(y * 2));
|
||||
}
|
||||
// Assume everything else is safe from PyTorch tests.
|
||||
}
|
||||
|
||||
TEST_CASE("expanding-array") {
|
||||
SECTION("successful construction") {
|
||||
SECTION("initializer_list") {
|
||||
|
||||
Reference in New Issue
Block a user