API Documentation
#################

General
=======

.. currentmodule:: intel_extension_for_pytorch
.. autofunction:: optimize
.. autofunction:: optimize_transformers
.. autofunction:: get_fp32_math_mode
.. autofunction:: set_fp32_math_mode


Miscellaneous
=============

.. currentmodule:: intel_extension_for_pytorch.xpu
.. StreamContext
.. can_device_access_peer
.. current_blas_handle
.. autofunction:: current_device
.. autofunction:: current_stream
.. default_stream
.. autoclass:: device
.. autofunction:: device_count
.. autoclass:: device_of
.. autofunction:: get_device_name
.. autofunction:: get_device_properties
.. get_gencode_flags
.. get_sync_debug_mode
.. autofunction:: init
.. ipc_collect
.. autofunction:: is_available
.. autofunction:: is_initialized
.. memory_usage
.. autofunction:: set_device
.. set_stream
.. autofunction:: stream
.. autofunction:: synchronize

.. currentmodule:: intel_extension_for_pytorch.xpu.fp8.fp8
.. autofunction:: fp8_autocast


Random Number Generator
=======================

.. currentmodule:: intel_extension_for_pytorch.xpu
.. autofunction:: get_rng_state
.. autofunction:: get_rng_state_all
.. autofunction:: set_rng_state
.. autofunction:: set_rng_state_all
.. autofunction:: manual_seed
.. autofunction:: manual_seed_all
.. autofunction:: seed
.. autofunction:: seed_all
.. autofunction:: initial_seed

Streams and events
==================

.. currentmodule:: intel_extension_for_pytorch.xpu
.. autoclass:: Stream
    :members: 
.. ExternalStream
.. autoclass:: Event
    :members: 

Memory management
=================

.. currentmodule:: intel_extension_for_pytorch.xpu
.. autofunction:: empty_cache
.. list_gpu_processes
.. mem_get_info
.. autofunction:: memory_stats
.. autofunction:: memory_summary
.. autofunction:: memory_snapshot
.. autofunction:: memory_allocated
.. autofunction:: max_memory_allocated
.. reset_max_memory_allocated
.. autofunction:: memory_reserved
.. autofunction:: max_memory_reserved
.. set_per_process_memory_fraction
.. memory_cached
.. max_memory_cached
.. reset_max_memory_cached
.. autofunction:: reset_peak_memory_stats
.. caching_allocator_alloc
.. caching_allocator_delete

.. autofunction:: memory_stats_as_nested_dict
.. autofunction:: reset_accumulated_memory_stats

C++ API
=======

.. doxygenenum:: xpu::FP32_MATH_MODE

.. doxygenfunction:: xpu::set_fp32_math_mode

.. doxygenfunction:: xpu::get_queue_from_stream