pytorch/tools
Joel Schlosser 5aac95c713 Introduce slice_inverse() op (#117041)
Introduces a new op `slice_inverse()`. This is used in the reverse view_func for slice and several other ops (e.g. `split_with_sizes`, `chunk`). It's implemented behind the scenes by a call to `as_strided()`, but it's easier for subclasses to implement the more limited `slice_inverse()` than the full `as_strided()`. This PR:
* Introduces the op itself
* Updates all relevant functional inverses to call `slice_inverse()` instead of `as_strided()` directly
* Makes codegen changes to allow `slice_scatter()` to be the copy variant for `slice_inverse()`
    * Need to avoid view_copy codegen (assumes if view name ends in inverse, we don't need to gen one, which is possibly a bad assumption)

@albanD / @soulitzer / @bdhirsh: I'm most interested in your thoughts on the codegen changes and whether this is the right way to go.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/117041
Approved by: https://github.com/bdhirsh
2024-01-16 23:44:54 +00:00
..
alerts
amd_build Re-add initial Flash Attention support on ROCM (#115981) 2024-01-04 22:21:31 +00:00
autograd Introduce slice_inverse() op (#117041) 2024-01-16 23:44:54 +00:00
bazel_tools
build/bazel
build_defs Fix buck OSS build after #115570 (#115804) 2023-12-14 08:33:07 +00:00
code_analyzer [BE]: Enable RUFF PERF402 and apply fixes (#115505) 2023-12-20 18:01:24 +00:00
code_coverage
config
coverage_plugins_package
dynamo
gdb
github
iwyu
jit
linter [BE] Use precompiled headers to speedup clang-tidy (#116780) 2024-01-04 18:37:44 +00:00
lite_interpreter
lldb
onnx
pyi Pyi doc inclusion + fix (#117267) 2024-01-15 13:06:53 +00:00
rules
rules_cc
setup_helpers
shared
stats
test [pt-vulkan] Enable Python code blocks in shader templates and upgrade shader template generation (#115948) 2023-12-20 05:47:33 +00:00
testing [ez][td] Pipe TD logs to log file (#116796) 2024-01-05 19:05:12 +00:00
__init__.py
bazel.bzl
BUCK.bzl
BUCK.oss
build_libtorch.py
build_pytorch_libs.py
build_with_debinfo.py [DevX] Add tool and doc on partial debug builds (#116521) 2023-12-29 05:15:35 +00:00
download_mnist.py
extract_scripts.py
gen_flatbuffers.sh
gen_vulkan_spv.py [pt-vulkan][ez] Replace ska::flat_hash_map, c10::get_hash with std::unordered_map, std::hash (#117177) 2024-01-11 21:43:15 +00:00
generate_torch_version.py
generated_dirs.txt
git_add_generated_dirs.sh
git_reset_generated_dirs.sh
nightly.py
nvcc_fix_deps.py
pytorch.version
README.md
render_junit.py
substitute.py
update_masked_docs.py
vscode_settings.py

This folder contains a number of scripts which are used as part of the PyTorch build process. This directory also doubles as a Python module hierarchy (thus the __init__.py).

Overview

Modern infrastructure:

  • autograd - Code generation for autograd. This includes definitions of all our derivatives.
  • jit - Code generation for JIT
  • shared - Generic infrastructure that scripts in tools may find useful.
    • module_loader.py - Makes it easier to import arbitrary Python files in a script, without having to add them to the PYTHONPATH first.

Build system pieces:

  • setup_helpers - Helper code for searching for third-party dependencies on the user system.
  • build_pytorch_libs.py - cross-platform script that builds all of the constituent libraries of PyTorch, but not the PyTorch Python extension itself.
  • build_libtorch.py - Script for building libtorch, a standalone C++ library without Python support. This build script is tested in CI.

Developer tools which you might find useful:

Important if you want to run on AMD GPU:

  • amd_build - HIPify scripts, for transpiling CUDA into AMD HIP. Right now, PyTorch and Caffe2 share logic for how to do this transpilation, but have separate entry-points for transpiling either PyTorch or Caffe2 code.
    • build_amd.py - Top-level entry point for HIPifying our codebase.

Tools which are only situationally useful: