File: standalone_compile.sh

package info (click to toggle)
pytorch-cuda 2.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 161,620 kB
  • sloc: python: 1,278,832; cpp: 900,322; ansic: 82,710; asm: 7,754; java: 3,363; sh: 2,811; javascript: 2,443; makefile: 597; ruby: 195; xml: 84; objc: 68
file content (26 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

if [ -z "$CXX" ]; then
    CXX="clang++"
    echo "Using system default C++ compiler: $CXX"
else
    echo "Using user-provided C++ compiler: $CXX"
fi

if [ -z "$TORCH_ROOT_DIR" ]; then
    echo "Error: The TORCH_ROOT_DIR environment variable must be set." >&2
    echo "Example: export TORCH_ROOT_DIR=/home/$USER/local/pytorch" >&2
    exit 1
fi

if [ $# -lt 2 ]; then
    echo "Usage: $0 <input file path> <output file path>."
    echo "Example Usage: $0 standalone_test.cpp standalone_test.out."
    exit 1
fi

# Building the wrapper
$CXX -I$TORCH_ROOT_DIR/build/aten/src -I$TORCH_ROOT_DIR/aten/src -I$TORCH_ROOT_DIR/build -I$TORCH_ROOT_DIR -I$TORCH_ROOT_DIR/build/caffe2/aten/src -I$TORCH_ROOT_DIR/torch/csrc/api -I$TORCH_ROOT_DIR/torch/csrc/api/include -std=gnu++17 -fPIE -o $1.o -c $1

# Linking
$CXX -rdynamic -Wl,--no-as-needed,$TORCH_ROOT_DIR/build/lib/libtorch.so $1.o -Wl,--no-as-needed,$TORCH_ROOT_DIR/build/lib/libtorch_cpu.so -Wl,--no-as-needed,$TORCH_ROOT_DIR/build/lib/libc10.so -o $2