MCPcopy Create free account
hub / github.com/pytorch/pytorch / _maybe_write

Function _maybe_write

torch/utils/cpp_extension.py:268–282  ·  view source on GitHub ↗

r''' Equivalent to writing the content into the file but will not touch the file if it already had the right content (to avoid triggering recompile).

(filename, new_content)

Source from the content-addressed store, hash-verified

266 return ['clang++', 'clang'] if IS_MACOS else ['g++', 'gcc', 'gnu-c++', 'gnu-cc', 'clang++', 'clang']
267
268def _maybe_write(filename, new_content):
269 r'''
270 Equivalent to writing the content into the file but will not touch the file
271 if it already had the right content (to avoid triggering recompile).
272 '''
273 if os.path.exists(filename):
274 with open(filename) as f:
275 content = f.read()
276
277 if content == new_content:
278 # The file already contains the right thing!
279 return
280
281 with open(filename, 'w') as source_file:
282 source_file.write(new_content)
283
284def get_default_build_root() -> str:
285 """

Callers 2

load_inlineFunction · 0.85
_write_ninja_fileFunction · 0.85

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…