-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIPC] Add scripts for npu and xpu, test=develop #3377
Changes from 4 commits
260c2a2
40138aa
e076e13
ea95055
5715e20
05b9d37
cf66a7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,13 @@ def parse_args(): | |
type=str, | ||
help="The eos token. It should be provided when use custom vocab_file. " | ||
) | ||
parser.add_argument( | ||
"--device", | ||
default="gpu", | ||
choices=["gpu", "cpu", "xpu", "npu"], | ||
help="Device selected for inference." | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add arguement "--device" to enable npu/xpu |
||
args = parser.parse_args() | ||
return args | ||
|
||
|
@@ -83,6 +90,10 @@ def post_process_seq(seq, bos_idx, eos_idx, output_bos=False, output_eos=False): | |
def do_predict(args): | ||
if args.device == "gpu": | ||
place = "gpu" | ||
elif args.device == "xpu": | ||
place = "xpu" | ||
elif args.device == "npu": | ||
place = "npu" | ||
else: | ||
place = "cpu" | ||
|
||
|
@@ -157,6 +168,7 @@ def do_predict(args): | |
args.unk_token = ARGS.unk_token | ||
args.bos_token = ARGS.bos_token | ||
args.eos_token = ARGS.eos_token | ||
args.device = ARGS.device | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. transform ARGS.device to args.device |
||
pprint(args) | ||
|
||
do_predict(args) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
source test_tipc/common_func.sh | ||
|
||
function readlinkf() { | ||
perl -MCwd -e 'print Cwd::abs_path shift' "$1"; | ||
} | ||
|
||
function func_parser_config() { | ||
strs=$1 | ||
IFS=" " | ||
array=(${strs}) | ||
tmp=${array[2]} | ||
echo ${tmp} | ||
} | ||
|
||
BASEDIR=$(dirname "$0") | ||
REPO_ROOT_PATH=$(readlinkf ${BASEDIR}/../) | ||
|
||
FILENAME=$1 | ||
|
||
# change gpu to npu in tipc txt configs | ||
sed -i "s/--device:gpu/--device:npu/g" $FILENAME | ||
sed -i "s/state=GPU/state=NPU/g" $FILENAME | ||
sed -i "s/trainer:pact_train/trainer:norm_train/g" $FILENAME | ||
sed -i "s/trainer:fpgm_train/trainer:norm_train/g" $FILENAME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change "pact_train" or "fpgm_train" to "norm_train" |
||
sed -i "s/--device:cpu|gpu/--device:cpu|npu/g" $FILENAME | ||
sed -i "s/--device:gpu|cpu/--device:cpu|npu/g" $FILENAME | ||
sed -i "s/--benchmark:True/--benchmark:False/g" $FILENAME | ||
sed -i "s/--use_tensorrt:False|True/--use_tensorrt:False/g" $FILENAME | ||
sed -i 's/\"gpu\"/\"npu\"/g' test_tipc/test_train_inference_python.sh | ||
|
||
# parser params | ||
dataline=`cat $FILENAME` | ||
IFS=$'\n' | ||
lines=(${dataline}) | ||
|
||
# pass parameters to test_train_inference_python.sh | ||
cmd="bash test_tipc/test_train_inference_python.sh ${FILENAME} $2" | ||
echo $cmd | ||
eval $cmd | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
source test_tipc/common_func.sh | ||
|
||
function readlinkf() { | ||
perl -MCwd -e 'print Cwd::abs_path shift' "$1"; | ||
} | ||
|
||
function func_parser_config() { | ||
strs=$1 | ||
IFS=" " | ||
array=(${strs}) | ||
tmp=${array[2]} | ||
echo ${tmp} | ||
} | ||
|
||
BASEDIR=$(dirname "$0") | ||
REPO_ROOT_PATH=$(readlinkf ${BASEDIR}/../) | ||
|
||
FILENAME=$1 | ||
|
||
# change gpu to npu in tipc txt configs | ||
sed -i "s/--device:gpu/--device:xpu/g" $FILENAME | ||
sed -i "s/state=GPU/state=XPU/g" $FILENAME | ||
sed -i "s/trainer:pact_train/trainer:norm_train/g" $FILENAME | ||
sed -i "s/trainer:fpgm_train/trainer:norm_train/g" $FILENAME | ||
sed -i "s/--device:cpu|gpu/--device:cpu|xpu/g" $FILENAME | ||
sed -i "s/--device:gpu|cpu/--device:cpu|xpu/g" $FILENAME | ||
sed -i "s/--benchmark:True/--benchmark:False/g" $FILENAME | ||
sed -i "s/--use_tensorrt:False|True/--use_tensorrt:False/g" $FILENAME | ||
sed -i 's/\"gpu\"/\"npu\"/g' test_tipc/test_train_inference_python.sh | ||
|
||
# parser params | ||
dataline=`cat $FILENAME` | ||
IFS=$'\n' | ||
lines=(${dataline}) | ||
|
||
# pass parameters to test_train_inference_python.sh | ||
cmd="bash test_tipc/test_train_inference_python.sh ${FILENAME} $2" | ||
echo $cmd | ||
eval $cmd | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add npu device