mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary:
Uses cmake's `configure_file()` macro to generate a new `torch/csrc/api/include/torch/version.h` header with `TORCH_VERSION_{MAJOR,MINOR,PATCH}` \#defines from an input file `torch/csrc/api/include/torch/version.h.in`.
For Bazel builds, this is accomplished with `header_template_rule()`.
For Buck builds, this is accomplished with `fb_native.genrule()`.
Fixes https://github.com/pytorch/pytorch/issues/44365
<img width="1229" alt="Screen Shot 2021-01-05 at 3 19 24 PM" src="https://user-images.githubusercontent.com/75754324/103809279-3fd80380-5027-11eb-9039-fd23922cebd5.png">
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50073
Reviewed By: glaringlee
Differential Revision: D25855877
Pulled By: jbschlosser
fbshipit-source-id: 6bb792718c97e2c2dbaa74b7b7b831a4f6938e49
28 lines
527 B
ReStructuredText
28 lines
527 B
ReStructuredText
Library Versioning
|
|
==================
|
|
|
|
We provide version number macros for identifying the version of LibTorch in use.
|
|
Example usage:
|
|
|
|
.. code-block:: cpp
|
|
|
|
#include <torch/torch.h>
|
|
#include <iostream>
|
|
|
|
int main() {
|
|
std::cout << "PyTorch version: "
|
|
<< TORCH_VERSION_MAJOR << "."
|
|
<< TORCH_VERSION_MINOR << "."
|
|
<< TORCH_VERSION_PATCH << std::endl;
|
|
}
|
|
|
|
This will output something like:
|
|
|
|
.. code-block:: text
|
|
|
|
PyTorch version: 1.8.0
|
|
|
|
.. note::
|
|
|
|
These macros are only available in PyTorch >= 1.8.0.
|