pytorch/torch/csrc/jit/tensorexpr
Zhenghao Hu e5fccb2bab [pytorch] Fix duplicated Malloc/Free insertation when using IRBuilderBase::CreateMalloc/CreateFree in LLVM 18+ (#149058)
Summary:
Pytorch unitest hangs when jitting the Tensor kernel. The problem exists for LLVM version >= 18 due to this upstream change: 45bb45f2ae

`IRBuilderBase::CreateCall` will insert the instruction into the BasicBlock by default. And we don't need to explicitly insert the instruction when compiling the tensor kernel.

Test Plan:
## Test with the release toolchain
```
buck test 'mode/dev' //caffe2/test:jit -- --exact 'caffe2/test:jit - test_concat_invariant (test_jit_fuser_te.TestTEFuserDynamic)'
```
## Test with the Buckified toolchain
Apply this D71046097 to select the LLVM libraries.
```
# Build tests
buck build 'mode/dev-asan' //caffe2/test:jit --show-output
```
```
# Run test (Change HASH and paths accordingly)
HASH="b755f1c435832a1e"

ENABLE_FLATBUFFER=0 FB_OVERRIDE_PYBIND11_GIL_INCREF_DECREF_CHECK=1 MKL_NUM_THREADS=1 NO_MULTIPROCESSING_SPAWN=0 OMP_NUM_THREADS=1 PYTORCH_TEST=1 PYTORCH_TEST_FBCODE=1 PYTORCH_TEST_WITH_ASAN=1 PYTORCH_TEST_WITH_DEV_DBG_ASAN=1 PYTORCH_TEST_WITH_TSAN=0 PYTORCH_TEST_WITH_UBSAN=1 SKIP_TEST_BOTTLENECK=1 TENSORPIPE_TLS_DATACENTER=test_dc TEST_PILOT=True TPX_IS_TEST_EXECUTION=true TPX_TIMEOUT_SEC=6000 \
buck-out/v2/gen/$HASH/caffe2/test/__jit__/jit.par --test-filter test_jit_fuser_te.TestTEFuserDynamic.test_concat_invariant
```

Differential Revision: D71046799

Pull Request resolved: https://github.com/pytorch/pytorch/pull/149058
Approved by: https://github.com/dcci, https://github.com/Skylion007
2025-03-13 20:37:47 +00:00
..
operators Fix NOLINTNEXTLINE (#141794) 2024-12-02 19:22:00 +00:00
scripts
analysis.h
block_codegen.cpp
block_codegen.h
bounds_inference.cpp
bounds_inference.h Concat namespaces in jit code (#138976) 2024-10-26 17:41:27 +00:00
bounds_overlap.cpp
bounds_overlap.h Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
codegen_external.py
codegen.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
codegen.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ConditionalsInTE.md
cpp_codegen.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
cpp_codegen.h
cpp_intrinsics.h Concat namespaces in jit code (#138976) 2024-10-26 17:41:27 +00:00
cuda_codegen.cpp
cuda_codegen.h
cuda_random.h Concat namespaces in jit code (#138976) 2024-10-26 17:41:27 +00:00
eval.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
eval.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
exceptions.h
expr.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
expr.h Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
external_functions_codegen.cpp
external_functions_core.cpp
external_functions_core.h
external_functions_registry.cpp
external_functions_registry.h
external_functions.cpp Fix NOLINTNEXTLINE (#141794) 2024-12-02 19:22:00 +00:00
external_functions.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
fwd_decls.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
graph_opt.cpp
graph_opt.h
half_support.h
hash_provider.cpp
hash_provider.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
intrinsic_symbols.cpp
intrinsic_symbols.h
ir_cloner.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir_cloner.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir_mutator.cpp Fix NOLINTNEXTLINE (#141794) 2024-12-02 19:22:00 +00:00
ir_mutator.h Fix Wextra-semi warnings (#139000) 2024-10-28 21:48:51 +00:00
ir_printer.cpp Fix floating point literals in IRPrinter (#142119) 2024-12-18 21:59:48 +00:00
ir_printer.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir_simplifier.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir_simplifier.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir_verifier.cpp
ir_verifier.h Concat namespaces in jit code (#138976) 2024-10-26 17:41:27 +00:00
ir_visitor.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir_visitor.h
ir.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
ir.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
IRSpecification.md
kernel.cpp Remove unnecessary tensor clone (#148159) 2025-03-02 16:21:39 +00:00
kernel.h
llvm_codegen.cpp [pytorch] Fix duplicated Malloc/Free insertation when using IRBuilderBase::CreateMalloc/CreateFree in LLVM 18+ (#149058) 2025-03-13 20:37:47 +00:00
llvm_codegen.h
llvm_jit.cpp [caffe2/torch] Fixup upstream LLVM (major version 21) API changes (#148833) 2025-03-09 18:58:36 +00:00
llvm_jit.h
loopnest_randomization.cpp Fix clang-tidy warnings in torch/jit (#146963) 2025-02-15 03:36:59 +00:00
loopnest_randomization.h
loopnest.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
loopnest.h
lowerings.cpp Fix NOLINTNEXTLINE (#141794) 2024-12-02 19:22:00 +00:00
lowerings.h
mem_dependency_checker.cpp
mem_dependency_checker.h
reduction.cpp
reduction.h
registerizer.cpp [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
registerizer.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
stmt.h
tensor.cpp
tensor.h
tensorexpr_init.cpp
tensorexpr_init.h
types.cpp Fix NOLINTNEXTLINE (#141794) 2024-12-02 19:22:00 +00:00
types.h [6/N] Fix Wextra-semi warning (#139605) 2024-11-04 13:43:16 +00:00
unique_name_manager.cpp
unique_name_manager.h
var_substitutor.h