Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit 49b78f0

Browse files
authored
Allow dashes in kernel names (#297)
This allows us to upload kernels with dashes in their names without setting the repo ID in `general.hub`.
1 parent 76b691d commit 49b78f0

File tree

21 files changed

+46
-33
lines changed

21 files changed

+46
-33
lines changed

.github/workflows/kernel_abi_python_release.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ jobs:
141141
strategy:
142142
matrix:
143143
platform:
144-
- runner: macos-13
145-
target: x86_64
146144
- runner: macos-14
147145
target: aarch64
148146
steps:

build2cmake/src/config/v2.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ pub struct General {
5656
pub hub: Option<Hub>,
5757
}
5858

59+
impl General {
60+
/// Name of the kernel as a Python extension.
61+
pub fn python_name(&self) -> String {
62+
self.name.replace("-", "_")
63+
}
64+
}
65+
5966
#[derive(Debug, Deserialize, Serialize)]
6067
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
6168
pub struct Hub {

build2cmake/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ fn clean(
344344
// Clean up empty directories
345345
let dirs_to_check = [
346346
target_dir.join("cmake"),
347-
target_dir.join("torch-ext").join(&build.general.name),
347+
target_dir
348+
.join("torch-ext")
349+
.join(build.general.python_name()),
348350
target_dir.join("torch-ext"),
349351
];
350352

build2cmake/src/torch/cpu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn write_torch_ext_cpu(
2626

2727
let mut file_set = FileSet::default();
2828

29-
let ops_name = kernel_ops_identifier(&target_dir, &build.general.name, ops_id);
29+
let ops_name = kernel_ops_identifier(&target_dir, &build.general.python_name(), ops_id);
3030

3131
write_cmake(
3232
env,
@@ -45,7 +45,7 @@ pub fn write_torch_ext_cpu(
4545
&mut file_set,
4646
)?;
4747

48-
write_ops_py(env, &build.general.name, &ops_name, &mut file_set)?;
48+
write_ops_py(env, &build.general.python_name(), &ops_name, &mut file_set)?;
4949

5050
write_pyproject_toml(env, &mut file_set)?;
5151

build2cmake/src/torch/cuda.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn write_torch_ext_cuda(
3838

3939
let mut file_set = FileSet::default();
4040

41-
let ops_name = kernel_ops_identifier(&target_dir, &build.general.name, ops_id);
41+
let ops_name = kernel_ops_identifier(&target_dir, &build.general.python_name(), ops_id);
4242

4343
write_cmake(
4444
env,
@@ -58,7 +58,7 @@ pub fn write_torch_ext_cuda(
5858
&mut file_set,
5959
)?;
6060

61-
write_ops_py(env, &build.general.name, &ops_name, &mut file_set)?;
61+
write_ops_py(env, &build.general.python_name(), &ops_name, &mut file_set)?;
6262

6363
write_pyproject_toml(env, &mut file_set)?;
6464

build2cmake/src/torch/metal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn write_torch_ext_metal(
4747
&mut file_set,
4848
)?;
4949

50-
write_ops_py(env, &build.general.name, &ops_name, &mut file_set)?;
50+
write_ops_py(env, &build.general.python_name(), &ops_name, &mut file_set)?;
5151

5252
write_pyproject_toml(env, &mut file_set)?;
5353

build2cmake/src/torch/universal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ pub fn write_torch_ext_universal(
1717
) -> Result<FileSet> {
1818
let mut file_set = FileSet::default();
1919

20-
let ops_name = kernel_ops_identifier(&target_dir, &build.general.name, ops_id);
20+
let ops_name = kernel_ops_identifier(&target_dir, &build.general.python_name(), ops_id);
2121

22-
write_ops_py(env, &build.general.name, &ops_name, &mut file_set)?;
22+
write_ops_py(env, &build.general.python_name(), &ops_name, &mut file_set)?;
2323
write_pyproject_toml(
2424
env,
2525
build.torch.as_ref(),

build2cmake/src/torch/xpu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn write_torch_ext_xpu(
2626

2727
let mut file_set = FileSet::default();
2828

29-
let ops_name = kernel_ops_identifier(&target_dir, &build.general.name, ops_id);
29+
let ops_name = kernel_ops_identifier(&target_dir, &build.general.python_name(), ops_id);
3030

3131
write_cmake(
3232
env,
@@ -45,7 +45,7 @@ pub fn write_torch_ext_xpu(
4545
&mut file_set,
4646
)?;
4747

48-
write_ops_py(env, &build.general.name, &ops_name, &mut file_set)?;
48+
write_ops_py(env, &build.general.python_name(), &ops_name, &mut file_set)?;
4949

5050
write_pyproject_toml(env, &mut file_set)?;
5151

examples/cutlass-gemm/build.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[general]
2-
name = "cutlass_gemm"
2+
name = "cutlass-gemm"
33
universal = false
44

55
[torch]

examples/relu-backprop-compile/build.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[general]
2-
name = "relu"
2+
name = "relu-backprop-compile"
33
universal = false
44

55
[torch]

0 commit comments

Comments
 (0)