pytorch/tools/code_analyzer/run_analyzer.sh
Jiakai Liu f92089b8ca [pytorch] tweak code analyzer script to handle new namespaces (#40276)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40276

- add a couple new namespaces;
- handle the case where both contextual namespace and opreator namespace
  are set (BackendSelectRegister.cpp and #39401);
- improve error message;

Test Plan: Imported from OSS

Differential Revision: D22135686

Pulled By: ljk53

fbshipit-source-id: 14d359c93573349b8fe1e05d7e44d875295a5f6d
2020-06-19 14:54:21 -07:00

29 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
##############################################################################
# Invoke code analyzer binary with pre-defined parameters for LibTorch.
# This script should be called via build.sh. Do NOT use it directly.
##############################################################################
set -exu
echo "Analyze: ${INPUT}"
# NB: op_register_pattern actually contains "too" many entries. We only
# need to regex for symbols which occur after inlining; and most of the
# public API for the registration API disappears after inlining (e.g.,
# only _def and _impl are retained). But the inliner isn't guaranteed
# to operate, so for safety we match a more expansive set.
"${ANALYZER_BIN}" \
-op_schema_pattern="^(_aten|_prim|aten|quantized|_quantized|prepacked|profiler|_test)::[a-zA-Z0-9_.]+(\(.*)?$" \
-op_register_pattern="c10::RegisterOperators::(op|checkSchemaAndRegisterOp_)|c10::Module::(_?def|_?impl|impl_UNBOXED)|torch::Library::(_?def|_?impl|_?impl_UNBOXED)" \
-op_invoke_pattern="c10::Dispatcher::findSchema" \
-root_symbol_pattern="torch::jit::[^(]" \
-torch_library_init_pattern="^.*TORCH_LIBRARY_init_([^(]+)(\(.*)?$" \
-torch_library_init_pattern="^.*TORCH_LIBRARY_FRAGMENT_init_([^(]+)(\(.*)?$" \
-torch_library_init_pattern="^.*TORCH_LIBRARY_IMPL_init_([^(]+)_([^_]+)(\(.*)?$" \
${EXTRA_ANALYZER_FLAGS} \
"${INPUT}" \
> "${OUTPUT}"
echo "Result: ${OUTPUT}"