File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,3 +79,28 @@ pub fn write_torch_registration_macros(file_set: &mut FileSet) -> Result<()> {
7979
8080 Ok ( ( ) )
8181}
82+
83+ pub fn write_ops_py (
84+ env : & Environment ,
85+ name : & str ,
86+ ops_name : & str ,
87+ file_set : & mut FileSet ,
88+ ) -> Result < ( ) > {
89+ let mut path = PathBuf :: new ( ) ;
90+ path. push ( "torch-ext" ) ;
91+ path. push ( name) ;
92+ path. push ( "_ops.py" ) ;
93+ let writer = file_set. entry ( path) ;
94+
95+ env. get_template ( "_ops.py" )
96+ . wrap_err ( "Cannot get _ops.py template" ) ?
97+ . render_to_write (
98+ context ! {
99+ ops_name => ops_name,
100+ } ,
101+ writer,
102+ )
103+ . wrap_err ( "Cannot render kernel template" ) ?;
104+
105+ Ok ( ( ) )
106+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use minijinja::{context, Environment};
77use crate :: config:: { Backend , Build , Torch } ;
88use crate :: fileset:: FileSet ;
99use crate :: torch:: common:: write_metadata;
10+ use crate :: torch:: common:: write_ops_py;
1011use crate :: torch:: common:: write_pyproject_toml;
1112use crate :: torch:: common:: write_torch_registration_macros;
1213use crate :: torch:: kernel:: render_kernel_components;
@@ -172,31 +173,6 @@ fn render_preamble(
172173 Ok ( ( ) )
173174}
174175
175- fn write_ops_py (
176- env : & Environment ,
177- name : & str ,
178- ops_name : & str ,
179- file_set : & mut FileSet ,
180- ) -> Result < ( ) > {
181- let mut path = PathBuf :: new ( ) ;
182- path. push ( "torch-ext" ) ;
183- path. push ( name) ;
184- path. push ( "_ops.py" ) ;
185- let writer = file_set. entry ( path) ;
186-
187- env. get_template ( "_ops.py" )
188- . wrap_err ( "Cannot get _ops.py template" ) ?
189- . render_to_write (
190- context ! {
191- ops_name => ops_name,
192- } ,
193- writer,
194- )
195- . wrap_err ( "Cannot render kernel template" ) ?;
196-
197- Ok ( ( ) )
198- }
199-
200176fn write_setup_py (
201177 env : & Environment ,
202178 torch : & Torch ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use minijinja::{context, Environment};
99use crate :: config:: { Backend , Build , Dependency , Torch } ;
1010use crate :: torch:: common:: prefix_and_join_includes;
1111use crate :: torch:: common:: write_metadata;
12+ use crate :: torch:: common:: write_ops_py;
1213use crate :: torch:: common:: write_pyproject_toml;
1314use crate :: torch:: common:: write_torch_registration_macros;
1415use crate :: torch:: kernel:: render_kernel_components;
@@ -93,31 +94,6 @@ fn write_setup_py(
9394 Ok ( ( ) )
9495}
9596
96- fn write_ops_py (
97- env : & Environment ,
98- name : & str ,
99- ops_name : & str ,
100- file_set : & mut FileSet ,
101- ) -> Result < ( ) > {
102- let mut path = PathBuf :: new ( ) ;
103- path. push ( "torch-ext" ) ;
104- path. push ( name) ;
105- path. push ( "_ops.py" ) ;
106- let writer = file_set. entry ( path) ;
107-
108- env. get_template ( "_ops.py" )
109- . wrap_err ( "Cannot get _ops.py template" ) ?
110- . render_to_write (
111- context ! {
112- ops_name => ops_name,
113- } ,
114- writer,
115- )
116- . wrap_err ( "Cannot render kernel template" ) ?;
117-
118- Ok ( ( ) )
119- }
120-
12197fn write_cmake (
12298 env : & Environment ,
12399 backend : Backend ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use minijinja::{context, Environment};
77use crate :: config:: { Backend , Build , Torch } ;
88use crate :: fileset:: FileSet ;
99use crate :: torch:: common:: write_metadata;
10+ use crate :: torch:: common:: write_ops_py;
1011use crate :: torch:: common:: write_pyproject_toml;
1112use crate :: torch:: common:: write_torch_registration_macros;
1213use crate :: torch:: kernel:: render_kernel_components;
@@ -188,31 +189,6 @@ fn render_preamble(
188189 Ok ( ( ) )
189190}
190191
191- fn write_ops_py (
192- env : & Environment ,
193- name : & str ,
194- ops_name : & str ,
195- file_set : & mut FileSet ,
196- ) -> Result < ( ) > {
197- let mut path = PathBuf :: new ( ) ;
198- path. push ( "torch-ext" ) ;
199- path. push ( name) ;
200- path. push ( "_ops.py" ) ;
201- let writer = file_set. entry ( path) ;
202-
203- env. get_template ( "_ops.py" )
204- . wrap_err ( "Cannot get _ops.py template" ) ?
205- . render_to_write (
206- context ! {
207- ops_name => ops_name,
208- } ,
209- writer,
210- )
211- . wrap_err ( "Cannot render kernel template" ) ?;
212-
213- Ok ( ( ) )
214- }
215-
216192fn write_setup_py (
217193 env : & Environment ,
218194 torch : & Torch ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use minijinja::{context, Environment};
88
99use crate :: config:: { Backend , Build , Dependency , Torch } ;
1010use crate :: torch:: common:: write_metadata;
11+ use crate :: torch:: common:: write_ops_py;
1112use crate :: torch:: common:: write_pyproject_toml;
1213use crate :: torch:: common:: write_torch_registration_macros;
1314use crate :: torch:: kernel:: render_kernel_components;
@@ -89,31 +90,6 @@ fn write_setup_py(
8990 Ok ( ( ) )
9091}
9192
92- fn write_ops_py (
93- env : & Environment ,
94- name : & str ,
95- ops_name : & str ,
96- file_set : & mut FileSet ,
97- ) -> Result < ( ) > {
98- let mut path = PathBuf :: new ( ) ;
99- path. push ( "torch-ext" ) ;
100- path. push ( name) ;
101- path. push ( "_ops.py" ) ;
102- let writer = file_set. entry ( path) ;
103-
104- env. get_template ( "_ops.py" )
105- . wrap_err ( "Cannot get _ops.py template" ) ?
106- . render_to_write (
107- context ! {
108- ops_name => ops_name,
109- } ,
110- writer,
111- )
112- . wrap_err ( "Cannot render _ops.py template" ) ?;
113-
114- Ok ( ( ) )
115- }
116-
11793fn write_cmake (
11894 env : & Environment ,
11995 build : & Build ,
You can’t perform that action at this time.
0 commit comments