Skip to content

Commit 6e822c2

Browse files
committed
Bindings for PyTorch 2.11.
1 parent b8d2670 commit 6e822c2

14 files changed

Lines changed: 525 additions & 111 deletions

File tree

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.23.0"
3+
version = "0.24.0"
44
authors = ["Laurent Mazare <lmazare@gmail.com>"]
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.23.0", path = "torch-sys" }
25+
torch-sys = { version = "0.24.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.10.0* to be available on
21+
This crate requires the C++ PyTorch library (libtorch) in version *v2.11.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.10.0 --recurse-submodule https://github.com/pytorch/pytorch.git pytorch-static --depth 1
88+
git clone -b v2.11.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.23.0"
3+
version = "0.24.0"
44
authors = ["Laurent Mazare <lmazare@gmail.com>"]
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.23.0" }
22-
tch = { path = "../..", features = ["python-extension"], version = "0.23.0" }
23-
torch-sys = { path = "../../torch-sys", features = ["python-extension"], version = "0.23.0" }
21+
pyo3-tch = { path = "../../pyo3-tch", version = "0.24.0" }
22+
tch = { path = "../..", features = ["python-extension"], version = "0.24.0" }
23+
torch-sys = { path = "../../torch-sys", features = ["python-extension"], version = "0.24.0" }

gen/gen.ml

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

885885
let () =
886886
run
887-
~yaml_filename:"third_party/pytorch/Declarations-v2.10.0.yaml"
887+
~yaml_filename:"third_party/pytorch/Declarations-v2.11.0.yaml"
888888
~cpp_filename:"torch-sys/libtch/torch_api_generated"
889889
~ffi_filename:"torch-sys/src/c_generated.rs"
890890
~wrapper_filename:"src/wrappers/tensor_generated.rs"

pyo3-tch/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyo3-tch"
3-
version = "0.23.0"
3+
version = "0.24.0"
44
authors = ["Laurent Mazare <lmazare@gmail.com>"]
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.23.0" }
16-
torch-sys = { path = "../torch-sys", features = ["python-extension"], version = "0.23.0" }
15+
tch = { path = "..", features = ["python-extension"], version = "0.24.0" }
16+
torch-sys = { path = "../torch-sys", features = ["python-extension"], version = "0.24.0" }
1717
pyo3 = { version = "0.24", features = ["extension-module"] }

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ description = "Rust bindings for PyTorch"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
8-
"torch==2.10.0",
8+
"torch==2.11.0",
99
]

src/wrappers/tensor_fallible_generated.rs

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9056,6 +9056,48 @@ impl Tensor {
90569056
Ok(return_ != 0)
90579057
}
90589058

