Skip to content

Commit

Permalink
[src] Allow disabling script_if_tracing for ONNX export (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpariente authored Jul 30, 2022
1 parent 8a3d13f commit e15bb3f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion asteroid_filterbanks/scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
import torch


global SCRIPT_ENABLED
SCRIPT_ENABLED = True


def disable_script_if_tracing():
global SCRIPT_ENABLED
SCRIPT_ENABLED = False


def enable_script_if_tracing():
global SCRIPT_ENABLED
SCRIPT_ENABLED = True


def is_tracing():
# Taken for pytorch for compat in 1.6.0
"""
Expand Down Expand Up @@ -32,7 +46,7 @@ def script_if_tracing(fn):

@functools.wraps(fn)
def wrapper(*args, **kwargs):
if not is_tracing():
if not is_tracing() or not SCRIPT_ENABLED:
# Not tracing, don't do anything
return fn(*args, **kwargs)

Expand Down

0 comments on commit e15bb3f

Please sign in to comment.