mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Preferring dash over underscore in command-line options. Add `--command-arg-name` to the argument parser. The old arguments with underscores `--command_arg_name` are kept for backward compatibility.
Both dashes and underscores are used in the PyTorch codebase. Some argument parsers only have dashes or only have underscores in arguments. For example, the `torchrun` utility for distributed training only accepts underscore arguments (e.g., `--master_port`). The dashes are more common in other command-line tools. And it looks to be the default choice in the Python standard library:
`argparse.BooleanOptionalAction`: 4a9dff0e5a/Lib/argparse.py (L893-L895)
```python
class BooleanOptionalAction(Action):
def __init__(...):
if option_string.startswith('--'):
option_string = '--no-' + option_string[2:]
_option_strings.append(option_string)
```
It adds `--no-argname`, not `--no_argname`. Also typing `_` need to press the shift or the caps-lock key than `-`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94505
Approved by: https://github.com/ezyang, https://github.com/seemethere
42 lines
1.1 KiB
Bash
42 lines
1.1 KiB
Bash
OUTFILE=spmm-no-mkl-test.txt
|
|
PYTORCH_HOME=$1
|
|
|
|
cd $PYTORCH_HOME
|
|
|
|
echo "" >> $OUTFILE
|
|
echo "----- USE_MKL=1 -----" >> $OUTFILE
|
|
rm -rf build
|
|
|
|
export USE_MKL=1
|
|
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
|
|
python setup.py build --cmake-only
|
|
ccmake build # or cmake-gui build
|
|
|
|
python setup.py install
|
|
|
|
cd benchmarks
|
|
echo "!! SPARSE SPMM TIME BENCHMARK!! " >> $OUTFILE
|
|
for dim0 in 1000 5000 10000; do
|
|
for nnzr in 0.01 0.05 0.1 0.3; do
|
|
python -m sparse.spmm --format csr --m $dim0 --n $dim0 --k $dim0 --nnz-ratio $nnzr --outfile $OUTFILE
|
|
# python -m sparse.spmm --format coo --m $dim0 --n $dim0 --k $dim0 --nnz-ratio $nnzr --outfile $OUTFILE
|
|
done
|
|
done
|
|
echo "----------------------" >> $OUTFILE
|
|
|
|
cd $PYTORCH_HOME
|
|
echo "----- USE_MKL=0 ------" >> $OUTFILE
|
|
rm -rf build
|
|
|
|
export USE_MKL=0
|
|
python setup.py install
|
|
|
|
cd benchmarks
|
|
for dim0 in 1000 5000 10000; do
|
|
for nnzr in 0.01 0.05 0.1 0.3; do
|
|
python -m sparse.spmv --format csr --m $dim0 --nnz-ratio $nnzr --outfile $OUTFILE
|
|
python -m sparse.spmv --format coo --m $dim0 --nnz-ratio $nnzr --outfile $OUTFILE
|
|
done
|
|
done
|
|
echo "----------------------" >> $OUTFILE
|