I have code like
if condition:
do foo
else:
do bla
do foo
is not compileable, but when using torch.compile I’m never going to enter that code path anyways. Is there a way of letting the compiler know that?
I have code like
if condition:
do foo
else:
do bla
do foo
is not compileable, but when using torch.compile I’m never going to enter that code path anyways. Is there a way of letting the compiler know that?
You could try to use torch.compiler.disable
as described here.
I saw that but that seems to just allow for decorating functions? I see now it says
here it’s also a context manager so let me using it like that.
ok that doesnt work guess i have to put it in a different function
I might be misunderstanding - but if you want to ensure that foo()
is only executed when running with eager, and not when running with torch.compile
, you can do:
if torch.compiler.is_compiling():
return bla()
else:
return foo()