diff --git a/ACL_TensorFlow/contrib/cv/edsr/.keep b/ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/.keep similarity index 100% rename from ACL_TensorFlow/contrib/cv/edsr/.keep rename to ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/.keep diff --git a/ACL_TensorFlow/contrib/cv/edsr/README.md b/ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/README.md similarity index 100% rename from ACL_TensorFlow/contrib/cv/edsr/README.md rename to ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/README.md diff --git a/ACL_TensorFlow/contrib/cv/edsr/ckpt2pb.py b/ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/ckpt2pb.py similarity index 100% rename from ACL_TensorFlow/contrib/cv/edsr/ckpt2pb.py rename to ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/ckpt2pb.py diff --git a/ACL_TensorFlow/contrib/cv/edsr/edsr.py b/ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/edsr.py similarity index 100% rename from ACL_TensorFlow/contrib/cv/edsr/edsr.py rename to ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/edsr.py diff --git a/ACL_TensorFlow/contrib/cv/edsr/run.py b/ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/run.py similarity index 100% rename from ACL_TensorFlow/contrib/cv/edsr/run.py rename to ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/run.py diff --git a/ACL_TensorFlow/contrib/cv/edsr/testpic.bin b/ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/testpic.bin similarity index 100% rename from ACL_TensorFlow/contrib/cv/edsr/testpic.bin rename to ACL_TensorFlow/contrib/cv/EDSR_ID1263_for_ACL/testpic.bin diff --git a/ACL_TensorFlow/contrib/cv/mnasnet/.keep b/ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/.keep similarity index 100% rename from ACL_TensorFlow/contrib/cv/mnasnet/.keep rename to ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/.keep diff --git a/ACL_TensorFlow/contrib/cv/mnasnet/README.md b/ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/README.md similarity index 100% rename from ACL_TensorFlow/contrib/cv/mnasnet/README.md rename to ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/README.md diff --git a/ACL_TensorFlow/contrib/cv/mnasnet/ckpt2pb.py b/ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/ckpt2pb.py similarity index 100% rename from ACL_TensorFlow/contrib/cv/mnasnet/ckpt2pb.py rename to ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/ckpt2pb.py diff --git a/ACL_TensorFlow/contrib/cv/mnasnet/pic.bin b/ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/pic.bin similarity index 100% rename from ACL_TensorFlow/contrib/cv/mnasnet/pic.bin rename to ACL_TensorFlow/contrib/cv/MnasNet_ID0728_for ACL/pic.bin diff --git a/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/.keep b/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/README.md b/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/README.md new file mode 100644 index 0000000000000000000000000000000000000000..07a7c35d14803eb6de5a891d0abb8f15b659ba2a --- /dev/null +++ b/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/README.md @@ -0,0 +1,81 @@ +# ATC SeqGAN + + +- references: + + ["SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient"](https://arxiv.org/abs/1609.05473) + + +- training model: + + [SeqGAN_ID2096_for_TensorFlow](https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/contrib/cv/SeqGAN_ID2096_for_TensorFlow) + + +# 1. ckpt to pb + +download **ckpt** and use **ckpt2pb.py** process ckpt to pb. + +[ckpt](https://pan.baidu.com/s/1hTrdrkppaHT_onXrrTMwFg) +Password:lzqe + +# 2. pb to om +Command: +``` +atc --model=seqgan.pb --framework=3 --input_format="ND" --input_shape="Placeholder:64,20" --output=seqgan --soc_version=Ascend310 +``` +[Pb](https://pan.baidu.com/s/1zudcMVdDYCDN5q4LDrDXrg) +Password:yh6q + +[OM](https://pan.baidu.com/s/1HJZhBZKBX2W6i6daaMKuuw) +Password:9p09 + +# 3. compile msame +Reference to https://gitee.com/ascend/tools/tree/master/msame, compile **msame** + +Compile msame command: +```bash +. /home/HwHiAiUser/Ascend/ascend-toolkit/set_env.sh +export DDK_PATH=/home/HwHiAiUser/Ascend/ascend-toolkit/latest +export NPU_HOST_LIB=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/runtime/lib64/stub +cd $HOME/AscendProjects/tools/msame/ +./build.sh g++ $HOME/AscendProjects/tools/msame/out + +``` + +# 4. inference +Inference command: +```bash +cd $HOME/AscendProjects/tools/msame/out +model_path=/home/HwHiAiUser/AscendProjects/SeqGAN/seqgan.om +output_path=/home/HwHiAiUser/AscendProjects/SeqGAN +./msame --model ${model_path} --output ${output_path} --outputSize 25600000 +``` + + + +Part of **Inference sys output**: +```bash +[INFO] acl init success +[INFO] open device 0 success +[INFO] create context success +[INFO] create stream success +[INFO] get run mode success +[INFO] load model ./seqgan.om success +[INFO] create model description success +[INFO] get input dynamic gear count success +[INFO] create model output success +.//2022118_17_18_37_136806 +[INFO] model execute success +Inference time: 181.534ms +[INFO] get max dynamic batch size success +[INFO] output data success +Inference average time: 181.534000 ms +[INFO] destroy model input success +[INFO] unload model success, model Id is 1 +[INFO] Execute sample success +[INFO] end to destroy stream +[INFO] end to destroy context +[INFO] end to reset device is 0 +[INFO] end to finalize acl +``` + diff --git a/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/ckpt2pb.py b/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/ckpt2pb.py new file mode 100644 index 0000000000000000000000000000000000000000..b714d367432ea770600b06faf7e39b1320849f9f --- /dev/null +++ b/ACL_TensorFlow/contrib/cv/SeqGAN_ID2096_for_ACL/ckpt2pb.py @@ -0,0 +1,32 @@ +import tensorflow as tf +from tensorflow.python.tools import freeze_graph +from tensorflow.python.framework import graph_util + + +def freeze_graph(input_checkpoint,output_graph): + + # 指定输出的节点名称,该节点名称必须是原模型中存在的节点 + output_node_names = "transpose_2" + saver = tf.train.import_meta_graph(input_checkpoint + '.meta', clear_devices=True) + graph = tf.get_default_graph() # 获得默认的图 + input_graph_def = graph.as_graph_def() # 返回一个序列化的图代表当前的图 + + with tf.Session() as sess: + + graph_def = tf.get_default_graph().as_graph_def(add_shapes=True) + node_list = [n.name for n in graph_def.node] + #for node in node_list: + # print("node_name", node) + saver.restore(sess, input_checkpoint) #恢复图并得到数据 + output_graph_def = graph_util.convert_variables_to_constants( # 模型持久化,将变量值固定 + sess=sess, + input_graph_def=input_graph_def,# 等于:sess.graph_def + output_node_names=output_node_names.split(","))# 如果有多个输出节点,以逗号隔开 + + with tf.gfile.GFile(output_graph, "wb") as f: #保存模型 + f.write(output_graph_def.SerializeToString()) #序列化输出 + print("%d ops in the final graph." % len(output_graph_def.node)) #得到当前图有几个操作节点 + +input_checkpoint='./checkpoint/myModel' +out_pb_path='seqgan.pb' +freeze_graph(input_checkpoint, out_pb_path)