mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Address jittering issues in python_print (#14064)
Summary:
export - print a method with python_print
import - import a method with import_method
We want to ensure:
export(g) == export(import(export(g)))
That is after after exporting/importing once, the graph will stay exactly
the same. This is less strict that g == import(export(g)) which would
require us to maintain a lot more information about the structure of the
IR and about the names of debug symbols.
This PR addresses this with the following fixes:
* print out double-precision numbers with high enough precision such
that they always parse in the same way
* when creating loop-carried dependencies, sort them
by variable name, ensuring a consistent order
* parse nan correctly
* DCE: remove unused outputs of if statements, and loop-carried dependencies
in loops that are dead both after the loop and inside the body of the
loop.
* Do not set uniqueName for variables whose names are _[0-9]+, these
are probably rare in user code, and we need a way to communicate
that we do not care about a variable name when re-parsing the graph.
Otherwise temporary variable names will jitter around.
* Expand the definition of a constant in printing code to None,
and family.
* Allow re-treeing to work as long as the only thing in its way is a
constant node. These do not have side effects but are sometimes
inserted in a different order when tracing compared to how we print them.
* Print all constant nodes out first in the order in which they are used_val
(or, if they are inlined, ensure they get assigned CONSTANT.cX number
in a consistent order). Cleanup tuples (this is done in the compiler,
but not in the tracer, leading to some tuple indexing jitter if not
done).
* use strtod_l, not std::stod which can throw exceptions
Other:
* Add REL_WITH_DEB_INFO to setup.py. It already existed for the
cmake files. Threading it into setup.py allows us to turn on
debug symbols with optimization everywhere.
* enable round trip testing for all generated graphs. This only adds
~6 seconds to total build time but tests printing for every graph.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14064
Differential Revision: D13094637
Pulled By: zdevito
fbshipit-source-id: 0a1c6912194d965f15d6b0c6cf838ccc551f161d
This commit is contained in:
committed by
Facebook Github Bot
parent
af82396f7f
commit
788d2e87bd
8
setup.py
8
setup.py
@ -5,6 +5,9 @@
|
||||
# DEBUG
|
||||
# build with -O0 and -g (debug symbols)
|
||||
#
|
||||
# REL_WITH_DEB_INFO
|
||||
# build with optimizations and -g (debug symbols)
|
||||
#
|
||||
# MAX_JOBS
|
||||
# maximum number of compile jobs we should use to compile your code
|
||||
#
|
||||
@ -189,6 +192,7 @@ from tools.setup_helpers.dist_check import USE_DISTRIBUTED, \
|
||||
################################################################################
|
||||
|
||||
DEBUG = check_env_flag('DEBUG')
|
||||
REL_WITH_DEB_INFO = check_env_flag('REL_WITH_DEB_INFO')
|
||||
IS_WINDOWS = (platform.system() == 'Windows')
|
||||
IS_DARWIN = (platform.system() == 'Darwin')
|
||||
IS_LINUX = (platform.system() == 'Linux')
|
||||
@ -835,6 +839,10 @@ if DEBUG:
|
||||
extra_compile_args += ['-O0', '-g']
|
||||
extra_link_args += ['-O0', '-g']
|
||||
|
||||
if REL_WITH_DEB_INFO:
|
||||
extra_compile_args += ['-g']
|
||||
extra_link_args += ['-g']
|
||||
|
||||
|
||||
def make_relative_rpath(path):
|
||||
if IS_DARWIN:
|
||||
|
||||
Reference in New Issue
Block a user