File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
tests/keras2onnx_unit_tests Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 15
15
def is_keras_3 ():
16
16
return tf .__version__ .startswith ("2.18" ) or tf .__version__ .startswith ("2.17" ) or tf .__version__ .startswith ("2.16" )
17
17
18
- if is_keras_3 ():
19
- import tf_keras
20
- K = tf_keras .backend
21
-
22
18
@pytest .fixture (scope = 'function' )
23
19
def runner ():
24
20
np .random .seed (42 )
@@ -31,10 +27,15 @@ def runner():
31
27
def runner_func (* args , ** kwargs ):
32
28
return run_onnx_runtime (* args , model_files , ** kwargs )
33
29
34
- # Ensure Keras layer naming is reset for each function
35
- K .reset_uids ()
36
- # Reset the TensorFlow session to avoid resource leaking between tests
37
- K .clear_session ()
30
+ if is_keras_3 ():
31
+ import tf_keras
32
+ tf_keras .backend .reset_uids ()
33
+ tf_keras .backend .clear_session ()
34
+ else :
35
+ # Ensure Keras layer naming is reset for each function
36
+ K .reset_uids ()
37
+ # Reset the TensorFlow session to avoid resource leaking between tests
38
+ K .clear_session ()
38
39
39
40
# Provide wrapped run_onnx_runtime function
40
41
yield runner_func
You can’t perform that action at this time.
0 commit comments