Skip to content

Commit fde04c4

Browse files
Merge pull request #972 from LaurentMazare/pytorch-2.8.0
Update for pytorch 2.8.
2 parents 3adff18 + fdb55e0 commit fde04c4

File tree

16 files changed

+602
-56
lines changed

16 files changed

+602
-56
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## Unreleased
88
### Changed
99

10+
## v0.21.0
11+
### Changed
12+
- PyTorch v2.8 support
13+
1014
## v0.20.0
1115
### Changed
1216
- PyTorch v2.7 support

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tch"
3-
version = "0.20.0"
3+
version = "0.21.0"
44
authors = ["Laurent Mazare <[email protected]>"]
55
edition = "2021"
66
build = "build.rs"
@@ -22,7 +22,7 @@ libc = "0.2.0"
2222
ndarray = "0.16.1"
2323
rand = "0.8"
2424
thiserror = "1"
25-
torch-sys = { version = "0.20.0", path = "torch-sys" }
25+
torch-sys = { version = "0.21.0", path = "torch-sys" }
2626
zip = "0.6"
2727
half = "2"
2828
safetensors = "0.3.0"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The code generation part for the C api on top of libtorch comes from
1818

1919
## Getting Started
2020

21-
This crate requires the C++ PyTorch library (libtorch) in version *v2.7.0* to be available on
21+
This crate requires the C++ PyTorch library (libtorch) in version *v2.8.0* to be available on
2222
your system. You can either:
2323

2424
- Use the system-wide libtorch installation (default).
@@ -85,7 +85,7 @@ seem to include `libtorch.a` by default so this would have to be compiled
8585
manually, e.g. via the following:
8686

8787
```bash
88-
git clone -b v2.7.0 --recurse-submodule https://github.com/pytorch/pytorch.git pytorch-static --depth 1
88+
git clone -b v2.8.0 --recurse-submodule https://github.com/pytorch/pytorch.git pytorch-static --depth 1
8989
cd pytorch-static
9090
USE_CUDA=OFF BUILD_SHARED_LIBS=OFF python setup.py build
9191
# export LIBTORCH to point at the build directory in pytorch-static.

examples/python-extension/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tch-ext"
3-
version = "0.20.0"
3+
version = "0.21.0"
44
authors = ["Laurent Mazare <[email protected]>"]
55
edition = "2021"
66
build = "build.rs"
@@ -18,6 +18,6 @@ crate-type = ["cdylib"]
1818

1919
[dependencies]
2020
pyo3 = { version = "0.24", features = ["extension-module"] }
21-
pyo3-tch = { path = "../../pyo3-tch", version = "0.20.0" }
22-
tch = { path = "../..", features = ["python-extension"], version = "0.20.0" }
23-
torch-sys = { path = "../../torch-sys", features = ["python-extension"], version = "0.20.0" }
21+
pyo3-tch = { path = "../../pyo3-tch", version = "0.21.0" }
22+
tch = { path = "../..", features = ["python-extension"], version = "0.21.0" }
23+
torch-sys = { path = "../../torch-sys", features = ["python-extension"], version = "0.21.0" }

examples/yolo/darknet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl Darknet {
241241
Ok(image_width)
242242
}
243243

244-
pub fn build_model(&self, vs: &nn::Path) -> Result<FuncT> {
244+
pub fn build_model(&self, vs: &nn::Path) -> Result<FuncT<'_>> {
245245
let mut blocks: Vec<(i64, Bl)> = vec![];
246246
let mut prev_channels: i64 = 3;
247247
for (index, block) in self.blocks.iter().enumerate() {

gen/gen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ let run
883883

884884
let () =
885885
run
886-
~yaml_filename:"third_party/pytorch/Declarations-v2.7.0.yaml"
886+
~yaml_filename:"third_party/pytorch/Declarations-v2.8.0.yaml"
887887
~cpp_filename:"torch-sys/libtch/torch_api_generated"
888888
~ffi_filename:"torch-sys/src/c_generated.rs"
889889
~wrapper_filename:"src/wrappers/tensor_generated.rs"

pyo3-tch/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyo3-tch"
3-
version = "0.20.0"
3+
version = "0.21.0"
44
authors = ["Laurent Mazare <[email protected]>"]
55
edition = "2021"
66
build = "build.rs"
@@ -12,6 +12,6 @@ categories = ["science"]
1212
license = "MIT/Apache-2.0"
1313

1414
[dependencies]
15-
tch = { path = "..", features = ["python-extension"], version = "0.20.0" }
16-
torch-sys = { path = "../torch-sys", features = ["python-extension"], version = "0.20.0" }
17-
pyo3 = { version = "0.24", features = ["extension-module"] }
15+
tch = { path = "..", features = ["python-extension"], version = "0.21.0" }
16+
torch-sys = { path = "../torch-sys", features = ["python-extension"], version = "0.21.0" }
17+
pyo3 = { version = "0.24", features = ["extension-module"] }

src/nn/var_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl VarStore {
149149
/// Variables are named and organized using paths. This function returns
150150
/// the top level path for the var store and can be combined with '/'
151151
/// to create sub-paths.
152-
pub fn root(&self) -> Path {
152+
pub fn root(&self) -> Path<'_> {
153153
Path { path: vec![], group: 0, var_store: self }
154154
}
155155

src/tensor/safetensors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl View for SafeView<'_> {
9191
&self.shape
9292
}
9393

94-
fn data(&self) -> std::borrow::Cow<[u8]> {
94+
fn data(&self) -> std::borrow::Cow<'_, [u8]> {
9595
let mut data = vec![0; self.data_len()];
9696
let numel = self.tensor.numel();
9797
self.tensor.f_copy_data_u8(&mut data, numel).unwrap();

0 commit comments

Comments
 (0)