Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
libtorch 是否有任何方法可以获取张量或模型设备类型。
就像xxx.device在pytorch中一样?
xxx.device
import torch tensor = torch.rand(3,4) print(tensor.device)
libtorch 的设计目的是在 C++ 中提供与在 python 中几乎完全相同的功能,因此如果有疑问,您可以尝试:
#include <torch/torch.h> torch::Tensor tensor = torch::rand({3,4}); std::cout << tensor.device() << std::endl;
情节扭曲:它有效\o/