9059+
pub fn f_internal_use_miopen_ctc_loss(
9060+
log_probs: &Tensor,
9061+
targets: &Tensor,
9062+
input_lengths: impl IntList,
9063+
target_lengths: impl IntList,
9064+
blank: i64,
9065+
) -> Result<bool, TchError> {
9066+
let return_;
9067+
unsafe_torch_err!(
9068+
return_ = atg__use_miopen_ctc_loss(
9069+
log_probs.c_tensor,
9070+
targets.c_tensor,
9071+
input_lengths.as_ptr(),
9072+
input_lengths.len_i32(),
9073+
target_lengths.as_ptr(),
9074+
target_lengths.len_i32(),
9075+
blank
9076+
)
9077+
);
9078+
Ok(return_ != 0)
9079+
}
9080+
9081+
pub fn f_internal_use_miopen_ctc_loss_tensor(
9082+
log_probs: &Tensor,
9083+
targets: &Tensor,
9084+
input_lengths: &Tensor,
9085+
target_lengths: &Tensor,
9086+
blank: i64,
9087+
) -> Result<bool, TchError> {
9088+
let return_;
9089+
unsafe_torch_err!(
9090+
return_ = atg__use_miopen_ctc_loss_tensor(
9091+
log_probs.c_tensor,
9092+
targets.c_tensor,
9093+
input_lengths.c_tensor,
9094+
target_lengths.c_tensor,
9095+
blank
9096+
)
9097+
);
9098+
Ok(return_ != 0)
9099+
}
9100+
90599101
pub fn f_internal_validate_compressed_sparse_indices(
90609102
is_crow: bool,
90619103
compressed_idx: &Tensor,
@@ -21460,6 +21502,24 @@ impl Tensor {
2146021502
Ok(Tensor { c_tensor: c_tensors[0] })
2146121503
}
2146221504

21505+
pub fn f_linalg_powsum(
21506+
&self,
21507+
dim: impl IntListOption,
21508+
keepdim: bool,
21509+
dtype: impl Into<Option<Kind>>,
21510+
) -> Result<Tensor, TchError> {
21511+
let mut c_tensors = [std::ptr::null_mut(); 1];
21512+
unsafe_torch_err!(atg_linalg__powsum(
21513+
c_tensors.as_mut_ptr(),
21514+
self.c_tensor,
21515+
dim.as_ptr(),
21516+
dim.len_i32(),
21517+
if keepdim { 1 } else { 0 },
21518+
dtype.into().map_or(-1, |s| s.c_int())
21519+
));
21520+
Ok(Tensor { c_tensor: c_tensors[0] })
21521+
}
21522+
2146321523
pub fn f_linalg_cholesky(&self, upper: bool) -> Result<Tensor, TchError> {
2146421524
let mut c_tensors = [std::ptr::null_mut(); 1];
2146521525
unsafe_torch_err!(atg_linalg_cholesky(
@@ -25191,6 +25251,83 @@ impl Tensor {
2519125251
Ok(Tensor { c_tensor: c_tensors[0] })
2519225252
}
2519325253

25254+
pub fn f_miopen_ctc_loss(
25255+
log_probs: &Tensor,
25256+
targets: &Tensor,
25257+
input_lengths: impl IntList,
25258+
target_lengths: impl IntList,
25259+
blank: i64,
25260+
deterministic: bool,
25261+
zero_infinity: bool,
25262+
) -> Result<(Tensor, Tensor), TchError> {
25263+
let mut c_tensors = [std::ptr::null_mut(); 2];
25264+
unsafe_torch_err!(atg_miopen_ctc_loss(
25265+
c_tensors.as_mut_ptr(),
25266+
log_probs.c_tensor,
25267+
targets.c_tensor,
25268+
input_lengths.as_ptr(),
25269+
input_lengths.len_i32(),
25270+
target_lengths.as_ptr(),
25271+
target_lengths.len_i32(),
25272+
blank,
25273+
if deterministic { 1 } else { 0 },
25274+
if zero_infinity { 1 } else { 0 }
25275+
));
25276+
Ok((Tensor { c_tensor: c_tensors[0] }, Tensor { c_tensor: c_tensors[1] }))
25277+
}
25278+
25279+
pub fn f_miopen_ctc_loss_out(
25280+
out0: &Tensor,
25281+
out1: &Tensor,
25282+
log_probs: &Tensor,
25283+
targets: &Tensor,
25284+
input_lengths: impl IntList,
25285+
target_lengths: impl IntList,
25286+
blank: i64,
25287+
deterministic: bool,
25288+
zero_infinity: bool,
25289+
) -> Result<(Tensor, Tensor), TchError> {
25290+
let mut c_tensors = [std::ptr::null_mut(); 2];
25291+
unsafe_torch_err!(atg_miopen_ctc_loss_out(
25292+
c_tensors.as_mut_ptr(),
25293+
out0.c_tensor,
25294+
out1.c_tensor,
25295+
log_probs.c_tensor,
25296+
targets.c_tensor,
25297+
input_lengths.as_ptr(),
25298+
input_lengths.len_i32(),
25299+
target_lengths.as_ptr(),
25300+
target_lengths.len_i32(),
25301+
blank,
25302+
if deterministic { 1 } else { 0 },
25303+
if zero_infinity { 1 } else { 0 }
25304+
));
25305+
Ok((Tensor { c_tensor: c_tensors[0] }, Tensor { c_tensor: c_tensors[1] }))
25306+
}
25307+
25308+
pub fn f_miopen_ctc_loss_tensor(
25309+
log_probs: &Tensor,
25310+
targets: &Tensor,
25311+
input_lengths: &Tensor,
25312+
target_lengths: &Tensor,
25313+
blank: i64,
25314+
deterministic: bool,
25315+
zero_infinity: bool,
25316+
) -> Result<(Tensor, Tensor), TchError> {
25317+
let mut c_tensors = [std::ptr::null_mut(); 2];
25318+
unsafe_torch_err!(atg_miopen_ctc_loss_tensor(
25319+
c_tensors.as_mut_ptr(),
25320+
log_probs.c_tensor,
25321+
targets.c_tensor,
25322+
input_lengths.c_tensor,
25323+
target_lengths.c_tensor,
25324+
blank,
25325+
if deterministic { 1 } else { 0 },
25326+
if zero_infinity { 1 } else { 0 }
25327+
));
25328+
Ok((Tensor { c_tensor: c_tensors[0] }, Tensor { c_tensor: c_tensors[1] }))
25329+
}
25330+
2519425331
pub fn f_miopen_depthwise_convolution<T: Borrow<Tensor>>(
2519525332
&self,
2519625333
weight: &Tensor,

src/wrappers/tensor_generated.rs

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5287,6 +5287,40 @@ impl Tensor {
52875287
Tensor::f_internal_use_cudnn_rnn_flatten_weight().unwrap()
52885288
}
52895289

5290+
pub fn internal_use_miopen_ctc_loss(
5291+
log_probs: &Tensor,
5292+
targets: &Tensor,
5293+
input_lengths: impl IntList,
5294+
target_lengths: impl IntList,
5295+
blank: i64,
5296+
) -> bool {
5297+
Tensor::f_internal_use_miopen_ctc_loss(
5298+
log_probs,
5299+
targets,
5300+
input_lengths,
5301+
target_lengths,
5302+
blank,
5303+
)
5304+
.unwrap()
5305+
}
5306+
5307+
pub fn internal_use_miopen_ctc_loss_tensor(
5308+
log_probs: &Tensor,
5309+
targets: &Tensor,
5310+
input_lengths: &Tensor,
5311+
target_lengths: &Tensor,
5312+
blank: i64,
5313+
) -> bool {
5314+
Tensor::f_internal_use_miopen_ctc_loss_tensor(
5315+
log_probs,
5316+
targets,
5317+
input_lengths,
5318+
target_lengths,
5319+
blank,
5320+
)
5321+
.unwrap()
5322+
}
5323+
52905324
pub fn internal_validate_compressed_sparse_indices(
52915325
is_crow: bool,
52925326
compressed_idx: &Tensor,
@@ -11220,6 +11254,15 @@ impl Tensor {
1122011254
self.f_lift_out(out).unwrap()
1122111255
}
1122211256

11257+
pub fn linalg_powsum(
11258+
&self,
11259+
dim: impl IntListOption,
11260+
keepdim: bool,
11261+
dtype: impl Into<Option<Kind>>,
11262+
) -> Tensor {
11263+
self.f_linalg_powsum(dim, keepdim, dtype).unwrap()
11264+
}
11265+
1122311266
pub fn linalg_cholesky(&self, upper: bool) -> Tensor {
1122411267
self.f_linalg_cholesky(upper).unwrap()
1122511268
}
@@ -13042,6 +13085,73 @@ impl Tensor {
1304213085
.unwrap()
1304313086
}
1304413087

13088+
pub fn miopen_ctc_loss(
13089+
log_probs: &Tensor,
13090+
targets: &Tensor,
13091+
input_lengths: impl IntList,
13092+
target_lengths: impl IntList,
13093+
blank: i64,
13094+
deterministic: bool,
13095+
zero_infinity: bool,
13096+
) -> (Tensor, Tensor) {
13097+
Tensor::f_miopen_ctc_loss(
13098+
log_probs,
13099+
targets,
13100+
input_lengths,
13101+
target_lengths,
13102+
blank,
13103+
deterministic,
13104+
zero_infinity,
13105+
)
13106+
.unwrap()
13107+
}
13108+
13109+
pub fn miopen_ctc_loss_out(
13110+
out0: &Tensor,
13111+
out1: &Tensor,
13112+
log_probs: &Tensor,
13113+
targets: &Tensor,
13114+
input_lengths: impl IntList,
13115+
target_lengths: impl IntList,
13116+
blank: i64,
13117+
deterministic: bool,
13118+
zero_infinity: bool,
13119+
) -> (Tensor, Tensor) {
13120+
Tensor::f_miopen_ctc_loss_out(
13121+
out0,
13122+
out1,
13123+
log_probs,
13124+
targets,
13125+
input_lengths,
13126+
target_lengths,
13127+
blank,
13128+
deterministic,
13129+
zero_infinity,
13130+
)
13131+
.unwrap()
13132+
}
13133+
13134+
pub fn miopen_ctc_loss_tensor(
13135+
log_probs: &Tensor,
13136+
targets: &Tensor,
13137+
input_lengths: &Tensor,
13138+
target_lengths: &Tensor,
13139+
blank: i64,
13140+
deterministic: bool,
13141+
zero_infinity: bool,
13142+
) -> (Tensor, Tensor) {
13143+
Tensor::f_miopen_ctc_loss_tensor(
13144+
log_probs,
13145+
targets,
13146+
input_lengths,
13147+
target_lengths,
13148+
blank,
13149+
deterministic,
13150+
zero_infinity,
13151+
)
13152+
.unwrap()
13153+
}
13154+
1304513155
pub fn miopen_depthwise_convolution<T: Borrow<Tensor>>(
1304613156
&self,
1304713157
weight: &Tensor,

torch-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "torch-sys"
3-
version = "0.23.0"
3+
version = "0.24.0"
44
authors = ["Laurent Mazare <lmazare@gmail.com>"]
55
edition = "2021"
66
build = "build.rs"

0 commit comments

Comments
 (0)