mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
Move hipify to torch/utils to bundle them into torch package (#27425)
Summary: Similar to https://github.com/pytorch/pytorch/pull/27418 but try to put it under "torch" namespace Pull Request resolved: https://github.com/pytorch/pytorch/pull/27425 Differential Revision: D17779490 Pulled By: bddppq fbshipit-source-id: 688338d143509b37dfc110df17af3331db48a42b
This commit is contained in:
parent
ce16d689b3
commit
4bd8ae13c6
2
.flake8
2
.flake8
|
|
@ -11,4 +11,4 @@ ignore =
|
|||
B007,B008,
|
||||
# these ignores are from flake8-comprehensions; please fix!
|
||||
C400,C401,C402,C403,C404,C405,C407,C411,
|
||||
exclude = docs/src,venv,third_party,caffe2,scripts,docs/caffe2,tools/amd_build/pyHIPIFY,torch/lib/include,torch/lib/tmp_install,build,torch/include,*.pyi
|
||||
exclude = docs/src,venv,third_party,caffe2,scripts,docs/caffe2,torch/lib/include,torch/lib/tmp_install,build,torch/include,*.pyi
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace c10 { namespace hip {
|
|||
// we switch PyTorch to calling a HIP a HIP.
|
||||
//
|
||||
// When you add a new MasqueradingAsCUDA class/function, you need to
|
||||
// also update the rewrite rules in tools/amd_build/pyHIPIFY/cuda_to_hip_mappings.py
|
||||
// also update the rewrite rules in torch/utils/hipify/cuda_to_hip_mappings.py
|
||||
//
|
||||
//
|
||||
//
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ configure_file(
|
|||
# transitively passed on to all libraries dependent on PyTorch.
|
||||
|
||||
# Note: if you add a new source file/header, you will need to update
|
||||
# tools/amd_build/pyHIPIFY/cuda_to_hip_mappings.py for new files
|
||||
# torch/utils/hipify/cuda_to_hip_mappings.py for new files
|
||||
# and headers you add
|
||||
set(C10_CUDA_SRCS
|
||||
CUDAStream.cpp
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void my_func();
|
|||
```
|
||||
|
||||
Thus, if you add new functionality to c10, you must also update `C10_MAPPINGS`
|
||||
`tools/amd_build/pyHIPIFY/cuda_to_hip_mappings.py` to transpile
|
||||
`torch/utils/hipify/cuda_to_hip_mappings.py` to transpile
|
||||
occurrences of `cuda::my_func` to `hip::my_func`. (At the moment,
|
||||
we do NOT have a catch all `cuda::` to `hip::` namespace conversion,
|
||||
as not all `cuda` namespaces are converted to `hip::`, even though
|
||||
|
|
|
|||
|
|
@ -570,5 +570,10 @@ class TestHub(TestCase):
|
|||
SUM_OF_HUB_EXAMPLE)
|
||||
|
||||
|
||||
class TestHipify(TestCase):
|
||||
def test_import_hipify(self):
|
||||
from torch.utils.hipify import hipify_python # noqa
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_tests()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,16 @@ from __future__ import absolute_import, division, print_function
|
|||
import os
|
||||
import subprocess
|
||||
import argparse
|
||||
import sys
|
||||
sys.path.append(os.path.realpath(os.path.join(
|
||||
__file__,
|
||||
os.path.pardir,
|
||||
os.path.pardir,
|
||||
os.path.pardir,
|
||||
'torch',
|
||||
'utils')))
|
||||
|
||||
from pyHIPIFY import hipify_python
|
||||
from hipify import hipify_python
|
||||
|
||||
parser = argparse.ArgumentParser(description='Top-level script for HIPifying, filling in most common parameters')
|
||||
parser.add_argument(
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
8083
torch/utils/hipify/cuda_to_hip_mappings.py
Normal file
8083
torch/utils/hipify/cuda_to_hip_mappings.py
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -32,9 +32,9 @@ import shutil
|
|||
import sys
|
||||
import os
|
||||
|
||||
from pyHIPIFY import constants
|
||||
from pyHIPIFY.cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
|
||||
from pyHIPIFY.cuda_to_hip_mappings import MATH_TRANSPILATIONS
|
||||
from . import constants
|
||||
from .cuda_to_hip_mappings import CUDA_TO_HIP_MAPPINGS
|
||||
from .cuda_to_hip_mappings import MATH_TRANSPILATIONS
|
||||
|
||||
# Hardcode the PyTorch template map
|
||||
"""This dictionary provides the mapping from PyTorch kernel template types
|
||||
|
|
@ -366,9 +366,13 @@ RE_ASSERT = re.compile(r"\bassert[ ]*\(")
|
|||
|
||||
|
||||
def replace_math_functions(input_string):
|
||||
""" 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.
|
||||
Plan is to remove this function once HIP supports std:: math function calls inside device code
|
||||
"""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. Plan is to remove this function once HIP supports
|
||||
std:: math function calls inside device code
|
||||
|
||||
"""
|
||||
output_string = input_string
|
||||
for func in MATH_TRANSPILATIONS:
|
||||
Loading…
Reference in New Issue
Block a user