@@ -81,6 +81,24 @@ def train():
8181 return train
8282
8383
84+ def _forward_with_fixed_radius_graph (
85+ model_module ,
86+ module ,
87+ data ,
88+ edge_index ,
89+ ):
90+ original_radius_graph = model_module .radius_graph
91+
92+ def fixed_radius_graph (* _args , ** _kwargs ):
93+ return edge_index
94+
95+ model_module .radius_graph = fixed_radius_graph
96+ try :
97+ return module (data )
98+ finally :
99+ model_module .radius_graph = original_radius_graph
100+
101+
84102def build_spherical_harmonics (config : dict [str , Any ]) -> Task :
85103 torch , o3 = _imports ()
86104 vectors = torch .randn (config ["items" ], 3 , requires_grad = True )
@@ -141,7 +159,9 @@ def build_fully_connected_tensor_product(config: dict[str, Any]) -> Task:
141159 module = o3 .FullyConnectedTensorProduct (irreps , irreps , irreps )
142160 left = torch .randn (config ["items" ], irreps .dim )
143161 right = torch .randn (config ["items" ], irreps .dim )
144- forward = lambda : module (left , right )
162+ def forward ():
163+ return module (left , right )
164+
145165 return _task (
146166 name = "fully_connected_tensor_product" ,
147167 config = config ,
@@ -212,7 +232,9 @@ def build_linear(config: dict[str, Any]) -> Task:
212232 irreps = o3 .Irreps (spherical_irreps (config ["mul" ], config ["lmax" ]))
213233 module = o3 .Linear (irreps , irreps )
214234 values = torch .randn (config ["items" ], irreps .dim )
215- forward = lambda : module (values )
235+ def forward ():
236+ return module (values )
237+
216238 return _task (
217239 name = "linear" ,
218240 config = config ,
@@ -267,7 +289,7 @@ def _model_graph(config, *, input_dim, node_attr_dim=0, edge_attr_dim=0):
267289
268290
269291def build_gate_points_2102 (config : dict [str , Any ]) -> Task :
270- torch , o3 = _imports ()
292+ _ , o3 = _imports ()
271293 import e3nn .nn .models .gate_points_2102 as model_module
272294
273295 irreps_in = o3 .Irreps ("4x0e" )
@@ -297,14 +319,20 @@ def build_gate_points_2102(config: dict[str, Any]) -> Task:
297319 input_dim = irreps_in .dim ,
298320 node_attr_dim = irreps_node_attr .dim ,
299321 )
300- model_module .radius_graph = lambda _pos , _radius , _batch : edge_index
301322 data = {
302323 "pos" : positions ,
303324 "x" : node_input ,
304325 "z" : node_attr ,
305326 "batch" : batch ,
306327 }
307- forward = lambda : module (data )
328+ def forward ():
329+ return _forward_with_fixed_radius_graph (
330+ model_module ,
331+ module ,
332+ data ,
333+ edge_index ,
334+ )
335+
308336 return _task (
309337 name = "gate_points_2102" ,
310338 config = config ,
@@ -315,7 +343,7 @@ def build_gate_points_2102(config: dict[str, Any]) -> Task:
315343
316344
317345def build_v2106_simple_network (config : dict [str , Any ]) -> Task :
318- torch , o3 = _imports ()
346+ _ , o3 = _imports ()
319347 import e3nn .nn .models .v2106 .gate_points_networks as model_module
320348
321349 irreps_in = o3 .Irreps ("4x0e" )
@@ -334,9 +362,16 @@ def build_v2106_simple_network(config: dict[str, Any]) -> Task:
334362 config ,
335363 input_dim = irreps_in .dim ,
336364 )
337- model_module .radius_graph = lambda _pos , _radius , _batch : edge_index
338365 data = {"pos" : positions , "x" : node_input , "batch" : batch }
339- forward = lambda : module (data )
366+
367+ def forward ():
368+ return _forward_with_fixed_radius_graph (
369+ model_module ,
370+ module ,
371+ data ,
372+ edge_index ,
373+ )
374+
340375 return _task (
341376 name = "v2106_simple_network" ,
342377 config = config ,
@@ -347,7 +382,7 @@ def build_v2106_simple_network(config: dict[str, Any]) -> Task:
347382
348383
349384def build_v2106_attributed_network (config : dict [str , Any ]) -> Task :
350- torch , o3 = _imports ()
385+ _ , o3 = _imports ()
351386 from e3nn .nn .models .v2106 .gate_points_networks import (
352387 NetworkForAGraphWithAttributes ,
353388 )
@@ -382,7 +417,9 @@ def build_v2106_attributed_network(config: dict[str, Any]) -> Task:
382417 "edge_index" : edge_index ,
383418 "batch" : batch ,
384419 }
385- forward = lambda : module (data )
420+ def forward ():
421+ return module (data )
422+
386423 return _task (
387424 name = "v2106_attributed_network" ,
388425 config = config ,
0 commit comments