Rate this Page

torch.compiler.assume_constant_result#

torch.compiler.assume_constant_result(fn)[source]#

This function is used to mark a function fn as having a constant result. This allows the compiler to optimize away your function. Returns The same function fn

Parameters

fn – The function to be marked as having a constant result.

Warning

assume_constant_result can if invalid cause safety and soundness issues, torch.compile() will not attempt to validate whether the constant assumption is true or not