From 4903987f40fc2cfc2c2f683f35e7bb69f15065da Mon Sep 17 00:00:00 2001 From: hanhui <193691140@qq.com> Date: Thu, 31 Aug 2023 02:59:51 +0800 Subject: [PATCH] fix typo; fix ci bug; --- chap2/include/TensorCuda.h | 6 +++--- chap2/python/TensorBasics.py | 4 ++-- chap2/readme.md | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chap2/include/TensorCuda.h b/chap2/include/TensorCuda.h index 4762d3e..db9a43e 100644 --- a/chap2/include/TensorCuda.h +++ b/chap2/include/TensorCuda.h @@ -13,11 +13,11 @@ void tensor_cuda() { if (torch::cuda::is_available()) { device = torch::Device(torch::kCUDA); } - torch::Tensor b = torch::randn({3, 3}).cuda(); - torch::Tensor a = torch::randn({3, 3}).to(device); + // torch::Tensor a = torch::randn({3, 3}).cuda(); + torch::Tensor b = torch::randn({3, 3}).to(device); torch::Tensor c = torch::randn({3, 3}, device); // 似乎是发生了 Device -> TensorOptions 的隐式转换 - std::cout << a << std::endl; + // std::cout << a << std::endl; std::cout << b << std::endl; std::cout << c << std::endl; } \ No newline at end of file diff --git a/chap2/python/TensorBasics.py b/chap2/python/TensorBasics.py index 82c278e..a0183d8 100644 --- a/chap2/python/TensorBasics.py +++ b/chap2/python/TensorBasics.py @@ -84,10 +84,10 @@ def tensor_calculate(): # CUDA def tensor_cuda(): device = torch.device("cuda" if torch.cuda.is_available() else "cpu") - a = torch.randn((3,3)).cuda() + # a = torch.randn((3,3)).cuda() b = torch.randn((3,3)).to(device) c = torch.randn((3,3), device=device) # more efficient - print(a) + # print(a) print(b) print(c) diff --git a/chap2/readme.md b/chap2/readme.md index 7ec7dee..3ffc6e3 100644 --- a/chap2/readme.md +++ b/chap2/readme.md @@ -91,8 +91,8 @@ torch::Device device = torch::Device(torch::kCPU); if (torch::cuda::is_available()) { device = torch::Device(torch::kCUDA); } -torch::Tensor b = torch::randn({3, 3}).cuda(); -torch::Tensor a = torch::randn({3, 3}).to(device); +torch::Tensor a = torch::randn({3, 3}).cuda(); +torch::Tensor b = torch::randn({3, 3}).to(device); torch::Tensor c = torch::randn({3, 3}, device); ```