評價本頁

庫版本控制#

我們提供了版本號宏,用於識別正在使用的 LibTorch 版本。示例用法

#include <torch/torch.h>
#include <iostream>

int main() {
  std::cout << "PyTorch version from parts: "
    << TORCH_VERSION_MAJOR << "."
    << TORCH_VERSION_MINOR << "."
    << TORCH_VERSION_PATCH << std::endl;
  std::cout << "PyTorch version: " << TORCH_VERSION << std::endl;
}

這將輸出類似以下內容

PyTorch version from parts: 1.8.0
PyTorch version: 1.8.0

注意

這些宏僅在 PyTorch 版本 >= 1.8.0 中可用。