Table of Contents
Shortcuts

# torch.compiler.assume_constant_result

torch.compiler.assume_constant_result(fn)

  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

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.