diff --git a/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_full_1p.sh index fe078086b4be5cfdcd83852e6faf6ba96d8d7899..105c5916b21f2f1d815ab410a1454a6488e5c09a 100644 --- a/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_full_1p.sh @@ -17,6 +17,7 @@ learning_rate= #参数配置 data_path=$cur_path +dynamic_input="1" if [[ $1 == --help || $1 == --h ]];then echo "usage:./train_full_1p.sh --data_path=../" @@ -27,6 +28,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -62,6 +65,7 @@ nohup python3 train.py \ --epochs ${train_epochs} \ --data-dir $data_path/pascal-voc \ --vgg-dir $data_path/vgg_graph \ + --dynamic_input ${dynamic_input} \ "${@:1}" > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait @@ -117,3 +121,4 @@ echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_performance_1p.sh index 0004076aa3695ba342771864a8ae6c77b1649e99..2c004af3bd140ab20091a95601a9dce5a3432593 100644 --- a/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/test/train_performance_1p.sh @@ -19,6 +19,7 @@ learning_rate= #参数配置 data_path=$cur_path +dynamic_input="1" if [[ $1 == --help || $1 == --h ]];then echo "usage:./train_performance_1p.sh --data_path=../" @@ -29,6 +30,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -64,6 +67,7 @@ nohup python3 train.py \ --epochs ${train_epochs} \ --data-dir $data_path/pascal-voc \ --vgg-dir $data_path/vgg_graph \ + --dynamic_input ${dynamic_input} \ "${@:1}" > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait @@ -118,3 +122,4 @@ echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/train.py b/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/train.py index 10fd58af0692b3eba416b77cedb4942a597cf492..822a1beaf6ecddc52160eef119808ce0e6507d14 100644 --- a/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/train.py +++ b/TensorFlow/built-in/cv/detection/SSD-VGG_ID1619_for_TensorFlow/train.py @@ -107,7 +107,9 @@ def main(): parser.add_argument('--dump_path', type=str, default='/home/HwHiAiUser/', help='dump path') parser.add_argument('--data_path', type=str, default='./', - help='data path') + help='data path') + parser.add_argument("--dynamic_input", type=str, default='1', + help="--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph") #****** npu modify end ****** args = parser.parse_args() @@ -130,6 +132,7 @@ def main(): print('[i] Overflow dump flag: ', args.over_dump) print('[i] data dump flag: ', args.data_dump) print('[i] Dump path: ', args.dump_path) + print('[i] dynamic_input: ', args.dynamic_input) #****** npu modify end ****** #--------------------------------------------------------------------------- # Find an existing checkpoint @@ -205,7 +208,12 @@ def main(): custom_op.name = "NpuOptimizer" custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") custom_op.parameter_map["dynamic_input"].b = 1 - custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + if args.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + elif args.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") + else: + print("Enter correct compilation parameters.") custom_op.parameter_map["use_off_line"].b = True custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes(args.precision_mode) if args.over_dump: diff --git a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/TrainResNet.py b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/TrainResNet.py index 46f51c5a8a75e624f7d7703e3af3d1c184c83176..b184e85ea086bdde820e360916b63f95e0a31aa2 100644 --- a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/TrainResNet.py +++ b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/TrainResNet.py @@ -56,16 +56,17 @@ from scipy import misc from utils import * def parse_args(): - desc = "MAIN" - parser = argparse.ArgumentParser(description=desc) - parser.add_argument('--label_path', type=str, default='./label/label_1200.npy', help='Path of Label.npy') - parser.add_argument('--image_name_path', type=str, default='./label/name_1200.npy', help='Path of image file names') - ############################add train_data_path################################## - parser.add_argument('--train_data_path', type=str, default='./train_data/1200_data.npy', help='Path of train data') - ############################add train_data_path################################## - parser.add_argument('--parentPath', type=str, default='./CACD2000_Crop/', help='image path') - parser.add_argument('--epochs', type=int, default=100, help='NUM_EPOCHS') - return parser.parse_args() + desc = "MAIN" + parser = argparse.ArgumentParser(description=desc) + parser.add_argument('--dynamic_input', type=str, default='1', help='--dynamic_input=1 Use fuzzy compilation --dynamic_input=lazy_recompile Compile using lazy static graph') + parser.add_argument('--label_path', type=str, default='./label/label_1200.npy', help='Path of Label.npy') + parser.add_argument('--image_name_path', type=str, default='./label/name_1200.npy', help='Path of image file names') + ############################add train_data_path################################## + parser.add_argument('--train_data_path', type=str, default='./train_data/1200_data.npy', help='Path of train data') + ############################add train_data_path################################## + parser.add_argument('--parentPath', type=str, default='./CACD2000_Crop/', help='image path') + parser.add_argument('--epochs', type=int, default=100, help='NUM_EPOCHS') + return parser.parse_args() args = parse_args() # image size @@ -145,7 +146,12 @@ def Train(epochs=100): custom_op = global_config.graph_options.rewrite_options.custom_optimizers.add() custom_op.name = "NpuOptimizer" custom_op.parameter_map["dynamic_input"].b = 1 - custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + if args.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + elif args.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") + else: + print("Enter correct compilation parameters.") global_config.graph_options.rewrite_options.remapping = RewriterConfig.OFF global_config.graph_options.rewrite_options.memory_optimization = RewriterConfig.OFF #with tf.Session() as sess: diff --git a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh index 33673edf993d910f76dad4120f6dc90e3a4a90fb..2c86cd50ac105482a7b8deb2a0ccab1808d60925 100644 --- a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_full_1p.sh @@ -20,6 +20,7 @@ learning_rate= #参数配置 data_path="" +dynamic_input="1" #work_dir="$cur_path/estimator_working_dir" #export_path="$cur_path/outputs/models/000001-first_generation" @@ -32,6 +33,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -58,7 +61,8 @@ nohup python3 TrainResNet.py \ --image_name_path ${data_path}/label/name_1200.npy \ --train_data_path ${data_path}/train_data/1200_data.npy \ --parentPath ${data_path}/CACD2000_Crop/ \ - --epochs 100 > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --epochs 100 \ + --dynamic_input ${dynamic_input} > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait end=$(date +%s) e2e_time=$(( $end - $start )) @@ -114,4 +118,4 @@ echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEV echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log - +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log diff --git a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_performance_1p.sh index 3e357429902a0f5556e2e4e9d49453c561822517..41420ab08efc93ce377e6a9fbcda5e445574b653 100644 --- a/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/built-in/cv/image_classification/Face-ResNet50_ID1372_for_TensorFlow/test/train_performance_1p.sh @@ -20,6 +20,7 @@ learning_rate= #参数配置 data_path="" +dynamic_input="1" #work_dir="$cur_path/estimator_working_dir" #export_path="$cur_path/outputs/models/000001-first_generation" @@ -32,6 +33,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -58,7 +61,8 @@ nohup python3 TrainResNet.py \ --image_name_path ${data_path}/label/name_1200.npy \ --train_data_path ${data_path}/train_data/1200_data.npy \ --parentPath ${data_path}/CACD2000_Crop/ \ - --epochs 2 > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --epochs 2 \ + --dynamic_input ${dynamic_input} > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait end=$(date +%s) e2e_time=$(( $end - $start )) @@ -114,4 +118,4 @@ echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEV echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log - +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log diff --git a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/main.py b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/main.py index f52a29fe18e2b2fcf2e44e6e80f2db17fa533509..659c8a97d95e71a28862b2d5931e04e01d2fe2d3 100644 --- a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/main.py +++ b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/main.py @@ -39,6 +39,7 @@ parser.add_argument('--epochs', default=5, type=int) parser.add_argument('--train_data_path', default='./data/membrane/train') parser.add_argument('--test_data_path', default='./data/membrane/test') parser.add_argument('--predict_data_path', default='./data/membrane/predict') +parser.add_argument("--dynamic_input", type=str, default='1', help="--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph") args = parser.parse_args() def main(): @@ -66,7 +67,12 @@ if __name__ == '__main__': custom_op.name = "NpuOptimizer" custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") custom_op.parameter_map["dynamic_input"].b = 1 - custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + if args.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + elif args.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") + else: + print("Enter correct compilation parameters.") npu_keras_sess = set_keras_session_npu_config(config=global_config) # ***** npu modify end ***** main() diff --git a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/model.py b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/model.py index 310f7a7dea4fd64ea78a215469d69caaebf06d3b..597ae0418a05bf5ccde90919d9a81996679a010a 100644 --- a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/model.py +++ b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/model.py @@ -28,6 +28,7 @@ # limitations under the License. # from npu_bridge.npu_init import * +from npu_bridge.estimator.npu import npu_convert_dropout import numpy as np import os import skimage.io as io @@ -67,11 +68,17 @@ def unet(pretrained_weights = None,input_size = (256,256,1)): conv4 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool3) conv4 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv4) drop4 = Dropout(0.5)(conv4) + # drop4 = npu_ops.dropout(0.5)(conv4) + # drop4 = npu_ops.dropout(conv4, 0.5) + # drop4 = tf.keras.layers.Dropout(0.5)(conv4) pool4 = MaxPooling2D(pool_size=(2, 2))(drop4) conv5 = Conv2D(1024, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool4) conv5 = Conv2D(1024, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv5) drop5 = Dropout(0.5)(conv5) + # drop5 = npu_ops.dropout(0.5)(conv5) + # drop5 = npu_ops.dropout(conv5, 0.5) + # drop5 = tf.keras.layers.Dropout(0.5)(conv5) up6 = Conv2D(512, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(UpSampling2D(size = (2,2))(drop5)) merge6 = concatenate([drop4,up6], axis = 3) diff --git a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_full_1p.sh index 315bbaa301593277116db7c8d1d5c125460817f8..1b4179dae92d74ece6e03c015647abec1d46d5f1 100644 --- a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_full_1p.sh @@ -18,6 +18,7 @@ learning_rate= #参数配置 data_path="" +dynamic_input="1" if [[ $1 == --help || $1 == --h ]];then echo "usage:./train_full_1p.sh --data_path=./datasets" @@ -28,6 +29,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -51,7 +54,8 @@ start=$(date +%s) python3 main.py --epochs=${train_epochs} \ --train_data_path=${data_path}/data/membrane/train \ --test_data_path=${data_path}/data/membrane/test \ - --predict_data_path=${cur_path}/test/predict > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --predict_data_path=${cur_path}/test/predict \ + --dynamic_input ${dynamic_input} > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait end=$(date +%s) @@ -109,4 +113,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_performance_1p.sh index fef0301deb185c69877d804f6989c94f5e085682..7e23b40fe14a71b758e29629f568b0b12b3426b0 100644 --- a/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/built-in/cv/image_segmentation/2D_Unet_ID2337_for_TensorFlow/test/train_performance_1p.sh @@ -1,6 +1,8 @@ #!/bin/bash cur_path=`pwd`/../ +export ASCEND_SLOG_PRINT_TO_STDOUT=1 +export ASCEND_GLOBAL_LOG_LEVEL=0 #基础参数,需要模型审视修改 #Batch Size batch_size=2 @@ -18,6 +20,9 @@ learning_rate= #参数配置 data_path="" +dynamic_input="1" + +source /usr/local/Ascend/latest/bin/setenv.bash if [[ $1 == --help || $1 == --h ]];then echo "usage:./train_performance_1p.sh --data_path=./datasets" @@ -28,6 +33,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -51,7 +58,8 @@ start=$(date +%s) python3 main.py --epochs=${train_epochs} \ --train_data_path=${data_path}/data/membrane/train \ --test_data_path=${data_path}/data/membrane/test \ - --predict_data_path=${cur_path}/test/predict > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --predict_data_path=${cur_path}/test/predict \ + --dynamic_input ${dynamic_input} > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait end=$(date +%s) @@ -109,4 +117,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/osmn_coco_pretrain.py b/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/osmn_coco_pretrain.py index 2e3809f4a023affa3f13d22f761553b8c87b8dd1..c7c891bf48bac9303ab9e4b836177ad2c934b2b2 100644 --- a/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/osmn_coco_pretrain.py +++ b/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/osmn_coco_pretrain.py @@ -81,6 +81,12 @@ def add_arguments(parser): required=False, default=[0.8, 1, 1.2], help='Image scales for data augmentation') + group.add_argument( + '--dynamic_input', + type=str, + required=False, + default='1', + help='--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph') print(" ".join(sys.argv[:])) @@ -115,7 +121,12 @@ config.gpu_options.per_process_gpu_memory_fraction = 0.9 custom_op = config.graph_options.rewrite_options.custom_optimizers.add() custom_op.name = "NpuOptimizer" custom_op.parameter_map["dynamic_input"].b = 1 -custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") +if args.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") +elif args.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") +else: + print("Enter correct compilation parameters.") custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") #custom_op.parameter_map["mix_compile_mode"].b = True diff --git a/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_full_1p.sh index 7ac40e7b23a146f7ceb74cb785edfa44c5cf48c0..e8e9cc8838824f4882eda861a2b19c682bc55fcf 100644 --- a/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_full_1p.sh @@ -19,6 +19,7 @@ learning_rate= #参数配置 data_path="../data/" +dynamic_input="1" if [[ $1 == --help || $1 == --h ]];then echo "usage:./train_full_1p.sh --data_path=../data" @@ -29,6 +30,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -65,7 +68,8 @@ nohup python3 osmn_coco_pretrain.py --data_path ${data_path}/data/ \ --model_save_path $cur_path/models/ \ --training_iters $train_steps \ --display_iters 100 \ - --save_iters 50000 > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --save_iters 50000 \ + --dynamic_input ${dynamic_input} > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait end=$(date +%s) e2etime=$(( $end - $start )) @@ -107,3 +111,4 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2etime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_performance_1p.sh index 5392e196023e9bc994716613b033bbed3b90fd07..06f15be3a50633e35262312bafacff6c6059bf52 100644 --- a/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/built-in/cv/image_segmentation/OSMN_ID1103_for_TensorFlow/test/train_performance_1p.sh @@ -1,6 +1,8 @@ #!/bin/bash cur_path=`pwd`/../ #export ASCEND_DEVICE_ID=3 +export ASCEND_SLOG_PRINT_TO_STDOUT=1 +export ASCEND_GLOBAL_LOG_LEVEL=0 #基础参数,需要模型审视修改 #Batch Size @@ -19,6 +21,7 @@ learning_rate= #参数配置 data_path="/data" +dynamic_input="1" if [[ $1 == --help || $1 == --h ]];then echo "usage:./train_performance_1p.sh --data_path=../data" @@ -29,6 +32,8 @@ for para in $* do if [[ $para == --data_path* ]];then data_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -65,7 +70,8 @@ nohup python3 osmn_coco_pretrain.py --data_path $data_path/data/ \ --model_save_path $cur_path/models/ \ --training_iters $train_steps \ --display_iters 100 \ - --save_iters 500 > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --save_iters 500 \ + --dynamic_input ${dynamic_input} > $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & wait end=$(date +%s) e2etime=$(( $end - $start )) @@ -106,4 +112,5 @@ echo "CaseName = ${CaseName}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseN echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2etime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2etime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/adagan_gmm.py b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/adagan_gmm.py index bd236179ef49023503138e3491be45bd8295e581..627bed38ad477b1a39ccefcd1fc4b6b266776253 100644 --- a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/adagan_gmm.py +++ b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/adagan_gmm.py @@ -175,6 +175,7 @@ if __name__ == '__main__': parser.add_argument("--data_url", type=str, default="/test-modelartsxc/dataset/train") parser.add_argument("--modelarts_data_dir", type=str, default="/cache/dataset/train") parser.add_argument("--modelarts_result_dir", type=str, default="/cache/result") + parser.add_argument("--dynamic_input", type=str, default='1', help="--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph") config, unparsed = parser.parse_known_args() while len(sys.argv) > 1: sys.argv.pop() diff --git a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/gan.py b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/gan.py index 7c302bfcc13406bc3203a8b7709e16edcecc2704..8ea87113b2d7f4a9c5fd8739f5227c51022c15f4 100644 --- a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/gan.py +++ b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/gan.py @@ -58,7 +58,12 @@ class Gan(object): custom_op = config.graph_options.rewrite_options.custom_optimizers.add() custom_op.name = "NpuOptimizer" custom_op.parameter_map["dynamic_input"].b = True - custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + if args.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + elif args.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") + else: + print("Enter correct compilation parameters.") config.graph_options.rewrite_options.remapping = RewriterConfig.OFF # 必须显式关闭remap run_config = NPURunConfig(enable_data_pre_proc=False) diff --git a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_full_1p.sh index c120d0eeb28f24ad7cc9baecad297ffc7748942b..54281fe469b2cb2daa43b53d0a6b534e2c8d4dfd 100644 --- a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_full_1p.sh @@ -13,6 +13,7 @@ RANK_ID_START=0 # 数据集路径,保持为空,不需要修改 data_path='' ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要修改 export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -78,6 +79,8 @@ do elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -111,7 +114,7 @@ do #执行训练脚本,以下传参不需要修改,其他需要模型审视修改 - python3 adagan_gmm.py > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + python3 adagan_gmm.py --dynamic_input ${dynamic_input} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done @@ -156,4 +159,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_performance_1p.sh index 1bbb9a1daff5ad772f5af0dfb7a8db6980d01130..a96512fac4dbc14bcbb1518efa189ea612a63a42 100644 --- a/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/ADAGAN_ID2115_for_TensorFlow/test/train_performance_1p.sh @@ -13,6 +13,7 @@ RANK_ID_START=0 # 数据集路径,保持为空,不需要修改 data_path='' ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要修改 export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -78,6 +79,8 @@ do elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -113,7 +116,8 @@ do python3 adagan_gmm.py \ --epochs=${train_epochs} \ - --steps=${train_steps} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + --steps=${train_steps} \ + --dynamic_input ${dynamic_input} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done @@ -158,4 +162,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/Hybrid-Spectral-Net.py b/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/Hybrid-Spectral-Net.py index 55a6cce34215a8f7cb1e3da2aaf57e9efe54a21e..3de262a376e26a1badac3e82dc882983f7ba9f54 100644 --- a/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/Hybrid-Spectral-Net.py +++ b/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/Hybrid-Spectral-Net.py @@ -62,13 +62,6 @@ import scipy.io as sio # %matplotlib inline from tensorflow.core.protobuf.rewriter_config_pb2 import RewriterConfig -config = tf.compat.v1.ConfigProto() -custom_op = config.graph_options.rewrite_options.custom_optimizers.add() -custom_op.name = "NpuOptimizer" -custom_op.parameter_map["use_off_line"].b = True -config.graph_options.rewrite_options.remapping = RewriterConfig.OFF -custom_op.parameter_map["dynamic_input"].b = True -custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") flags = tf.compat.v1.flags FLAGS = flags.FLAGS @@ -91,6 +84,23 @@ flags.DEFINE_integer( "train_step", 100, "total epochs for training") +flags.DEFINE_integer( + "dynamic_input", "1", + "--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph") + +config = tf.compat.v1.ConfigProto() +custom_op = config.graph_options.rewrite_options.custom_optimizers.add() +custom_op.name = "NpuOptimizer" +custom_op.parameter_map["use_off_line"].b = True +config.graph_options.rewrite_options.remapping = RewriterConfig.OFF +custom_op.parameter_map["dynamic_input"].b = True +if FLAGS.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") +elif FLAGS.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") +else: + print("Enter correct compilation parameters.") + ## GLOBAL VARIABLES dataset = 'SA' diff --git a/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_full_1p.sh index acf6eef09f99aee617bf555b3fdbb4a59d7fb3d5..34cd7e3022362e153c3af62825fb60b0f88d2d0b 100644 --- a/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_full_1p.sh @@ -13,6 +13,7 @@ RANK_ID_START=0 # 数据集路径,保持为空,不需要修改 data_path='' ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要修改 export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -78,6 +79,8 @@ do elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -120,7 +123,7 @@ do #执行训练脚本,以下传参不需要修改,其他需要模型审视修改 - python3 Hybrid-Spectral-Net.py --datapath=${data_path} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + python3 Hybrid-Spectral-Net.py --datapath=${data_path} --dynamic_input=${dynamic_input} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done @@ -165,4 +168,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_performance_1p.sh index 6114bf636b5fd722690297a254959b91fd0c9fca..c6362c04e9de7cfcc76eff184e07be7588b3547c 100644 --- a/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/HybridSN_ID1160_for_TensorFlow/test/train_performance_1p.sh @@ -13,6 +13,7 @@ RANK_ID_START=0 # 数据集路径,保持为空,不需要修改 data_path='' ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要修改 export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -78,6 +79,8 @@ do elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -120,7 +123,7 @@ do #执行训练脚本,以下传参不需要修改,其他需要模型审视修改 - python3 Hybrid-Spectral-Net.py --train_step=${train_steps} --datapath=${data_path} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + python3 Hybrid-Spectral-Net.py --train_step=${train_steps} --datapath=${data_path} --dynamic_input=${dynamic_input} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done @@ -165,4 +168,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/mgcnn_npu.py b/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/mgcnn_npu.py index 908b689952a6de682ac41ad6036b713cfa50e137..cba82218939e99aac62b9515c9239220a292b7aa 100644 --- a/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/mgcnn_npu.py +++ b/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/mgcnn_npu.py @@ -187,17 +187,6 @@ class mgcnn(object): if __name__ == '__main__': - # npu_keras_sess = set_keras_session_npu_config() - # ***** npu modify begin ***** - os.system(" export ENABLE_FORCE_V2_CONTROL = 1") - # export ENABLE_FORCE_V2_CONTROL = 1 - global_config = tf.ConfigProto(log_device_placement=False) - custom_op = global_config.graph_options.rewrite_options.custom_optimizers.add() - custom_op.name = "NpuOptimizer" - custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") - custom_op.parameter_map["dynamic_input"].b = 1 - custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") - npu_keras_sess = set_keras_session_npu_config(config=global_config) # ***** npu modify end ***** description = ("Train a CNN to classify four cosmological models\n" + @@ -223,8 +212,26 @@ if __name__ == '__main__': help="specific gpu id to use") parser.add_argument("-datapath", "--datapath", type=str, default="/cache/dataset/data", help="specific gpu id to use") + parser.add_argument("--dynamic_input", type=str, default='1', + help="--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph") args = parser.parse_args() + # npu_keras_sess = set_keras_session_npu_config() + # ***** npu modify begin ***** + os.system(" export ENABLE_FORCE_V2_CONTROL = 1") + # export ENABLE_FORCE_V2_CONTROL = 1 + global_config = tf.ConfigProto(log_device_placement=False) + custom_op = global_config.graph_options.rewrite_options.custom_optimizers.add() + custom_op.name = "NpuOptimizer" + custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("allow_mix_precision") + custom_op.parameter_map["dynamic_input"].b = 1 + if args.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + elif args.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") + else: + print("Enter correct compilation parameters.") + npu_keras_sess = set_keras_session_npu_config(config=global_config) noise_opts = {0: "clean", 1: "sigma035", 2: "sigma070"} noise_name = noise_opts[args.noise] diff --git a/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_full_1p.sh b/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_full_1p.sh index 274129ace16858e26a22d8019c268ed82d2279dc..97be2b7ed88dcad00ebe8282faa0e7d2b00221e5 100644 --- a/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_full_1p.sh +++ b/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_full_1p.sh @@ -13,6 +13,7 @@ RANK_ID_START=0 # 数据集路径,保持为空,不需要修改 data_path='' ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要修改 export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -78,6 +79,8 @@ do elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -123,7 +126,8 @@ do python3 mgcnn_npu.py \ --datapath=${data_path}/data/ \ --iterations=${train_steps} \ - --epochs=${train_epochs} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 & + --epochs=${train_epochs} \ + --dynamic_input ${dynamic_input} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 & done @@ -171,4 +175,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_performance_1p.sh index 657a4a24350c97ed344d6d63f488192c9a6951d6..3d0535194aca7da1045beeba2be2dbff1e354225 100644 --- a/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/MGCNN_ID1039_for_TensorFlow/test/train_performance_1p.sh @@ -13,6 +13,7 @@ RANK_ID_START=0 # 数据集路径,保持为空,不需要修改 data_path='' ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要修改 export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -78,6 +79,8 @@ do elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` fi done @@ -123,7 +126,8 @@ do python3 mgcnn_npu.py \ --datapath=${data_path}/data/ \ --iterations=${train_steps} \ - --epochs=${train_epochs} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 & + --epochs=${train_epochs} \ + --dynamic_input ${dynamic_input} > ${cur_path}test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 & done @@ -171,4 +175,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file diff --git a/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/post_tprnn_npu_code_chun/tprnn_train_human.py b/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/post_tprnn_npu_code_chun/tprnn_train_human.py index 9d0f92adf728e93ad6727990ee3a8cbbc287d60a..7b5a086ece2879282bd434371a55383ed2e1331b 100644 --- a/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/post_tprnn_npu_code_chun/tprnn_train_human.py +++ b/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/post_tprnn_npu_code_chun/tprnn_train_human.py @@ -145,6 +145,10 @@ parser.add_argument( parser.add_argument( "--data_url", type=str, default="./dataset" ) # PyCharm插件传入的 Data Path in OBS路径 +parser.add_argument( + "--dynamic_input", type=str, default='1', help="--dynamic_input=1 Use fuzzy compilation. --dynamic_input=lazy_recompile Compile using lazy static graph" + ) + #add parser.add_argument("--locals_dir", default="/data2/NRE_Check/wx1056345/ID1297_tprnn/data/h3.6m/dataset") @@ -318,7 +322,12 @@ def train(): custom_op.name = "NpuOptimizer" #add custom_op.parameter_map['dynamic_input'].b = True - custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + if FLAGS.dynamic_input == "lazy_recompile": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("lazy_recompile") + elif FLAGS.dynamic_input == "1": + custom_op.parameter_map["dynamic_graph_execute_mode"].s = tf.compat.as_bytes("dynamic_execute") + else: + print("Enter correct compilation parameters.") ##混合精度 custom_op.parameter_map["precision_mode"].s = tf.compat.as_bytes("force_fp16") diff --git a/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/test/train_performance_1p.sh index af988dc747033804fa5d6f65d6e01347854415c8..6480b950598ae04017cdb837afed9455add1c281 100644 --- a/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/tprnn_ID1297_for_TensorFlow/test/train_performance_1p.sh @@ -14,6 +14,7 @@ RANK_ID_START=0 data_path='' #预训练模型地址 ckpt_path='' +dynamic_input="1" #设置默认日志级别,不需要改 #export ASCEND_GLOBAL_LOG_LEVEL=3 @@ -77,7 +78,9 @@ do data_path=`echo ${para#*=}` elif [[ $para == --ckpt_path* ]];then ckpt_path=`echo ${para#*=}` - fi + elif [[ $para == --dynamic_input* ]];then + dynamic_input=`echo ${para#*=}` + fi done # #校验是否传入data_path,不需要修改 # if [[$data_path == ""]];then @@ -105,7 +108,8 @@ python3 tprnn_train_human.py \ --locals_dir=${data_path} \ --model_dir=$cur_path/result \ --iterations=1000 \ - --test_every=2000 > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + --test_every=2000 \ + --dynamic_input ${dynamic_input} > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 wait #训练结束时间,不需要修改 @@ -155,4 +159,5 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -#echo "Accuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +#echo "Accuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DynamicInput = ${dynamic_input}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file