torch.utils#
Created On: Jul 21, 2023 | Last Updated On: Dec 05, 2025
rename_privateuse1_backend |
Rename the privateuse1 backend device to make it more convenient to use as a device name within PyTorch APIs. |
generate_methods_for_privateuse1_backend |
Automatically generate attributes and methods for the custom backend after rename privateuse1 backend. |
get_cpp_backtrace |
Return a string containing the C++ stack trace of the current thread. |
set_module |
Set the module attribute on a python object for a given object for nicer printing |
swap_tensors |
This function swaps the content of the two Tensor objects. |
torch.utils.collect_env#
torch.utils.flop_counter#
baddbmm_flop |
Count flops for the baddbmm operation. |
bmm_flop |
Count flops for the bmm operation. |
conv_backward_flop |
|
conv_flop |
Count flops for convolution. |
conv_flop_count |
Count flops for convolution. |
register_flop_formula |
|
sdpa_backward_flop |
Count flops for self-attention backward. |
sdpa_backward_flop_count |
|
sdpa_flop |
Count flops for self-attention. |
sdpa_flop_count |
Count flops for self-attention. |
shape_wrapper |
torch.utils.hipify.hipify_python#
The Python Hipify script. ## # Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. # 2017-2018 Advanced Micro Devices, Inc. and # Facebook Inc. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE.
compute_stats |
|
extract_arguments |
Return the list of arguments in the upcoming function parameter closure. |
file_add_header |
|
file_specific_replacement |
|
find_bracket_group |
Finds the first balanced parentheses. |
find_closure_group |
Generalization for finding a balancing closure group |
find_parentheses_group |
Finds the first balanced bracket. |
fix_static_global_kernels |
Static global kernels in HIP results in a compilation error. |
hip_header_magic |
If the file makes kernel builtin calls and does not include the cuda_runtime.h header, then automatically add an #include to match the "magic" includes provided by NVCC. |
hipify |
|
is_caffe2_gpu_file |
|
is_cusparse_file |
|
is_out_of_place |
|
is_pytorch_file |
|
is_special_file |
|
openf |
|
preprocess_file_and_save_result |
|
preprocessor |
Executes the CUDA -> HIP conversion on the specified file. |
processKernelLaunches |
Replace the CUDA style Kernel launches with the HIP style kernel launches. |
replace_extern_shared |
Match 'extern __shared__ type foo[];' syntax and use HIP_DYNAMIC_SHARED() MACRO instead. |
replace_math_functions |
FIXME: Temporarily replace std:: invocations of math functions with non-std:: versions to prevent linker errors NOTE: This can lead to correctness issues when running tests, since the correct version of the math function (exp/expf) might not get called. |
str2bool |
ArgumentParser doesn't support type=bool. |