Author | SHA1 | Message | Date |
---|---|---|---|
|
49aa7bb17b |
!920 bug fix
From: @dimitri_rose Reviewed-by: @wqtshg,@xchu42 Signed-off-by: @wqtshg |
4 years ago |
|
82c1afa937 | bug | 4 years ago |
|
ab5ec6dc22 |
!919 unknownflag
From: @dimitri_rose Reviewed-by: @xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
77b56c0c08 | unknownflag | 4 years ago |
|
14a7c6a880 |
!910 _zero_copy_identity_reserved
From: @dimitri_rose Reviewed-by: @xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
2e67c3d45a | _zero_copy_identity_reserved | 4 years ago |
|
4bbaa371f0 |
!906 point_gnn
From: @dimitri_rose Reviewed-by: @xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
eb830a57ad | point_gnn | 4 years ago |
|
cee0f1b66a |
!890 update parser submodule
From: @yangyongqiang5033 Reviewed-by: @xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
4f32ef5b79 | update parser submodule | 4 years ago |
|
793abeabcf |
!788 for get package
From: @wangxiaotian22 Reviewed-by: @wqtshg,@ji_chen Signed-off-by: @ji_chen |
4 years ago |
|
f8bdf04f0b | parser submodule update | 4 years ago |
|
b159ab4d03 |
!729 license update, mentioning usage of tensorflow and caffe code
From: @nicholas_yhr Reviewed-by: @guoqi1024,@guoqi1024,@liujunzhu Signed-off-by: @liujunzhu |
4 years ago |
|
82dd040420 | license update, mentioning usage of tensorflow and caffe code | 4 years ago |
|
1bcdf925d1 |
!780 回退 'Pull Request !770 : AssignMemory2HasRefAttrNode'
From: @wqtshg Reviewed-by: @xchu42,@ji_chen Signed-off-by: @ji_chen |
4 years ago |
|
2d31b66f9d | 回退 'Pull Request !770 : AssignMemory2HasRefAttrNode' | 4 years ago |
|
312c394163 |
!770 AssignMemory2HasRefAttrNode
From: @dimitri_rose Reviewed-by: @wqtshg,@xchu42 Signed-off-by: @wqtshg |
4 years ago |
|
ebb409130c |
!769 Feature:display model info
From: @wangwenhua1 Reviewed-by: @wqtshg,@xchu42 Signed-off-by: |
4 years ago |
|
87a6726b2f | display model info | 4 years ago |
|
f24291b161 | display model info | 4 years ago |
|
41282db089 | display model info | 4 years ago |
|
0828878bbd | display model info | 4 years ago |
|
acafc1b578 | AssignMemory2HasRefAttrNode | 4 years ago |
|
6453e36696 | display model info | 4 years ago |
|
49a014c687 |
!641 restore code
From: @yangyongqiang5033 Reviewed-by: @xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
5fe5f712bf | restore code | 4 years ago |
|
b8457f7e21 |
!628 update readme
From: @wqtshg Reviewed-by: @xchu42,@ji_chen Signed-off-by: @ji_chen |
4 years ago |
|
eed48a4245 | update README_CN.md. | 4 years ago |
|
78c8adccc8 |
!627 add validation of fmk type for plugin load.
From: @yangyongqiang5033 Reviewed-by: @wqtshg,@xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
fca7991db2 | add validation of fmk type for plugin load. | 4 years ago |
|
1fcf20a787 |
!607 update cmakelist for runtimecompile
From: @wqtshg Reviewed-by: @xchu42,@sheng-nan Signed-off-by: @sheng-nan |
4 years ago |
|
596515a68b | update cmakelist for runtimecompile | 4 years ago |
|
8c4aef3cef |
!605 update cmakelist for compile
From: @wqtshg Reviewed-by: @xchu42,@ji_chen Signed-off-by: @ji_chen |
4 years ago |
|
b351f9ee54 | update cmakelist for compile | 4 years ago |
|
4e7301f926 |
!603 solve master compile
From: @taoxudonghaha Reviewed-by: @xchu42,@wqtshg Signed-off-by: @wqtshg |
4 years ago |
|
8692ffc23f | solve master compile | 4 years ago |
|
892da7167c |
!582 ONLY_COMPILE_OPEN_SRC_METADEF
From: @yangyongqiang5033 Reviewed-by: @wqtshg,@xchu42 Signed-off-by: @wqtshg |
4 years ago |
|
a4bab5bc89 | ONLY_COMPILE_OPEN_SRC_METADEF | 4 years ago |
|
e7e7f4143a |
!551 update submodule
From: @yangyongqiang5033 Reviewed-by: Signed-off-by: |
4 years ago |
|
0f96eff3af | update submodule | 4 years ago |
|
05020186f0 |
!426 update master directory
Merge pull request !426 from 王涛/pr_267 |
4 years ago |
|
66f563a97d | update master directory | 4 years ago |
|
66e9b44b89 | update master directory | 4 years ago |
|
d16cf136c2 | update master directory | 4 years ago |
|
06e33a7c04 | update master directory | 4 years ago |
|
3ad7da206e | update master directory | 4 years ago |
|
b409e6a442 | update master directory | 4 years ago |
|
f5e161b876 | update build.sh | 4 years ago |
|
73e3484b2c | update build.sh | 4 years ago |
|
5292a506a7 | update datatype | 4 years ago |
|
61f5835f2e | Update:The directory must be the same as the dev branch. | 4 years ago |
|
0cfdcdb096 | update submodule | 4 years ago |
|
cd9185189b | update json | 4 years ago |
|
7c19be97fd | update cmake and src | 4 years ago |
|
238d73e2a9 |
!314 Feature:Concatv2 host cpu kernel support int64
Merge pull request !314 from zhaoxinxin/dev_master |
4 years ago |
|
8751d19dd8 | modified: src/ge/host_kernels/concat_v2_kernel.cc | 4 years ago |
|
c60bfbe20b |
!260 update graph cmake
From: @wqtshg Reviewed-by: @xchu42,@ji_chen Signed-off-by: @xchu42 |
4 years ago |
|
7a1a82437d | update graph cmake | 4 years ago |
|
0ebedf55b1 |
!258 update fwk_proto cmake
From: @wqtshg Reviewed-by: @xchu42,@ji_chen Signed-off-by: @xchu42 |
4 years ago |
|
45570c3cae | update fwk_adapter.proto cmkae | 4 years ago |
|
9391fe4cfe |
!253 compile protobuf
From: @wqtshg Reviewed-by: @xchu42 Signed-off-by: |
4 years ago |
|
cd4eb3384c | compile protobuf | 4 years ago |
|
0e9a7c2ab9 |
!252 update readme
From: @wqtshg Reviewed-by: @xchu42,@ji_chen Signed-off-by: @ji_chen |
4 years ago |
|
15775d3218 | update README_CN.md. | 4 years ago |
|
7f3cf91352 |
!251 回退 'Pull Request !249 : protobuf test'
Merge pull request !251 from 王涛/revert-merge-249-master |
4 years ago |
|
ec18205196 | 回退 'Pull Request !249 : protobuf test' | 4 years ago |
|
7750ef2efb |
!249 protobuf test
Merge pull request !249 from 王涛/master |
4 years ago |
|
fb9144aa36 | update README_CN.md. | 4 years ago |
|
fd228c4843 | update README_CN.md. | 4 years ago |
|
d8bfb8056b | abi test | 4 years ago |
|
4112a9addf |
!220 回退 'Pull Request !208 : fix graphengine compilation'
Merge pull request !220 from 王涛/revert-merge-208-master |
4 years ago |
|
6d74596eaf | 回退 'Pull Request !208 : fix graphengine compilation' | 4 years ago |
|
9d79097319 |
!213 update task.proto
Merge pull request !213 from yanghaoran/master |
4 years ago |
|
501e8eda58 | add task.proto | 4 years ago |
|
c97bc41186 |
!208 fix graphengine compilation
Merge pull request !208 from yanghaoran/master |
4 years ago |
|
2debb65452 | fix compilation | 4 years ago |
|
a5d9a75c85 |
!204 clangformat modification
Merge pull request !204 from HW_KK/master |
4 years ago |
|
db4d2a9540 | clangformat modification | 4 years ago |
|
0b2e3dff2f |
!194 Roll back non-standard merging
Merge pull request !194 from lujiale/revert-merge-187-master |
4 years ago |
|
995cfcac25 | update src/common/graph/utils/mem_utils.h. | 4 years ago |
|
4679646fb5 | update src/common/graph/utils/mem_utils.h. | 4 years ago |
|
e0032f656f | 回退 'Pull Request !187 : sync src code and update the source folder location' | 4 years ago |
|
adb54f5f9b |
!187 sync src code and update the source folder location
Merge pull request !187 from taoxiangdong/master |
4 years ago |
|
319f4d167f | update submodule metadef and parser | 4 years ago |
|
416127b1f1 | sync src code from yellow zone master | 4 years ago |
|
dea1063e80 | Merge branch 'master' of https://gitee.com/taoxiangdong/graphengine | 4 years ago |
|
5ac356b3e2 | add stub files | 4 years ago |
|
c8d6e94441 |
handle empty label resource
Signed-off-by: zhoufeng <zhoufeng54@huawei.com> |
4 years ago |
|
1a651a4e57 | sync-from-trunk-to-blue-zone-1009 | 4 years ago |
|
a2ec076850 | sync-from-trunk-to-blue-zone-0928 | 4 years ago |
|
cd365aa247 |
!125 add stub files
Merge pull request !125 from yanghaoran/master |
4 years ago |
|
b25b70c9c2 | add stub files | 4 years ago |
|
575b546b55 |
!105 speed up third party download via domestic source
Merge pull request !105 from yanghaoran/master |
4 years ago |
|
1f4f0a47b1 | speed up third party download via domestic source | 4 years ago |
|
866c61a4e6 |
!92 Handle empty label resource
Merge pull request !92 from zhoufeng/master |
4 years ago |
|
0667dcfa3f |
handle empty label resource
Signed-off-by: zhoufeng <zhoufeng54@huawei.com> |
4 years ago |
|
7a75f024d5 |
!83 sync-from-trunk-to-blue-zone-1009
Merge pull request !83 from HW_KK/master |
4 years ago |
|
250465a71f | sync-from-trunk-to-blue-zone-1009 | 4 years ago |
|
80dfd25e01 |
!79 add libadump_server support in ge_lib_path mode
Merge pull request !79 from yanghaoran/master |
4 years ago |
|
fe038d0ae5 | add libadump_server support in ge_lib_path mode | 4 years ago |
|
88049a688b |
!77 fix securec download links due to mistakes made by openeuler community
Merge pull request !77 from yanghaoran/master |
4 years ago |
|
dcc1768c68 | fix securec download links due to mistakes made by openeuler community | 4 years ago |
|
14db109491 |
!74 sync-from-trunk-to-blue-zone-0928
Merge pull request !74 from HW_KK/master |
4 years ago |
|
bf316a3eeb | sync-from-trunk-to-blue-zone-0928 | 4 years ago |
@@ -1,8 +1,6 @@ | |||
[submodule "parser"] | |||
path = parser | |||
url = https://gitee.com/ascend/parser.git | |||
branch = development | |||
[submodule "metadef"] | |||
path = metadef | |||
url = https://gitee.com/ascend/metadef.git | |||
branch = development | |||
[submodule "parser"] | |||
path = parser | |||
url = https://gitee.com/ascend/parser.git |
@@ -41,6 +41,7 @@ if (ENABLE_OPEN_SRC) | |||
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") | |||
endif() | |||
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | |||
set(STATIC_ACL_LIB ${GE_LIB_PATH}) | |||
find_module(slog libslog.so ${GE_LIB_PATH}) | |||
find_module(mmpa libmmpa.so ${GE_LIB_PATH}) | |||
find_module(msprof libmsprof.so ${GE_LIB_PATH}) | |||
@@ -53,7 +54,6 @@ if (ENABLE_OPEN_SRC) | |||
find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | |||
find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) | |||
find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) | |||
find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | |||
else() | |||
if(DEFINED ENV{ASCEND_CUSTOM_PATH}) | |||
set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) | |||
@@ -66,6 +66,7 @@ if (ENABLE_OPEN_SRC) | |||
set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) | |||
set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) | |||
set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) | |||
set(STATIC_ACL_LIB ${ASCEND_ACL_DIR}) | |||
find_module(slog libslog.so ${ASCEND_ATC_DIR}) | |||
find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) | |||
if(PLATFORM STREQUAL "train") | |||
@@ -73,7 +74,8 @@ if (ENABLE_OPEN_SRC) | |||
find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | |||
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||
find_module(resource libresource.so ${ASCEND_ATC_DIR}) | |||
find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) | |||
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | |||
@@ -88,7 +90,6 @@ if (ENABLE_OPEN_SRC) | |||
find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) | |||
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) | |||
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) | |||
find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) | |||
if(PRODUCT STREQUAL "flr3") | |||
find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) | |||
elseif(PRODUCT STREQUAL "flr1") | |||
@@ -103,15 +104,14 @@ if (ENABLE_OPEN_SRC) | |||
elseif(PLATFORM STREQUAL "all") | |||
find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) | |||
find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) | |||
find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) | |||
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | |||
find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(resource libresource.so ${ASCEND_ATC_DIR}) | |||
find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) | |||
find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) | |||
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) | |||
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) | |||
find_module(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) | |||
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) | |||
find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) | |||
else() | |||
message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") | |||
endif() | |||
@@ -1,12 +1,12 @@ | |||
[View English](./README.md) | |||
图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示。 | |||
图引擎模块(GE)由C++实现,位于前端模块MindSpore/Tensorflow和底层硬件之间,起到承接作用。图引擎模块以ME/TF下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示。 | |||
 | |||
- GE API | |||
GE API是连接前端模块ME和GE Core的接口,负责GE Core中初始化、Session管理模块的接口,支持运行环境初始化,Session创建、销毁,图添加执行。 | |||
GE API是连接前端模块ME/TF和GE Core的接口,负责GE Core中初始化、Session管理模块的接口,支持运行环境初始化,Session创建、销毁,图添加执行。 | |||
- GE Core | |||
@@ -50,11 +50,12 @@ | |||
## 安装GE | |||
GE内嵌在MindSpore安装包中,MindSpore安装完毕后,GE以三个动态库的方式被调用。 | |||
GE内嵌在MindSpore/Ascend安装包中,MindSpore/Ascend安装完毕后,GE以动态库的方式被调用。 | |||
## 源码安装 | |||
GE也支持由源码编译,进行源码编译前,首先确保你有昇腾910 AI处理器的环境,同时系统满足以下要求: | |||
GE也支持由源码编译,进行源码编译前,首先确保你有昇腾910 AI处理器的环境(可通过[昇腾开发者社区](https://ascend.huawei.com | |||
)获取),同时系统满足以下要求: | |||
- GCC >= 7.3.0 | |||
- CMake >= 3.14.0 | |||
@@ -62,7 +63,7 @@ GE也支持由源码编译,进行源码编译前,首先确保你有昇腾910 | |||
- Libtool >= 2.4.6 | |||
- Automake >= 1.15.1 | |||
编译完成后会生成几个动态库,他们会链接到MindSpore中执行,无法单独运行。 | |||
编译完成后会生成几个动态库,他们会链接到MindSpore/Ascend中执行,无法单独运行。 | |||
1. 下载GE源码。 | |||
@@ -102,6 +103,26 @@ bash build.sh | |||
欢迎参与贡献,更多信息详见[Contributor Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md)。 | |||
## 路标 | |||
以下将展示graphengine近期的计划,我们会根据用户的反馈诉求,持续调整计划的优先级。 | |||
总体而言,我们会努力在以下几个方面不断改进。 | |||
1、完备性:Cast/ConcatV2算子支持输入数据类型为int64的常量折叠; | |||
2、完备性:onnx parser支持一对多映射; | |||
3、架构优化:ATC解耦并迁移至parser; | |||
4、易用性:提供tensorflow训练的checkpoint文件转pb文件的一键式转化工具; | |||
5、易用性:提供一键式本地编译环境构建工具; | |||
6、可维测:ATC转换生成的om模型包含框架信息、cann版本信息和芯片信息等; | |||
热忱希望各位在用户社区加入讨论,并贡献您的建议。 | |||
## Release Notes | |||
Release Notes请参考[RELEASE](RELEASE.md). | |||
@@ -458,3 +458,76 @@ Copyright (c) Facebook Inc. and Microsoft Corporation. | |||
License: MIT License | |||
Please see above. | |||
Software: caffe 1.0 | |||
License: BSD 2-Clause License | |||
Open Source Software Licensed Under the BSD 2-Clause License | |||
GraphEngine uses source code files from caffe so as to support model format conversion from caffe model to GraphEngine model. | |||
Please see below for the full list of source code files from caffe that are used by GraphEngine. | |||
The below software in this distribution may have been modified by Huawei Technologies Co., Ltd ("Huawei Modifications"). All Huawei Modifications are Copyright 2019-2020 Huawei Technologies Co., Ltd. | |||
---------------------------------------------------------------------------------------- | |||
1. caffe.proto master | |||
All contributions by the University of California: | |||
Copyright (c) 2014-2017 The Regents of the University of California (Regents) | |||
All rights reserved. | |||
Terms of the BSD 2-Clause License: | |||
-------------------------------------------------------------------- | |||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
Software: tensorflow 1.15.0 | |||
License: Apache-2.0 License | |||
Open Source Software Licensed Under the Apache-2.0 License | |||
GraphEngine uses source code files from tensorflow so as to support model format conversion from tensorflow model to GraphEngine model. | |||
Please see below for the full list of source code files from tensorflow that are used by GraphEngine. | |||
The below software in this distribution may have been modified by Huawei Technologies Co., Ltd ("Huawei Modifications"). All Huawei Modifications are Copyright 2019-2020 Huawei Technologies Co., Ltd. | |||
---------------------------------------------------------------------------------------- | |||
1. attr_value.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
2. function.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
3. graph.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
4. node_def.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
5. op_def.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
6. resource_handle.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
7. tensor.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
8. tensor_shape.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
9. types.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
10. versions.proto master | |||
Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |||
Terms of the Apache-2.0 License: | |||
Please see above. |
@@ -23,7 +23,7 @@ export BUILD_PATH="${BASEPATH}/build/" | |||
usage() | |||
{ | |||
echo "Usage:" | |||
echo "sh build.sh [-j[n]] [-h] [-v] [-s] [-t] [-u] [-c] [-p]" | |||
echo "sh build.sh [-j[n]] [-h] [-v] [-s] [-t] [-u] [-c] [-S on|off]" | |||
echo "" | |||
echo "Options:" | |||
echo " -h Print usage" | |||
@@ -34,9 +34,21 @@ usage() | |||
echo " -c Build ut with coverage tag" | |||
echo " -p Build inference or train" | |||
echo " -v Display build command" | |||
echo " -S Enable enable download cmake compile dependency from gitee , default off" | |||
echo "to be continued ..." | |||
} | |||
# check value of input is 'on' or 'off' | |||
# usage: check_on_off arg_value arg_name | |||
check_on_off() | |||
{ | |||
if [[ "X$1" != "Xon" && "X$1" != "Xoff" ]]; then | |||
echo "Invalid value $1 for option -$2" | |||
usage | |||
exit 1 | |||
fi | |||
} | |||
# parse and set options | |||
checkopts() | |||
{ | |||
@@ -47,10 +59,11 @@ checkopts() | |||
ENABLE_GE_ST="off" | |||
ENABLE_GE_COV="off" | |||
GE_ONLY="on" | |||
PLATFORM="inference" | |||
PLATFORM="train" | |||
PRODUCT="normal" | |||
ENABLE_GITEE="off" | |||
# Process the options | |||
while getopts 'ustchj:p:g:v' opt | |||
while getopts 'ustchj:p:g:vS:' opt | |||
do | |||
OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]') | |||
case "${opt}" in | |||
@@ -86,6 +99,11 @@ checkopts() | |||
g) | |||
PRODUCT=$OPTARG | |||
;; | |||
S) | |||
check_on_off $OPTARG S | |||
ENABLE_GITEE="$OPTARG" | |||
echo "enable download from gitee" | |||
;; | |||
*) | |||
echo "Undefined option: ${opt}" | |||
usage | |||
@@ -129,6 +147,9 @@ build_graphengine() | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_ST=ON" | |||
fi | |||
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON" | |||
fi | |||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH} -DPLATFORM=${PLATFORM} -DPRODUCT=${PRODUCT}" | |||
echo "${CMAKE_ARGS}" | |||
cmake ${CMAKE_ARGS} .. | |||
@@ -141,14 +162,14 @@ build_graphengine() | |||
TARGET=${COMMON_TARGET} | |||
if [ "x${PLATFORM}" = "xtrain" ] | |||
then | |||
TARGET="ge_runner ge_local_engine ge_local_opskernel_builder host_cpu_engine host_cpu_opskernel_builder ${TARGET}" | |||
TARGET="ge_runner ge_local_engine host_cpu_engine ge_compiler atc_ge_local_engine atc_host_cpu_engine atc ${TARGET}" | |||
elif [ "x${PLATFORM}" = "xinference" ] | |||
then | |||
TARGET="ge_compiler atc_ge_local_engine atc_ge_local_opskernel_builder atc_host_cpu_engine atc_host_cpu_opskernel_builder atc opensrc_ascendcl ${TARGET}" | |||
TARGET="opensrc_ascendcl ${TARGET}" | |||
elif [ "x${PLATFORM}" = "xall" ] | |||
then | |||
# build all the target | |||
TARGET="" | |||
TARGET="ge_runner ge_local_engine host_cpu_engine ge_compiler atc_ge_local_engine atc_host_cpu_engine atc opensrc_ascendcl ${TARGET}" | |||
fi | |||
make ${VERBOSE} ${TARGET} -j${THREAD_NUM} && make install | |||
@@ -255,7 +276,7 @@ generate_package() | |||
fi | |||
for lib in "${PLUGIN_OPSKERNEL[@]}"; | |||
do | |||
find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth ${MAX_DEPTH} -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${OPSKERNEL_PATH} \; | |||
find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${OPSKERNEL_PATH} \; | |||
find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth ${MAX_DEPTH} -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH} \; | |||
done | |||
@@ -280,10 +301,10 @@ generate_package() | |||
if [ "x${PLATFORM}" = "xtrain" ] | |||
then | |||
tar -cf graphengine_lib.tar fwkacllib | |||
tar -cf graphengine_lib.tar fwkacllib atc | |||
elif [ "x${PLATFORM}" = "xinference" ] | |||
then | |||
tar -cf graphengine_lib.tar acllib atc | |||
tar -cf graphengine_lib.tar acllib | |||
elif [ "x${PLATFORM}" = "xall" ] | |||
then | |||
tar -cf graphengine_lib.tar fwkacllib acllib atc | |||
@@ -11,8 +11,16 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||
endif() | |||
if (ENABLE_GITEE) | |||
set(REQ_URL "https://gitee.com/mirrors/gflags/repository/archive/v2.2.2.tar.gz") | |||
set(MD5 "") | |||
else() | |||
set(REQ_URL "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz") | |||
set(MD5 "") | |||
endif () | |||
ExternalProject_Add(gflags_build | |||
URL https://github.com/gflags/gflags/archive/v2.2.2.tar.gz | |||
URL ${REQ_URL} | |||
#URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||
#SOURCE_DIR ${GE_CODE_DIR}/../third_party/gflags/src/gflags-2.2.2 | |||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gflags <SOURCE_DIR> | |||
@@ -5,8 +5,17 @@ endif() | |||
include(ExternalProject) | |||
set(JSON_SRC_DIR ${CMAKE_BINARY_DIR}/opensrc/json/include) | |||
if (ENABLE_GITEE) | |||
set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip") | |||
set(MD5 "5bda78ce308e6cfcf614dcf1d5ff27a7") | |||
set(JSON_INCLUDE_DIR "${JSON_SRC_DIR}/include") | |||
else() | |||
set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip") | |||
set(MD5 "0dc903888211db3a0f170304cd9f3a89") | |||
set(JSON_INCLUDE_DIR ${JSON_SRC_DIR}) | |||
endif () | |||
ExternalProject_Add(json_build | |||
URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip | |||
URL ${REQ_URL} | |||
#URL /home/txd/workspace/cloud_code/pkg/include.zip | |||
SOURCE_DIR ${JSON_SRC_DIR} | |||
CONFIGURE_COMMAND "" | |||
@@ -17,7 +26,7 @@ ExternalProject_Add(json_build | |||
add_library(json INTERFACE) | |||
target_include_directories(json INTERFACE ${JSON_SRC_DIR}) | |||
target_include_directories(json INTERFACE ${JSON_INCLUDE_DIR}) | |||
add_dependencies(json json_build) | |||
#set(HAVE_JSON TRUE CACHE BOOL "json build add") | |||
@@ -6,8 +6,16 @@ set(ONNX_PROTO_DIR ${CMAKE_BINARY_DIR}/onnx) | |||
set(ONNX_PROTO_FILE ${ONNX_PROTO_DIR}/onnx.proto) | |||
file(MAKE_DIRECTORY ${ONNX_PROTO_DIR}) | |||
if (ENABLE_GITEE) | |||
set(REQ_URL "https://gitee.com/mirrors/ONNX/repository/archive/v1.6.0.tar.gz") | |||
set(MD5 "1bdbcecdd68ea8392630467646776e02") | |||
else() | |||
set(REQ_URL "https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz") | |||
set(MD5 "512f2779d6215d4a36f366b6b9acdf1e") | |||
endif () | |||
ExternalProject_Add(onnx | |||
URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz | |||
URL ${REQ_URL} | |||
#URL /home/txd/workspace/cloud_code/pkg/onnx-1.6.0.tar.gz | |||
#URL_HASH SHA256=3b88c3fe521151651a0403c4d131cb2e0311bd28b753ef692020a432a81ce345 | |||
#SOURCE_DIR ${ONNX_SRC_DIR} | |||
@@ -10,10 +10,19 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||
set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) | |||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||
endif() | |||
if (ENABLE_GITEE) | |||
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz") | |||
set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236") | |||
else() | |||
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz") | |||
set(MD5 "3d9e32700639618a4d2d342c99d4507a") | |||
endif () | |||
set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") | |||
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||
ExternalProject_Add(protobuf_build | |||
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz | |||
URL ${REQ_URL} | |||
#URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||
#SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 | |||
#DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 <SOURCE_DIR> | |||
@@ -8,11 +8,19 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||
endif() | |||
if (ENABLE_GITEE) | |||
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz") | |||
set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236") | |||
else() | |||
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz") | |||
set(MD5 "3d9e32700639618a4d2d342c99d4507a") | |||
endif () | |||
set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") | |||
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||
set(PROTOBUF_STATIC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf_static) | |||
ExternalProject_Add(protobuf_static_build | |||
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz | |||
URL ${REQ_URL} | |||
#URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||
#SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 | |||
CONFIGURE_COMMAND ${CMAKE_COMMAND} | |||
@@ -1,103 +1,112 @@ | |||
if (HAVE_PROTOC) | |||
return() | |||
endif() | |||
include(ExternalProject) | |||
include(GNUInstallDirs) | |||
#set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) | |||
if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||
(${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||
set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) | |||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||
endif() | |||
set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") | |||
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||
ExternalProject_Add(protoc_build | |||
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz | |||
#URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||
#SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 | |||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protoc <SOURCE_DIR>/cmake | |||
BUILD_COMMAND $(MAKE) | |||
INSTALL_COMMAND $(MAKE) install | |||
EXCLUDE_FROM_ALL TRUE | |||
) | |||
set(PROTOC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protoc) | |||
set(protoc_EXECUTABLE ${PROTOC_PKG_DIR}/${CMAKE_INSTALL_BINDIR}/protoc) | |||
function(protobuf_generate comp c_var h_var) | |||
if(NOT ARGN) | |||
message(SEND_ERROR "Error: protobuf_generate() called without any proto files") | |||
return() | |||
endif() | |||
set(${c_var}) | |||
set(${h_var}) | |||
foreach(file ${ARGN}) | |||
get_filename_component(abs_file ${file} ABSOLUTE) | |||
get_filename_component(file_name ${file} NAME_WE) | |||
get_filename_component(file_dir ${abs_file} PATH) | |||
get_filename_component(parent_subdir ${file_dir} NAME) | |||
if("${parent_subdir}" STREQUAL "proto") | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
else() | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
endif() | |||
list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") | |||
list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") | |||
add_custom_command( | |||
OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" | |||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
COMMAND ${protoc_EXECUTABLE} -I${file_dir} --cpp_out=${proto_output_path} ${abs_file} | |||
DEPENDS protoc_build ${abs_file} | |||
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||
endforeach() | |||
set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) | |||
set(${c_var} ${${c_var}} PARENT_SCOPE) | |||
set(${h_var} ${${h_var}} PARENT_SCOPE) | |||
endfunction() | |||
function(protobuf_generate_py comp py_var) | |||
if(NOT ARGN) | |||
message(SEND_ERROR "Error: protobuf_generate_py() called without any proto files") | |||
return() | |||
endif() | |||
set(${py_var}) | |||
foreach(file ${ARGN}) | |||
get_filename_component(abs_file ${file} ABSOLUTE) | |||
get_filename_component(file_name ${file} NAME_WE) | |||
get_filename_component(file_dir ${abs_file} PATH) | |||
get_filename_component(parent_subdir ${file_dir} NAME) | |||
if("${parent_subdir}" STREQUAL "proto") | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
else() | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
endif() | |||
list(APPEND ${py_var} "${proto_output_path}/${file_name}_pb2.py") | |||
add_custom_command( | |||
OUTPUT "${proto_output_path}/${file_name}_pb2.py" | |||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
COMMAND ${protoc_EXECUTABLE} -I${file_dir} --python_out=${proto_output_path} ${abs_file} | |||
DEPENDS protoc_build ${abs_file} | |||
COMMENT "Running PYTHON protocol buffer compiler on ${file}" VERBATIM ) | |||
endforeach() | |||
set_source_files_properties(${${py_var}} PROPERTIES GENERATED TRUE) | |||
set(${py_var} ${${py_var}} PARENT_SCOPE) | |||
endfunction() | |||
#set(HAVE_PROTOC TRUE CACHE BOOL "protoc build add") | |||
set(HAVE_PROTOC TRUE) | |||
if (HAVE_PROTOC) | |||
return() | |||
endif() | |||
include(ExternalProject) | |||
include(GNUInstallDirs) | |||
#set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) | |||
if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||
(${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) | |||
set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) | |||
message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | |||
endif() | |||
if (ENABLE_GITEE) | |||
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz") | |||
set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236") | |||
else() | |||
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz") | |||
set(MD5 "3d9e32700639618a4d2d342c99d4507a") | |||
endif () | |||
set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") | |||
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||
ExternalProject_Add(protoc_build | |||
URL ${REQ_URL} | |||
#URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz | |||
#SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 | |||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protoc <SOURCE_DIR>/cmake | |||
BUILD_COMMAND $(MAKE) | |||
INSTALL_COMMAND $(MAKE) install | |||
EXCLUDE_FROM_ALL TRUE | |||
) | |||
set(PROTOC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protoc) | |||
set(protoc_EXECUTABLE ${PROTOC_PKG_DIR}/${CMAKE_INSTALL_BINDIR}/protoc) | |||
function(protobuf_generate comp c_var h_var) | |||
if(NOT ARGN) | |||
message(SEND_ERROR "Error: protobuf_generate() called without any proto files") | |||
return() | |||
endif() | |||
set(${c_var}) | |||
set(${h_var}) | |||
foreach(file ${ARGN}) | |||
get_filename_component(abs_file ${file} ABSOLUTE) | |||
get_filename_component(file_name ${file} NAME_WE) | |||
get_filename_component(file_dir ${abs_file} PATH) | |||
get_filename_component(parent_subdir ${file_dir} NAME) | |||
if("${parent_subdir}" STREQUAL "proto") | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
else() | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
endif() | |||
list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") | |||
list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") | |||
add_custom_command( | |||
OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" | |||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
COMMAND ${protoc_EXECUTABLE} -I${file_dir} --cpp_out=${proto_output_path} ${abs_file} | |||
DEPENDS protoc_build ${abs_file} | |||
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) | |||
endforeach() | |||
set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) | |||
set(${c_var} ${${c_var}} PARENT_SCOPE) | |||
set(${h_var} ${${h_var}} PARENT_SCOPE) | |||
endfunction() | |||
function(protobuf_generate_py comp py_var) | |||
if(NOT ARGN) | |||
message(SEND_ERROR "Error: protobuf_generate_py() called without any proto files") | |||
return() | |||
endif() | |||
set(${py_var}) | |||
foreach(file ${ARGN}) | |||
get_filename_component(abs_file ${file} ABSOLUTE) | |||
get_filename_component(file_name ${file} NAME_WE) | |||
get_filename_component(file_dir ${abs_file} PATH) | |||
get_filename_component(parent_subdir ${file_dir} NAME) | |||
if("${parent_subdir}" STREQUAL "proto") | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) | |||
else() | |||
set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) | |||
endif() | |||
list(APPEND ${py_var} "${proto_output_path}/${file_name}_pb2.py") | |||
add_custom_command( | |||
OUTPUT "${proto_output_path}/${file_name}_pb2.py" | |||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |||
COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | |||
COMMAND ${protoc_EXECUTABLE} -I${file_dir} --python_out=${proto_output_path} ${abs_file} | |||
DEPENDS protoc_build ${abs_file} | |||
COMMENT "Running PYTHON protocol buffer compiler on ${file}" VERBATIM ) | |||
endforeach() | |||
set_source_files_properties(${${py_var}} PROPERTIES GENERATED TRUE) | |||
set(${py_var} ${${py_var}} PARENT_SCOPE) | |||
endfunction() | |||
#set(HAVE_PROTOC TRUE CACHE BOOL "protoc build add") | |||
set(HAVE_PROTOC TRUE) |
@@ -88,7 +88,6 @@ set(TRAIN_SRC_LIST | |||
"graph/load/new_model_manager/model_utils.cc" | |||
"graph/load/new_model_manager/aipp_utils.cc" | |||
"graph/load/new_model_manager/task_info/end_graph_task_info.cc" | |||
"graph/load/new_model_manager/task_info/model_exit_task_info.cc" | |||
"graph/load/new_model_manager/task_info/event_record_task_info.cc" | |||
"graph/load/new_model_manager/task_info/event_wait_task_info.cc" | |||
"graph/load/new_model_manager/task_info/fusion_start_task_info.cc" | |||
@@ -140,7 +139,6 @@ set(TRAIN_SRC_LIST | |||
"graph/passes/mark_graph_unknown_status_pass.cc" | |||
"graph/passes/mark_agnostic_pass.cc" | |||
"graph/partition/dynamic_shape_partition.cc" | |||
"graph/partition/stage_partition.cc" | |||
"graph/passes/base_pass.cc" | |||
"graph/passes/bitcast_pass.cc" | |||
"graph/passes/cast_remove_pass.cc" | |||
@@ -211,7 +209,6 @@ set(TRAIN_SRC_LIST | |||
"graph/passes/multi_batch_pass.cc" | |||
"graph/passes/multi_batch_clone_pass.cc" | |||
"graph/passes/subexpression_migration_pass.cc" | |||
"graph/passes/subgraph_const_migration_pass.cc" | |||
"graph/passes/unused_args_clean_pass.cc" | |||
"graph/passes/net_output_pass.cc" | |||
"graph/passes/next_iteration_pass.cc" | |||
@@ -273,7 +270,6 @@ set(TRAIN_SRC_LIST | |||
"model/ge_root_model.cc" | |||
"omm/csa_interact.cc" | |||
"opskernel_manager/ops_kernel_manager.cc" | |||
"opskernel_manager/ops_kernel_builder_manager.cc" | |||
"session/inner_session.cc" | |||
"session/session_manager.cc" | |||
"single_op/single_op.cc" | |||
@@ -388,8 +384,8 @@ target_link_libraries(ge_runner | |||
resource | |||
error_manager | |||
ascend_hal_stub | |||
-Wl,--as-needed | |||
json | |||
-Wl,--as-needed | |||
-lrt | |||
-ldl | |||
) | |||
@@ -432,7 +428,6 @@ set(INFER_SRC_LIST | |||
"session/session_manager.cc" | |||
"engine_manager/dnnengine_manager.cc" | |||
"opskernel_manager/ops_kernel_manager.cc" | |||
"opskernel_manager/ops_kernel_builder_manager.cc" | |||
"graph/manager/graph_manager.cc" | |||
"graph/manager/graph_manager_utils.cc" | |||
"graph/manager/graph_context.cc" | |||
@@ -448,7 +443,6 @@ set(INFER_SRC_LIST | |||
"graph/partition/engine_place.cc" | |||
"graph/partition/graph_partition.cc" | |||
"graph/partition/dynamic_shape_partition.cc" | |||
"graph/partition/stage_partition.cc" | |||
"generator/ge_generator.cc" | |||
"generator/generator_api.cc" | |||
"graph/manager/graph_var_manager.cc" | |||
@@ -563,7 +557,6 @@ set(INFER_SRC_LIST | |||
"graph/passes/multi_batch_pass.cc" | |||
"graph/passes/multi_batch_clone_pass.cc" | |||
"graph/passes/subexpression_migration_pass.cc" | |||
"graph/passes/subgraph_const_migration_pass.cc" | |||
"graph/passes/unused_args_clean_pass.cc" | |||
"graph/passes/next_iteration_pass.cc" | |||
"graph/passes/control_trigger_pass.cc" | |||
@@ -624,7 +617,6 @@ set(INFER_SRC_LIST | |||
"graph/load/new_model_manager/task_info/stream_switch_task_info.cc" | |||
"graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" | |||
"graph/load/new_model_manager/task_info/end_graph_task_info.cc" | |||
"graph/load/new_model_manager/task_info/model_exit_task_info.cc" | |||
"graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" | |||
"graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" | |||
"single_op/task/op_task.cc" | |||
@@ -719,10 +711,24 @@ target_link_libraries(ge_compiler | |||
############ libascendcl.so ############ | |||
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") | |||
add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) | |||
set(DUMMY_OBJ $<TARGET_OBJECTS:dummy_obj>) | |||
#add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) | |||
#set(DUMMY_OBJ $<TARGET_OBJECTS:dummy_obj>) | |||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object) | |||
add_library(opensrc_ascendcl SHARED ${DUMMY_OBJ}) | |||
if(EXISTS ${STATIC_ACL_LIB}/libascendcl.a) | |||
execute_process( | |||
COMMAND ar x ${STATIC_ACL_LIB}/libascendcl.a | |||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object | |||
) | |||
file(GLOB OBJECT_LIST ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object/*.o) | |||
else() | |||
set(OBJECT_LIST ${CMAKE_BINARY_DIR}/dummy.c) | |||
endif() | |||
add_library(opensrc_ascendcl SHARED | |||
${OBJECT_LIST} | |||
) | |||
target_compile_options(opensrc_ascendcl PRIVATE | |||
-O2 | |||
-fvisibility=hidden | |||
@@ -737,7 +743,6 @@ target_link_options(opensrc_ascendcl PRIVATE | |||
target_link_libraries(opensrc_ascendcl PRIVATE | |||
-Wl,--whole-archive | |||
ge_executor | |||
ascendcl_static | |||
ge_common_static | |||
graph_static | |||
protobuf_static | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -40,34 +40,32 @@ const std::string kFilePath = "./"; | |||
const std::string kAnalyzeFile = "ge_check_op.json"; | |||
const std::string kUnknownShape = "unknownshape"; | |||
const std::string kUnsupport = "unsupport"; | |||
const std::string kUnsupport = "unsupport"; | |||
const std::string kSessionId = "session_id"; | |||
const std::string kGraphId = "graph_id"; | |||
const std::string kOpInfo = "op_info"; | |||
const std::string kGraphId = "graph_id"; | |||
const std::string kOpInfo = "op_info"; | |||
const std::string kErrorType = "error_type"; | |||
const std::string kOpName = "name"; | |||
const std::string kOpType = "type"; | |||
const std::string kReason = "reason"; | |||
const std::string kInput = "input"; | |||
const std::string kOutput = "output"; | |||
const std::string kShape = "shape"; | |||
const std::string kDataType = "data_type"; | |||
const std::string kLayout = "layout"; | |||
const std::string kResult = "result"; | |||
const std::string kOp = "op"; | |||
std::map<analyzer::AnalyzeType, std::string> errors_map { | |||
{PARSER, "paser_error"}, | |||
{INFER_SHAPE, "infer_shape_error"}, | |||
{CHECKSUPPORT, "check_support_error"}, | |||
{GRAPH_OPTIMIZE, "graph_optimize_error"}, | |||
{GRAPH_PARTION, "graph_partion_error"}, | |||
{GRAPH_BUILDER, "graph_builder_error"} | |||
}; | |||
} | |||
Analyzer* Analyzer::GetInstance() { | |||
const std::string kOpName = "name"; | |||
const std::string kOpType = "type"; | |||
const std::string kReason = "reason"; | |||
const std::string kInput = "input"; | |||
const std::string kOutput = "output"; | |||
const std::string kShape = "shape"; | |||
const std::string kDataType = "data_type"; | |||
const std::string kLayout = "layout"; | |||
const std::string kResult = "result"; | |||
const std::string kOp = "op"; | |||
std::map<analyzer::AnalyzeType, std::string> errors_map{{PARSER, "paser_error"}, | |||
{INFER_SHAPE, "infer_shape_error"}, | |||
{CHECKSUPPORT, "check_support_error"}, | |||
{GRAPH_OPTIMIZE, "graph_optimize_error"}, | |||
{GRAPH_PARTION, "graph_partion_error"}, | |||
{GRAPH_BUILDER, "graph_builder_error"}}; | |||
} // namespace | |||
Analyzer *Analyzer::GetInstance() { | |||
static Analyzer instance; | |||
return &instance; | |||
} | |||
@@ -77,8 +75,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||
std::lock_guard<std::recursive_mutex> lg(mutex_); | |||
auto iter = graph_infos_.find(session_id); | |||
if (iter == graph_infos_.end()) { | |||
std::shared_ptr<GraphInfo> graph_info(new(std::nothrow) GraphInfo()); | |||
GE_CHECK_NOTNULL(graph_info); | |||
auto p = new (std::nothrow) GraphInfo(); | |||
GE_CHECK_NOTNULL(p); | |||
std::shared_ptr<GraphInfo> graph_info(p); | |||
std::map<uint64_t, std::shared_ptr<GraphInfo>> graph_map; | |||
graph_map[graph_id] = graph_info; | |||
graph_info->session_id = session_id; | |||
@@ -87,8 +86,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||
} else { | |||
auto iter1 = (iter->second).find(graph_id); | |||
if (iter1 == (iter->second).end()) { | |||
std::shared_ptr<GraphInfo> graph_info(new(std::nothrow) GraphInfo()); | |||
GE_CHECK_NOTNULL(graph_info); | |||
auto p = new (std::nothrow) GraphInfo(); | |||
GE_CHECK_NOTNULL(p); | |||
std::shared_ptr<GraphInfo> graph_info(p); | |||
graph_info->session_id = session_id; | |||
graph_info->graph_id = graph_id; | |||
(iter->second).insert({graph_id, graph_info}); | |||
@@ -100,14 +100,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { | |||
} | |||
ge::Status Analyzer::Initialize() { | |||
// Initialize file | |||
string real_path = RealPath(kFilePath.c_str()); | |||
if (real_path.empty()) { | |||
GELOGE(FAILED, "File path is invalid."); | |||
return FAILED; | |||
} | |||
json_file_name_ = real_path + "/" + kAnalyzeFile; | |||
ClearHistoryFile(); | |||
return SUCCESS; | |||
} | |||
@@ -145,7 +138,6 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) { | |||
if (iter1 == (iter->second).end()) { | |||
GELOGW("Can not find the graph json object by session_id[%lu] and graph_id[%lu]. Do nothing.", session_id, | |||
graph_id); | |||
return; | |||
} | |||
(iter->second).erase(iter1); | |||
} | |||
@@ -182,8 +174,15 @@ ge::Status Analyzer::CreateAnalyzerFile() { | |||
return SUCCESS; | |||
} | |||
GELOGD("start to create analyzer file!"); | |||
// Check whether the manifest exists, if not, create it. | |||
string real_path = RealPath(kFilePath.c_str()); | |||
if (real_path.empty()) { | |||
GELOGE(FAILED, "File path is invalid."); | |||
return FAILED; | |||
} | |||
std::lock_guard<std::mutex> lg(file_mutex_); | |||
json_file_name_ = real_path + "/" + kAnalyzeFile; | |||
GELOGD("Created analyzer file:[%s]", json_file_name_.c_str()); | |||
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | |||
if (fd < 0) { | |||
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); | |||
@@ -199,27 +198,25 @@ ge::Status Analyzer::CreateAnalyzerFile() { | |||
return SUCCESS; | |||
} | |||
ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { | |||
ge::Status Analyzer::SaveAnalyzerDataToFile() { | |||
GELOGD("start to save analyze file!"); | |||
auto graph_info = GetJsonObject(session_id, graph_id); | |||
GE_CHECK_NOTNULL(graph_info); | |||
if (graph_info->op_info.size() == 0) { | |||
GELOGD("session_id:%lu graph_id:%lu does not owner op info, break it!", session_id, graph_id); | |||
return SUCCESS; | |||
} | |||
std::lock_guard<std::mutex> lg(file_mutex_); | |||
json_file_.open(json_file_name_, std::ios::app); | |||
json_file_.open(json_file_name_, std::ios::out); | |||
if (!json_file_.is_open()) { | |||
GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str()); | |||
return PARAM_INVALID; | |||
} | |||
json jsn; | |||
GraphInfoToJson(jsn, *graph_info); | |||
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | |||
json_file_.close(); | |||
std::lock_guard<std::recursive_mutex> lk(mutex_); | |||
for (auto &ele : graph_infos_) { | |||
for (auto &ele2 : ele.second) { | |||
json jsn; | |||
GraphInfoToJson(jsn, *(ele2.second)); | |||
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | |||
} | |||
} | |||
json_file_.close(); | |||
return SUCCESS; | |||
} | |||
@@ -240,7 +237,13 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { | |||
return FAILED; | |||
} | |||
// create json file | |||
return CreateAnalyzerFile(); | |||
status = CreateAnalyzerFile(); | |||
if (status != SUCCESS) { | |||
GELOGE(status, "create analyzer file failed!"); | |||
return status; | |||
} | |||
// save data to file | |||
return SaveAnalyzerDataToFile(); | |||
} | |||
ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | |||
@@ -253,18 +256,18 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | |||
op_info.error_type = iter->second; | |||
op_info.op_name = desc->GetName(); | |||
op_info.op_type = desc->GetType(); | |||
op_info.reason = data_info.reason; | |||
op_info.reason = data_info.reason; | |||
for (const auto &ptr : desc->GetAllInputsDescPtr()) { | |||
TensorInfo tensor_info; | |||
tensor_info.shape = ptr->GetShape().GetDims(); | |||
tensor_info.shape = ptr->GetShape().GetDims(); | |||
tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType()); | |||
tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); | |||
op_info.input_info.emplace_back(tensor_info); | |||
} | |||
for (const auto &ptr : desc->GetAllOutputsDescPtr()) { | |||
TensorInfo tensor_info; | |||
tensor_info.shape = ptr->GetShape().GetDims(); | |||
tensor_info.shape = ptr->GetShape().GetDims(); | |||
tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType()); | |||
tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); | |||
op_info.output_info.emplace_back(tensor_info); | |||
@@ -274,13 +277,13 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, | |||
return SUCCESS; | |||
} | |||
void Analyzer::TensorInfoToJson(json& j, const TensorInfo &tensor_info) { | |||
void Analyzer::TensorInfoToJson(json &j, const TensorInfo &tensor_info) { | |||
j[kShape] = tensor_info.shape; | |||
j[kDataType] = tensor_info.d_type; | |||
j[kLayout] = tensor_info.layout; | |||
} | |||
void Analyzer::OpInfoToJson(json& j, const OpInfo &op_info) { | |||
void Analyzer::OpInfoToJson(json &j, const OpInfo &op_info) { | |||
j[kErrorType] = op_info.error_type; | |||
j[kOpName] = op_info.op_name; | |||
j[kOpType] = op_info.op_type; | |||
@@ -297,7 +300,7 @@ void Analyzer::OpInfoToJson(json& j, const OpInfo &op_info) { | |||
} | |||
} | |||
void Analyzer::GraphInfoToJson(json& j, const GraphInfo &graph_info) { | |||
void Analyzer::GraphInfoToJson(json &j, const GraphInfo &graph_info) { | |||
GELOGD("start to buff graph info!"); | |||
j[kSessionId] = graph_info.session_id; | |||
j[kGraphId] = graph_info.graph_id; | |||
@@ -309,4 +312,4 @@ void Analyzer::GraphInfoToJson(json& j, const GraphInfo &graph_info) { | |||
} | |||
j[kOp] = json_op_infos; | |||
} | |||
} // namespace ge | |||
} // namespace ge |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -33,12 +33,12 @@ | |||
namespace ge { | |||
namespace analyzer { | |||
enum AnalyzeType { | |||
PARSER = 0, | |||
INFER_SHAPE = 1, | |||
CHECKSUPPORT = 2, | |||
PARSER = 0, | |||
INFER_SHAPE = 1, | |||
CHECKSUPPORT = 2, | |||
GRAPH_OPTIMIZE = 3, | |||
GRAPH_PARTION = 4, | |||
GRAPH_BUILDER = 5, | |||
GRAPH_PARTION = 4, | |||
GRAPH_BUILDER = 5, | |||
}; | |||
struct TensorInfo { | |||
@@ -66,8 +66,7 @@ struct DataInfo { | |||
DataInfo() = default; | |||
~DataInfo() = default; | |||
DataInfo(uint64_t sess, uint64_t graph, AnalyzeType type, | |||
ge::NodePtr node, std::string error_info) { | |||
DataInfo(uint64_t sess, uint64_t graph, AnalyzeType type, ge::NodePtr node, std::string error_info) { | |||
session_id = sess; | |||
graph_id = graph; | |||
analyze_type = type; | |||
@@ -80,10 +79,10 @@ struct DataInfo { | |||
ge::NodePtr node_ptr{nullptr}; | |||
std::string reason; | |||
}; | |||
} | |||
} // namespace analyzer | |||
class Analyzer { | |||
public: | |||
public: | |||
/** | |||
* @ingroup ge | |||
* @brief: get analyzer instance. | |||
@@ -157,39 +156,33 @@ public: | |||
*/ | |||
ge::Status DoAnalyze(analyzer::DataInfo &data_info); | |||
/** | |||
* @ingroup ge | |||
* @brief: Buff analyzed data and output to json file | |||
* @param [in]: session id , graph id | |||
* @return: 0: SUCCESS other: FAILED | |||
*/ | |||
ge::Status SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id); | |||
Analyzer(const Analyzer &) = delete; | |||
Analyzer& operator=(const Analyzer&) = delete; | |||
Analyzer &operator=(const Analyzer &) = delete; | |||
Analyzer(Analyzer &&) = delete; | |||
Analyzer& operator=(Analyzer &&) = delete; | |||
private: | |||
void TensorInfoToJson(nlohmann::json& j, const analyzer::TensorInfo &tensor_info); | |||
void OpInfoToJson(nlohmann::json& j, const analyzer::OpInfo &op_info); | |||
void GraphInfoToJson(nlohmann::json& j, const analyzer::GraphInfo &graph_info); | |||
Analyzer &operator=(Analyzer &&) = delete; | |||
private: | |||
void TensorInfoToJson(nlohmann::json &j, const analyzer::TensorInfo &tensor_info); | |||
void OpInfoToJson(nlohmann::json &j, const analyzer::OpInfo &op_info); | |||
void GraphInfoToJson(nlohmann::json &j, const analyzer::GraphInfo &graph_info); | |||
ge::Status SaveAnalyzerDataToFile(); | |||
ge::Status SaveOpInfo(ge::OpDescPtr desc, analyzer::DataInfo &data_info, | |||
std::shared_ptr<analyzer::GraphInfo> graph_info); | |||
std::shared_ptr<analyzer::GraphInfo> graph_info); | |||
void ClearHistoryFile(); | |||
ge::Status CreateAnalyzerFile(); | |||
explicit Analyzer() {}; | |||
explicit Analyzer(){}; | |||
~Analyzer() = default; | |||
private: | |||
private: | |||
std::map<uint64_t, std::map<uint64_t, std::shared_ptr<analyzer::GraphInfo>>> graph_infos_; | |||
std::recursive_mutex mutex_; // protect graph_infos_ | |||
std::mutex file_mutex_; // protect json_file_ | |||
std::recursive_mutex mutex_; // protect graph_infos_ | |||
std::mutex file_mutex_; // protect json_file_ | |||
std::ofstream json_file_; | |||
std::string json_file_name_; | |||
std::atomic_bool is_json_file_create_{false}; | |||
}; | |||
} // namespace ge | |||
#endif // DOMI_ANALYZER_ANANLYZER_H_ | |||
} // namespace ge | |||
#endif // DOMI_ANALYZER_ANANLYZER_H_ |
@@ -384,7 +384,7 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn | |||
} | |||
GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | |||
GELOGW( | |||
"The callback function will not be checked. Please ensure that the implementation of the function is trusted."); | |||
"The callback function will not be checked. Please ensure that the implementation of the function is trusted."); | |||
Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); | |||
if (ret != SUCCESS) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -39,12 +39,12 @@ const std::string kDeviceIdList = "devIdList"; | |||
const std::string kAicoreMetrics = "aicoreMetrics"; | |||
const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToString = { | |||
{ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"}, | |||
{ge::kAicorePipeline, "AICORE_PIPELINE"}, | |||
{ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, | |||
{ge::kAicoreMemory, "AICORE_MEMORY"}, | |||
{ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, | |||
{ge::kAicoreStall, "AICORE_STALL"}}; | |||
{ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"}, | |||
{ge::kAicorePipeline, "AICORE_PIPELINE"}, | |||
{ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, | |||
{ge::kAicoreMemory, "AICORE_MEMORY"}, | |||
{ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, | |||
{ge::kAicoreStall, "AICORE_STALL"}}; | |||
} // namespace | |||
static bool g_graph_prof_init_ = false; | |||
@@ -165,7 +165,7 @@ bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector<str | |||
prof_config_params.push_back(devID); | |||
prof_config_params.push_back(kAicoreMetrics); | |||
auto iter = | |||
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics)); | |||
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics)); | |||
if (iter == kProfAicoreMetricsToString.end()) { | |||
GELOGW("The prof aicore metrics is invalid."); | |||
return false; | |||
@@ -324,17 +324,10 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { | |||
return GE_PROF_NOT_INIT; | |||
} | |||
for (uint32_t i = 0; i < profiler_config->config.devNums; i++) { | |||
uint64_t data_type_config; | |||
Status status = ProfGetDataTypeConfig(profiler_config->config.devIdList[i], data_type_config); | |||
if (status != SUCCESS) { | |||
GELOGE(status, "Prof get data type config failed, prof result = %d", status); | |||
return status; | |||
} | |||
if (data_type_config != profiler_config->config.dataTypeConfig) { | |||
GELOGE(FAILED, "data type config verify failed"); | |||
return FAILED; | |||
} | |||
Status ret = ProfStopProfiling(&profiler_config->config); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Stop profiling failed, prof result = %d", ret); | |||
return ret; | |||
} | |||
std::vector<string> prof_params; | |||
@@ -351,18 +344,12 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { | |||
command.module_index = profiler_config->config.dataTypeConfig; | |||
GELOGI("Profiling will stop, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(), | |||
prof_params[kDeviceListIndex].c_str(), command.module_index); | |||
Status ret = graph_loader.CommandHandle(command); | |||
ret = graph_loader.CommandHandle(command); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Handle profiling command failed"); | |||
return FAILED; | |||
} | |||
ret = ProfStopProfiling(&profiler_config->config); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Stop profiling failed, prof result = %d", ret); | |||
return ret; | |||
} | |||
GELOGI("Successfully execute GraphProfStopProfiling."); | |||
return SUCCESS; | |||
} | |||
@@ -70,9 +70,10 @@ LOCAL_SHARED_LIBRARIES := \ | |||
libregister \ | |||
libge_compiler \ | |||
libge_common \ | |||
libmsprof | |||
libmsprof \ | |||
stub/libascend_hal | |||
LOCAL_STATIC_LIBRARIES := libmsprofiler | |||
LOCAL_LDFLAGS := -lrt -ldl | |||
@@ -107,6 +108,7 @@ LOCAL_SHARED_LIBRARIES := \ | |||
libge_common \ | |||
libmsprof | |||
LOCAL_STATIC_LIBRARIES := libmsprofiler | |||
LOCAL_LDFLAGS := -lrt -ldl | |||
LOCAL_CFLAGS += \ | |||
@@ -1 +1,104 @@ | |||
../../proto/ge_api.proto | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
syntax = "proto3"; | |||
package ge.api_pb; | |||
import "ge_ir.proto"; | |||
// GE initialize | |||
message GEInitialize { | |||
map<string, string> options = 1; | |||
}; | |||
// initialize response | |||
message GEInitializeResponse { | |||
uint32 status = 1; | |||
uint32 clientId = 2; | |||
}; | |||
// GE finalize | |||
message GEFinalize { | |||
bool final = 1; | |||
uint32 clientId = 2; | |||
}; | |||
message GEFinalizeResponse { | |||
uint32 status = 1; | |||
}; | |||
// GE Session | |||
message CreateSession{ | |||
map<string, string> options = 1; | |||
}; | |||
message CreateSessionResponse { | |||
uint32 status = 1; | |||
uint64 sessionId = 2; | |||
}; | |||
//GE AddGraph | |||
//model serialize :: serializegraph | |||
message SessionAddGraph{ | |||
uint32 graphId = 1; | |||
uint64 sessionId = 2; | |||
ge.proto.GraphDef graph = 3; | |||
}; | |||
message SessionAddGraphResponse { | |||
uint32 status = 1; | |||
}; | |||
//GE SessionRemoveGraph | |||
message SessionRemoveGraph{ | |||
uint32 graphId = 1; | |||
uint64 sessionId = 2; | |||
}; | |||
message SessionRemoveGraphResponse { | |||
uint32 status = 1; | |||
}; | |||
message SessionRunGraph{ | |||
uint32 graphId = 1; | |||
uint64 sessionId = 2; | |||
repeated ge.proto.TensorDef tensor = 3; | |||
}; | |||
message SessionBuildGraph{ | |||
uint32 graphId = 1; | |||
uint64 sessionId = 2; | |||
repeated ge.proto.TensorDef tensor = 3; | |||
string savePath = 4; | |||
}; | |||
message SessionRunGraphResponse { | |||
uint32 status = 1; | |||
repeated ge.proto.TensorDef tensor = 2; | |||
}; | |||
message SessionBuildGraphResponse { | |||
uint32 status = 1; | |||
}; | |||
message DestroySession{ | |||
bool final = 1; | |||
uint64 sessionId = 2; | |||
}; | |||
message DestroySessionResponse { | |||
uint32 status = 1; | |||
}; |
@@ -1,3 +1,19 @@ | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
syntax = "proto3"; | |||
package ge.proto; | |||
@@ -1,3 +1,19 @@ | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
syntax = "proto3"; | |||
package domi; | |||
@@ -45,9 +61,6 @@ message AippOpParams { | |||
// 标识对模型的第几个输入做AIPP处理,例如模型有两个输入,需要对第2个输入做AIPP,则配置related_input_rank为1。 | |||
uint32 related_input_rank = 2; | |||
// related_input_name is optional and the top name of data node which inserts aipp | |||
string related_input_name = 6; | |||
// input_edge_idx参数为可选,类型为整型,配置范围为>=0。 | |||
// 配置该参数的作用,在于对Data算子不同的输出做不同的AIPP处理,如果该参数没有配置,默认对related_input_rank指定的模型输入的所有输出边做AIPP。 | |||
// 配置值 <= Data算子输出边的个数。 | |||
@@ -1,14 +1,19 @@ | |||
/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* Apache License for more details at | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
syntax = "proto3"; | |||
package domi; | |||
@@ -1,14 +1,19 @@ | |||
/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* Apache License for more details at | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
syntax = "proto3"; | |||
package domi; | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -55,26 +55,9 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { | |||
Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size == 0 || data == nullptr, return PARAM_INVALID); | |||
mmSsize_t write_count; | |||
uint32_t size_2g = ((uint32_t) 0x1 << 31); | |||
uint32_t size_1g = ((uint32_t) 0x1 << 30); | |||
// Write data | |||
if (size > size_2g) { | |||
auto seek = reinterpret_cast<uint8_t *>(const_cast<void *>(data)); | |||
while (size > size_1g) { | |||
write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size_1g); | |||
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | |||
GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno)); | |||
return FAILED; | |||
} | |||
size -= size_1g; | |||
seek += size_1g; | |||
} | |||
write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size); | |||
} else { | |||
write_count = mmWrite(fd, const_cast<void *>(data), size); | |||
} | |||
// Write data | |||
int32_t write_count = mmWrite(fd, const_cast<void *>(data), size); | |||
// -1: Failed to write to file; - 2: Illegal parameter | |||
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | |||
GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno)); | |||
@@ -116,10 +99,10 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||
ModelPartitionTable &model_partition_table, | |||
const std::vector<ModelPartition> &partition_datas) { | |||
GE_CHK_BOOL_RET_STATUS(!partition_datas.empty() && model_partition_table.num != 0 | |||
&& model_partition_table.num == partition_datas.size(), FAILED, | |||
"Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", | |||
model_partition_table.num, partition_datas.size()); | |||
GE_CHK_BOOL_RET_STATUS( | |||
!partition_datas.empty() && model_partition_table.num != 0 && model_partition_table.num == partition_datas.size(), | |||
FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", model_partition_table.num, | |||
partition_datas.size()); | |||
// Open file | |||
int32_t fd = 0; | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(OpenFile(fd, file_path) != SUCCESS, return FAILED); | |||
@@ -127,18 +110,16 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||
do { | |||
// Write file header | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
WriteData(static_cast<const void *>(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; | |||
break); | |||
WriteData(static_cast<const void *>(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; break); | |||
// Write model partition table | |||
uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
WriteData(static_cast<const void *>(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); | |||
WriteData(static_cast<const void *>(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); | |||
// Write partition data | |||
for (const auto &partitionData : partition_datas) { | |||
GELOGI("GC:size[%zu]", partitionData.size); | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
WriteData(static_cast<const void *>(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; | |||
break); | |||
WriteData(static_cast<const void *>(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; | |||
break); | |||
} | |||
} while (0); | |||
// Close file | |||
@@ -151,9 +132,9 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, | |||
const std::vector<ModelPartition> &partitionDatas, | |||
ge::ModelBufferData &model) { | |||
GE_CHK_BOOL_RET_STATUS( | |||
!partitionDatas.empty() && model_partition_table.num != 0 && model_partition_table.num == partitionDatas.size(), | |||
FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", | |||
model_partition_table.num, partitionDatas.size()); | |||
!partitionDatas.empty() && model_partition_table.num != 0 && model_partition_table.num == partitionDatas.size(), | |||
FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", model_partition_table.num, | |||
partitionDatas.size()); | |||
uint32_t model_header_size = sizeof(ModelFileHeader); | |||
uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); | |||
uint32_t total_size = model_header_size + table_size; | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -74,10 +74,8 @@ class FileSaver { | |||
ModelPartitionTable &model_partition_table, | |||
const std::vector<ModelPartition> &partition_datas); | |||
static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, | |||
ModelPartitionTable &model_partition_table, | |||
const std::vector<ModelPartition> &partitionDatas, | |||
ge::ModelBufferData& model); | |||
static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, | |||
const std::vector<ModelPartition> &partitionDatas, ge::ModelBufferData &model); | |||
static Status SaveToFile(const string &file_path, const void *data, int len); | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -25,24 +25,23 @@ | |||
namespace ge { | |||
namespace { | |||
const char* kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |||
"abcdefghijklmnopqrstuvwxyz" | |||
"0123456789+/"; | |||
const char *kBase64Chars = | |||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |||
"abcdefghijklmnopqrstuvwxyz" | |||
"0123456789+/"; | |||
const char kEqualSymbol = '='; | |||
const size_t kBase64CharsNum = 64; | |||
const size_t kThreeByteOneGroup = 3; | |||
const size_t kFourByteOneGroup = 4; | |||
} | |||
} // namespace | |||
namespace base64 { | |||
static inline bool IsBase64Char(const char &c) { | |||
return (isalnum(c) || (c == '+') || (c == '/')); | |||
} | |||
static inline bool IsBase64Char(const char &c) { return (isalnum(c) || (c == '+') || (c == '/')); } | |||
static std::string EncodeToBase64(const std::string &raw_data) { | |||
size_t encode_length = raw_data.size() / kThreeByteOneGroup * kFourByteOneGroup; | |||
encode_length += raw_data.size() % kThreeByteOneGroup == 0 ? 0 : kFourByteOneGroup; | |||
size_t raw_data_index = 0 ; | |||
size_t raw_data_index = 0; | |||
size_t encode_data_index = 0; | |||
std::string encode_data; | |||
encode_data.resize(encode_length); | |||
@@ -80,8 +79,7 @@ static std::string EncodeToBase64(const std::string &raw_data) { | |||
#pragma GCC diagnostic ignored "-Wunused-function" | |||
static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) { | |||
if (base64_data.size() % kFourByteOneGroup != 0) { | |||
GELOGE(PARAM_INVALID, "base64 data size must can be divided by 4, but given data size is %zu", | |||
base64_data.size()); | |||
GELOGE(PARAM_INVALID, "base64 data size must can be divided by 4, but given data size is %zu", base64_data.size()); | |||
return PARAM_INVALID; | |||
} | |||
decode_data.clear(); | |||
@@ -94,8 +92,7 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco | |||
for (std::size_t input_data_index = 0; input_data_index < base64_data_len; input_data_index += 4) { | |||
for (size_t i = 0; i < kFourByteOneGroup; ++i) { | |||
if (base64_data[input_data_index + i] == kEqualSymbol && | |||
input_data_index >= base64_data_len - 4 && i > 1) { | |||
if (base64_data[input_data_index + i] == kEqualSymbol && input_data_index >= base64_data_len - 4 && i > 1) { | |||
byte_4[i] = kBase64CharsNum; | |||
} else if (IsBase64Char(base64_data[input_data_index + i])) { | |||
byte_4[i] = FindCharInBase64Chars(base64_data[input_data_index + i]); | |||
@@ -105,18 +102,18 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco | |||
} | |||
} | |||
decode_data += static_cast<char>((byte_4[0] << 2u) + ((byte_4[1] & 0x30) >> 4u)); | |||
if (byte_4[2] >= kBase64CharsNum){ | |||
if (byte_4[2] >= kBase64CharsNum) { | |||
break; | |||
} else if (byte_4[3] >= kBase64CharsNum) { | |||
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||
break; | |||
} | |||
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||
decode_data += static_cast<char>(((byte_4[2] & 0x03) << 6u) + byte_4[3]); | |||
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); | |||
decode_data += static_cast<char>(((byte_4[2] & 0x03) << 6u) + byte_4[3]); | |||
} | |||
return SUCCESS; | |||
} | |||
#pragma GCC diagnostic pop | |||
} | |||
} // namespace base64 | |||
} // namespace ge | |||
#endif // GE_COMMON_BASE64_H_ |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -0,0 +1,248 @@ | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
// File: pb2json.h | |||
// Description: This imply file for protobuf message and json interconversion | |||
#include "common/convert/pb2json.h" | |||
#include <set> | |||
#include <string> | |||
#include "securec.h" | |||
#include "framework/common/fmk_types.h" | |||
#include "framework/common/debug/ge_log.h" | |||
using std::set; | |||
using std::string; | |||
namespace ge { | |||
namespace { | |||
const int kSignificantDigits = 10; | |||
} | |||
// JSON parses non utf8 character throwing exceptions, so some fields need to be shielded through black fields | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void Pb2Json::Message2Json(const ProtobufMsg &message, | |||
const set<string> &black_fields, Json &json, | |||
bool enum2str) { | |||
auto descriptor = message.GetDescriptor(); | |||
auto reflection = message.GetReflection(); | |||
if (descriptor == nullptr || reflection == nullptr) { | |||
return; | |||
} | |||
auto count = descriptor->field_count(); | |||
for (auto i = 0; i < count; ++i) { | |||
const auto field = descriptor->field(i); | |||
if (field == nullptr) { | |||
return; | |||
} | |||
// Do not display weight data | |||
if (black_fields.find(field->name()) != black_fields.end()) { | |||
continue; | |||
} | |||
if (field->is_repeated()) { | |||
if (reflection->FieldSize(message, field) > 0) { | |||
RepeatedMessage2Json(message, field, reflection, black_fields, json[field->name()], enum2str); | |||
} | |||
continue; | |||
} | |||
if (!reflection->HasField(message, field)) { | |||
continue; | |||
} | |||
OneField2Json(message, field, reflection, black_fields, json, enum2str); | |||
} | |||
} | |||
void Pb2Json::OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, | |||
const ProtobufReflection *reflection, const set<string> &black_fields, Json &json, | |||
bool enum2str) { | |||
switch (field->type()) { | |||
case ProtobufFieldDescriptor::TYPE_MESSAGE: { | |||
const ProtobufMsg &tmp_message = reflection->GetMessage(message, field); | |||
if (0 != tmp_message.ByteSize()) { | |||
Message2Json(tmp_message, black_fields, json[field->name()], enum2str); | |||
} | |||
break; | |||
} | |||
case ProtobufFieldDescriptor::TYPE_BOOL: | |||
json[field->name()] = reflection->GetBool(message, field); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_ENUM: { | |||
auto *enum_value_desc = reflection->GetEnum(message, field); | |||
Enum2Json(enum_value_desc, field, enum2str, json); | |||
break; | |||
} | |||
case ProtobufFieldDescriptor::TYPE_INT32: | |||
case ProtobufFieldDescriptor::TYPE_SINT32: | |||
case ProtobufFieldDescriptor::TYPE_SFIXED32: | |||
json[field->name()] = reflection->GetInt32(message, field); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_UINT32: | |||
case ProtobufFieldDescriptor::TYPE_FIXED32: | |||
json[field->name()] = reflection->GetUInt32(message, field); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_INT64: | |||
case ProtobufFieldDescriptor::TYPE_SINT64: | |||
case ProtobufFieldDescriptor::TYPE_SFIXED64: | |||
json[field->name()] = reflection->GetInt64(message, field); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_UINT64: | |||
case ProtobufFieldDescriptor::TYPE_FIXED64: | |||
json[field->name()] = reflection->GetUInt64(message, field); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_FLOAT: | |||
char str[kSignificantDigits]; | |||
if (sprintf_s(str, kSignificantDigits, "%g", reflection->GetFloat(message, field)) != -1) { | |||
json[field->name()] = str; | |||
} else { | |||
json[field->name()] = reflection->GetFloat(message, field); | |||
} | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_STRING: | |||
json[field->name()] = reflection->GetString(message, field); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_BYTES: { | |||
string field_name = field->name(); | |||
string type_bytes = reflection->GetString(message, field); | |||
json[field_name] = TypeBytes2String(field_name, type_bytes); | |||
break; | |||
} | |||
default: | |||
break; | |||
} | |||
} | |||
string Pb2Json::TypeBytes2String(string &field_name, string &type_bytes) { | |||
if (field_name != "offset") { | |||
return type_bytes; | |||
} | |||
string result = ""; | |||
for (char temp_value : type_bytes) { | |||
uint8_t *value = 0; | |||
value = reinterpret_cast<uint8_t *>(&temp_value); | |||
char str[kSignificantDigits]; | |||
if (sprintf_s(str, kSignificantDigits, "%d", *value) == -1) { | |||
GELOGW("Convert bytes to string fail, filed name:%s", field_name.c_str()); | |||
continue; | |||
} | |||
result += str; | |||
} | |||
return result; | |||
} | |||
void Pb2Json::RepeatedMessage2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, | |||
const ProtobufReflection *reflection, const set<string> &black_fields, Json &json, | |||
bool enum2str) { | |||
if ((field == nullptr) || (reflection == nullptr)) { | |||
Message2Json(message, black_fields, json, enum2str); | |||
return; | |||
} | |||
for (auto i = 0; i < reflection->FieldSize(message, field); ++i) { | |||
Json tmp_json; | |||
switch (field->type()) { | |||
case ProtobufFieldDescriptor::TYPE_MESSAGE: { | |||
const ProtobufMsg &tmp_message = reflection->GetRepeatedMessage(message, field, i); | |||
if (0 != tmp_message.ByteSize()) { | |||
Message2Json(tmp_message, black_fields, tmp_json, enum2str); | |||
} | |||
} break; | |||
case ProtobufFieldDescriptor::TYPE_BOOL: | |||
tmp_json = reflection->GetRepeatedBool(message, field, i); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_ENUM: { | |||
auto *enum_value_desc = reflection->GetRepeatedEnum(message, field, i); | |||
RepeatedEnum2Json(enum_value_desc, enum2str, tmp_json); | |||
} break; | |||
case ProtobufFieldDescriptor::TYPE_INT32: | |||
case ProtobufFieldDescriptor::TYPE_SINT32: | |||
case ProtobufFieldDescriptor::TYPE_SFIXED32: | |||
tmp_json = reflection->GetRepeatedInt32(message, field, i); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_UINT32: | |||
case ProtobufFieldDescriptor::TYPE_FIXED32: | |||
tmp_json = reflection->GetRepeatedUInt32(message, field, i); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_INT64: | |||
case ProtobufFieldDescriptor::TYPE_SINT64: | |||
case ProtobufFieldDescriptor::TYPE_SFIXED64: | |||
tmp_json = reflection->GetRepeatedInt64(message, field, i); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_UINT64: | |||
case ProtobufFieldDescriptor::TYPE_FIXED64: | |||
tmp_json = reflection->GetRepeatedUInt64(message, field, i); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_FLOAT: | |||
tmp_json = reflection->GetRepeatedFloat(message, field, i); | |||
break; | |||
case ProtobufFieldDescriptor::TYPE_STRING: | |||
case ProtobufFieldDescriptor::TYPE_BYTES: | |||
tmp_json = reflection->GetRepeatedString(message, field, i); | |||
break; | |||
default: | |||
break; | |||
} | |||
json += tmp_json; | |||
} | |||
} | |||
void Pb2Json::Enum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, const ProtobufFieldDescriptor *field, | |||
bool enum2str, Json &json) { | |||
if (enum_value_desc != nullptr) { | |||
if (field == nullptr) { | |||
return; | |||
} | |||
if (enum2str) { | |||
json[field->name()] = enum_value_desc->name(); | |||
} else { | |||
json[field->name()] = enum_value_desc->number(); | |||
} | |||
} | |||
} | |||
void Pb2Json::RepeatedEnum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, bool enum2str, Json &json) { | |||
if (enum_value_desc != nullptr) { | |||
if (enum2str) { | |||
json = enum_value_desc->name(); | |||
} else { | |||
json = enum_value_desc->number(); | |||
} | |||
} | |||
} | |||
} // namespace ge |
@@ -0,0 +1,68 @@ | |||
/** | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
// File: pb2json.h | |||
// Description: This header file for protobuf message and json interconversion | |||
#ifndef GE_COMMON_CONVERT_PB2JSON_H_ | |||
#define GE_COMMON_CONVERT_PB2JSON_H_ | |||
#include <functional> | |||
#include <memory> | |||
#include <set> | |||
#include <string> | |||
#include "google/protobuf/descriptor.h" | |||
#include "google/protobuf/message.h" | |||
#include "nlohmann/json.hpp" | |||
namespace ge { | |||
using Json = nlohmann::json; | |||
using ProtobufMsg = ::google::protobuf::Message; | |||
using ProtobufReflection = ::google::protobuf::Reflection; | |||
using ProtobufFieldDescriptor = ::google::protobuf::FieldDescriptor; | |||
using ProtobufDescriptor = ::google::protobuf::Descriptor; | |||
using ProtobufEnumValueDescriptor = ::google::protobuf::EnumValueDescriptor; | |||
class Pb2Json { | |||
public: | |||
/** | |||
* @ingroup domi_omg | |||
* @brief Transfer protobuf object to JSON object | |||
* @param [out] json Converted JSON object | |||
* @return void success | |||
* @author | |||
*/ | |||
static void Message2Json(const ProtobufMsg &message, const std::set<std::string> &black_fields, Json &json, | |||
bool enum2str = false); | |||
protected: | |||
static void RepeatedMessage2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, | |||
const ProtobufReflection *reflection, const std::set<std::string> &black_fields, | |||
Json &json, bool enum2str); | |||
static void Enum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, const ProtobufFieldDescriptor *field, | |||
bool enum2str, Json &json); | |||
static void RepeatedEnum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, bool enum2str, Json &json); | |||
static void OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, | |||
const ProtobufReflection *reflection, const std::set<std::string> &black_fields, Json &json, | |||
bool enum2str); | |||
static std::string TypeBytes2String(std::string &field_name, std::string &type_bytes); | |||
}; | |||
} // namespace ge | |||
#endif // GE_COMMON_CONVERT_PB2JSON_H_ |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -20,9 +20,7 @@ namespace ge { | |||
CustAICPUKernelStore::CustAICPUKernelStore() {} | |||
void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { | |||
AddKernel(kernel); | |||
} | |||
void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { AddKernel(kernel); } | |||
void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr<ge::OpDesc> &op_desc) const { | |||
GELOGI("LoadCustAICPUKernelBinToOpDesc in"); | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -252,4 +252,4 @@ Status DumpOp::LaunchDumpOp() { | |||
} | |||
return SUCCESS; | |||
} | |||
} // namesapce ge | |||
} // namespace ge |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -35,14 +35,14 @@ const std::string kDumpStatusOpen = "on"; | |||
const uint32_t kAicoreOverflow = (0x1 << 0); | |||
const uint32_t kAtomicOverflow = (0x1 << 1); | |||
const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | |||
} | |||
} // namespace | |||
namespace ge { | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) { | |||
CopyFrom(other); | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=( | |||
const DumpProperties &other) { | |||
const DumpProperties &other) { | |||
CopyFrom(other); | |||
return *this; | |||
} | |||
@@ -97,7 +97,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::InitByOpti | |||
// The following is the new dump scenario of the fusion operator | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue( | |||
const std::string &model, const std::set<std::string> &layers) { | |||
const std::string &model, const std::set<std::string> &layers) { | |||
for (const std::string &layer : layers) { | |||
GELOGI("This model %s config to dump layer %s", model.c_str(), layer.c_str()); | |||
} | |||
@@ -136,7 +136,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpPrope | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetPropertyValue( | |||
const std::string &model) const { | |||
const std::string &model) const { | |||
auto iter = model_dump_properties_map_.find(model); | |||
if (iter != model_dump_properties_map_.end()) { | |||
return iter->second; | |||
@@ -145,7 +145,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpPrope | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsLayerNeedDump( | |||
const std::string &model, const std::string &om_name, const std::string &op_name) const { | |||
const std::string &model, const std::string &om_name, const std::string &op_name) const { | |||
// if dump all | |||
if (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { | |||
return true; | |||
@@ -201,7 +201,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperti | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch( | |||
const std::string dump_op_switch) { | |||
const std::string &dump_op_switch) { | |||
dump_op_switch_ = dump_op_switch; | |||
} | |||
@@ -266,4 +266,4 @@ void DumpProperties::SetDumpDebugOptions() { | |||
GELOGI("ge.exec.enableDumpDebug is false or is not set."); | |||
} | |||
} | |||
} // namespace | |||
} // namespace ge |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -65,7 +65,7 @@ class DumpProperties { | |||
const std::string &GetDumpStatus() const; | |||
void SetDumpOpSwitch(const std::string dump_op_switch); | |||
void SetDumpOpSwitch(const std::string &dump_op_switch); | |||
const std::string &GetDumpOpSwitch() const; | |||
@@ -77,9 +77,9 @@ class DumpProperties { | |||
uint32_t GetOpDebugMode() const { return op_debug_mode_; } | |||
const std::string &GetEnableDump() const {return enable_dump_;} | |||
const std::string &GetEnableDump() const { return enable_dump_; } | |||
const std::string &GetEnableDumpDebug() const {return enable_dump_debug_;} | |||
const std::string &GetEnableDumpDebug() const { return enable_dump_debug_; } | |||
private: | |||
void CopyFrom(const DumpProperties &other); | |||
@@ -99,6 +99,6 @@ class DumpProperties { | |||
bool is_op_debug_ = false; | |||
uint32_t op_debug_mode_ = 0; | |||
}; | |||
} | |||
} // namespace ge | |||
#endif //GE_COMMON_DUMP_DUMP_PROPERTIES_H_ | |||
#endif // GE_COMMON_DUMP_DUMP_PROPERTIES_H_ |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -89,8 +89,8 @@ Status TransDataSrc2Fp16(const CastArgs &args, uint8_t *dst, const size_t data_s | |||
} | |||
Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, const DataTypeTransMode trans_mode) { | |||
static std::map<DataTypeTransMode, std::function<Status(const CastArgs &, uint8_t *, const size_t)>> | |||
transfer_handle = { | |||
static std::map<DataTypeTransMode, std::function<Status(const CastArgs &, uint8_t *, const size_t)>> transfer_handle = | |||
{ | |||
{kTransferWithDatatypeFloatToFloat16, TransDataSrc2Fp16<float>}, | |||
{kTransferWithDatatypeFloatToInt32, TransDataSrc2Dst<float, int32_t>}, | |||
{kTransferWithDatatypeFloat16ToFloat, TransDataSrc2Dst<fp16_t, float>}, | |||
@@ -107,7 +107,7 @@ Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, co | |||
{kTransferWithDatatypeInt32ToInt64, TransDataSrc2Dst<int32_t, int64_t>}, | |||
{kTransferWithDatatypeInt32ToDouble, TransDataSrc2Dst<int32_t, double>}, | |||
{kTransferWithDatatypeDoubleToInt32, TransDataSrc2Dst<double, int32_t>}, | |||
}; | |||
}; | |||
auto it = transfer_handle.find(trans_mode); | |||
if (it == transfer_handle.end()) { | |||
return UNSUPPORTED; | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -105,8 +105,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size | |||
auto dst_offset = dst_idx * size; | |||
// The memcpy_s/memset_s argument `dstMax` must be less than 2G | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -13,6 +13,7 @@ | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
#include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" | |||
#include <securec.h> | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -13,6 +13,7 @@ | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
#ifndef GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWCN_FRACTAL_Z_3D_H_ | |||
#define GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWCN_FRACTAL_Z_3D_H_ | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -13,6 +13,7 @@ | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
#include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" | |||
#include <securec.h> | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -13,6 +13,7 @@ | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
#ifndef GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWNC_FRACTAL_Z_3D_TRANSPOSE_H_ | |||
#define GE_COMMON_FORMATS_FORMAT_TRANSFERS_FORMAT_TRANSFER_DHWNC_FRACTAL_Z_3D_TRANSPOSE_H_ | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -154,8 +154,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con | |||
for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { | |||
auto dst_offset = (h1h0_head + w1_idx * h1h0w0) * size; | |||
auto src_offset = (src_h_head + w1_idx * w0) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size * w0)); | |||
if (ret != EOK) { | |||
@@ -168,8 +169,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con | |||
auto src_w_idx = w1_head + w0_idx; | |||
auto dst_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; | |||
auto src_offset = (src_h_head + src_w_idx) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -225,8 +227,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con | |||
for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { | |||
auto src_offset = (h1h0_head + w1_idx * h1h0w0) * size; | |||
auto dst_offset = (dst_h_head + w1_idx * w0) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size * w0)); | |||
if (ret != EOK) { | |||
@@ -239,8 +242,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con | |||
auto dst_w_idx = w1_head + w0_idx; | |||
auto src_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; | |||
auto dst_offset = (dst_h_head + dst_w_idx) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
dst_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -124,11 +124,11 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
dst == nullptr, | |||
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
return OUT_OF_MEMORY;); | |||
dst == nullptr, | |||
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
return OUT_OF_MEMORY;); | |||
for (int64_t vfi = 0; vfi < vf_cnt; vfi++) { | |||
// vertical fractal matrix base index | |||
@@ -152,8 +152,8 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { | |||
auto idx = gfi * fractal_ele_cnt + col * c0 + row; | |||
auto offset = idx * size; | |||
auto protected_size = dst_size - offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
errno_t ret = EOK; | |||
if (need_pad_zero) { | |||
ret = memset_s(dst.get() + offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
@@ -209,11 +209,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
dst == nullptr, | |||
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
return OUT_OF_MEMORY;); | |||
dst == nullptr, | |||
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
return OUT_OF_MEMORY;); | |||
for (int64_t c1i = 0; c1i < c1; c1i++) { | |||
for (int64_t hi = 0; hi < h; hi++) { | |||
@@ -223,8 +223,8 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { | |||
int64_t dst_idx = c1i * hwn1n0c0 + hi * wn1n0c0 + wi * n1n0c0 + n1n0i * c0 + c0i; | |||
int64_t dst_offset = dst_idx * data_size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); | |||
errno_t ret = EOK; | |||
if (pad_zero) { | |||
@@ -284,11 +284,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | |||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
dst == nullptr, | |||
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
return OUT_OF_MEMORY;); | |||
dst == nullptr, | |||
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
return OUT_OF_MEMORY;); | |||
for (int64_t c1i = 0; c1i < c1; c1i++) { | |||
for (int64_t hi = 0; hi < h; hi++) { | |||
@@ -298,8 +298,8 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { | |||
int64_t dst_idx = c1i * hwn1n0c0 + hi * wn1n0c0 + wi * n1n0c0 + n1n0i * c0 + c0i; | |||
int64_t dst_offset = dst_idx * data_size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); | |||
errno_t ret = EOK; | |||
if (pad_zero) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2019 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -158,8 +158,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con | |||
auto src_offset = (src_h_head + w1_idx * w0) * size; | |||
auto dst_offset = (h0_head + w1_idx * h0w0) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size * w0)); | |||
if (ret != EOK) { | |||
@@ -174,8 +174,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con | |||
auto src_offset = (src_h_head + src_w_idx) * size; | |||
auto dst_offset = (w0_head + w0_idx) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -236,8 +236,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con | |||
auto src_offset = (h0_head + w1_idx * h0w0) * size; | |||
auto dst_offset = (dst_h_head + w1_idx * w0) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size * w0)); | |||
if (ret != EOK) { | |||
@@ -252,8 +252,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con | |||
auto dst_w_idx = w1_head + w0_idx; | |||
auto dst_offset = (dst_h_head + dst_w_idx) * size; | |||
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2019 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -104,8 +104,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | |||
auto src_offset = src_idx * size; | |||
auto dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
total_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -139,7 +140,7 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & | |||
} | |||
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return PARAM_INVALID; | |||
} | |||
GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -104,8 +104,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | |||
auto src_offset = src_idx * size; | |||
auto dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
total_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -139,7 +140,7 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & | |||
} | |||
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return PARAM_INVALID; | |||
} | |||
GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -104,8 +104,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size | |||
int64_t src_idx = c1_idx * hwncc0 + h_idx * wncc0 + w_idx * ncc0 + nc_idx * c0 + c0_idx; | |||
auto src_offset = src_idx * size; | |||
auto dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) ? | |||
total_size - dst_offset : static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -138,7 +139,7 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & | |||
} | |||
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return PARAM_INVALID; | |||
} | |||
GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -122,8 +122,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
int64_t dst_idx = c0_idx + co_head_addr; | |||
auto dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
int64_t c_idx = c0_idx + c1_idx * c0; | |||
int64_t src_idx = h_idx * wcn + w_idx * cn + c_idx * n + n_idx; | |||
auto src_offset = src_idx * size; | |||
@@ -141,7 +141,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
} | |||
} else { | |||
auto ret = | |||
memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(INTERNAL_ERROR, | |||
"Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -102,8 +102,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
auto src_offset = src_idx * size; | |||
auto dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -102,8 +102,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
auto src_offset = src_idx * size; | |||
auto dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -115,8 +115,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
int64_t dst_index = c0_idx + w_head_addr; | |||
int64_t dst_offset = dst_index * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
int64_t cIdx = c0_idx + c1_idx * c0; | |||
int64_t srcIdx = n_idx * chw + cIdx * hw + h_idx * w + w_idx; | |||
auto src_offset = srcIdx * size; | |||
@@ -133,7 +133,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
} | |||
} else { | |||
auto ret = | |||
memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(INTERNAL_ERROR, | |||
"Failed to set to 0 to " | |||
@@ -173,10 +173,10 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult | |||
return PARAM_INVALID; | |||
} | |||
GELOGD( | |||
"Begin to trans format from NCHW to NC1HWC0, src shape %s, data type " | |||
"%s, dst shape %s memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
"Begin to trans format from NCHW to NC1HWC0, src shape %s, data type " | |||
"%s, dst shape %s memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { | |||
GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -119,8 +119,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
int64_t dst_idx = c0_idx + w_head_addr; | |||
int64_t dst_offset = dst_idx * size; | |||
auto protected_size = total_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? total_size - dst_offset | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
int64_t c_idx = c0_idx + c1_idx * c0; | |||
int64_t src_idx = n_idx * hwc + h_idx * wc + w_idx * c + c_idx; | |||
auto src_offset = src_idx * size; | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -28,22 +28,22 @@ namespace ge { | |||
namespace formats { | |||
namespace { | |||
std::map<Format, std::map<Format, std::vector<int64_t>>> perm_args{ | |||
{FORMAT_NCHW, | |||
{{FORMAT_NHWC, std::vector<int64_t>({0, 2, 3, 1})}, | |||
{FORMAT_HWCN, std::vector<int64_t>({2, 3, 1, 0})}, | |||
{FORMAT_CHWN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||
{FORMAT_NHWC, | |||
{{FORMAT_NCHW, std::vector<int64_t>({0, 3, 1, 2})}, | |||
{FORMAT_CHWN, std::vector<int64_t>({3, 1, 2, 0})}, | |||
{FORMAT_HWCN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||
{FORMAT_HWCN, | |||
{{FORMAT_NCHW, std::vector<int64_t>({3, 2, 0, 1})}, | |||
{FORMAT_NHWC, std::vector<int64_t>({3, 0, 1, 2})}, | |||
{FORMAT_CHWN, std::vector<int64_t>({2, 0, 1, 3})}}}, | |||
{FORMAT_CHWN, | |||
{{FORMAT_NCHW, std::vector<int64_t>({3, 0, 1, 2})}, | |||
{FORMAT_NHWC, std::vector<int64_t>({3, 1, 2, 0})}, | |||
{FORMAT_HWCN, std::vector<int64_t>({1, 2, 0, 3})}}}, | |||
{FORMAT_NCHW, | |||
{{FORMAT_NHWC, std::vector<int64_t>({0, 2, 3, 1})}, | |||
{FORMAT_HWCN, std::vector<int64_t>({2, 3, 1, 0})}, | |||
{FORMAT_CHWN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||
{FORMAT_NHWC, | |||
{{FORMAT_NCHW, std::vector<int64_t>({0, 3, 1, 2})}, | |||
{FORMAT_CHWN, std::vector<int64_t>({3, 1, 2, 0})}, | |||
{FORMAT_HWCN, std::vector<int64_t>({1, 2, 3, 0})}}}, | |||
{FORMAT_HWCN, | |||
{{FORMAT_NCHW, std::vector<int64_t>({3, 2, 0, 1})}, | |||
{FORMAT_NHWC, std::vector<int64_t>({3, 0, 1, 2})}, | |||
{FORMAT_CHWN, std::vector<int64_t>({2, 0, 1, 3})}}}, | |||
{FORMAT_CHWN, | |||
{{FORMAT_NCHW, std::vector<int64_t>({3, 0, 1, 2})}, | |||
{FORMAT_NHWC, std::vector<int64_t>({3, 1, 2, 0})}, | |||
{FORMAT_HWCN, std::vector<int64_t>({1, 2, 0, 3})}}}, | |||
}; | |||
bool IsShapeArgValid(const std::vector<int64_t> &src_shape, const std::vector<int64_t> &perm_arg) { | |||
@@ -163,8 +163,8 @@ Status Transpose(const uint8_t *src, const std::vector<int64_t> &src_shape, Data | |||
auto src_offset = GenOffset(src_heads, dst_indexes) * data_size; | |||
auto dst_offset_bytes = dst_index * data_size; | |||
auto protected_size = dst_size - dst_offset_bytes < static_cast<int64_t>(SECUREC_MEM_MAX_LEN) | |||
? dst_size - dst_offset_bytes | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
? dst_size - dst_offset_bytes | |||
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN); | |||
auto ret = memcpy_s(dst.get() + dst_offset_bytes, static_cast<size_t>(protected_size), src + src_offset, | |||
static_cast<size_t>(data_size)); | |||
if (ret != EOK) { | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -33,7 +33,6 @@ Status TransposeWithShapeCheck(const uint8_t *src, const std::vector<int64_t> &s | |||
Status GetPermByForamt(Format src_format, Format dst_format, std::vector<int64_t> &perm); | |||
class FormatTransferTranspose : public FormatTransfer { | |||
public: | |||
Status TransFormat(const TransArgs &args, TransResult &result) override; | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2019 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -51,8 +51,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArg | |||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_format, | |||
const std::vector<int64_t> &src_shape, | |||
DataType data_type, | |||
Format dst_format, | |||
DataType data_type, Format dst_format, | |||
std::vector<int64_t> &dst_shape) { | |||
formats::TransArgs args; | |||
args.src_format = src_format; | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -36,8 +36,8 @@ namespace formats { | |||
*/ | |||
Status TransFormat(const TransArgs &args, TransResult &result); | |||
Status TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type, | |||
Format dst_format, std::vector<int64_t> &dst_shape); | |||
Status TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type, Format dst_format, | |||
std::vector<int64_t> &dst_shape); | |||
Status TransDataType(const CastArgs &args, TransResult &result); | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2019 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -23,38 +23,13 @@ static const int kCubeSize = 16; | |||
static const int kNiSize = 16; | |||
static const int64_t kShapeItemNumMAX = 1024UL * 1024UL * 1024UL * 1024UL; | |||
enum NchwDimIndex { | |||
kNchwN, | |||
kNchwC, | |||
kNchwH, | |||
kNchwW, | |||
kNchwDimsNum | |||
}; | |||
enum NchwDimIndex { kNchwN, kNchwC, kNchwH, kNchwW, kNchwDimsNum }; | |||
enum NhwcDimIndex { | |||
kNhwcN, | |||
kNhwcH, | |||
kNhwcW, | |||
kNhwcC, | |||
kNhwcDimsNum | |||
}; | |||
enum NhwcDimIndex { kNhwcN, kNhwcH, kNhwcW, kNhwcC, kNhwcDimsNum }; | |||
enum HwcnDimIndex { | |||
kHwcnH, | |||
kHwcnW, | |||
kHwcnC, | |||
kHwcnN, | |||
kHwcnDimsNum | |||
}; | |||
enum HwcnDimIndex { kHwcnH, kHwcnW, kHwcnC, kHwcnN, kHwcnDimsNum }; | |||
enum Nc1hwc0DimIndex { | |||
kNc1hwc0N, | |||
kNc1hwc0C1, | |||
kNc1hwc0H, | |||
kNc1hwc0W, | |||
kNc1hwc0C0, | |||
kNc1hwc0DimsNum | |||
}; | |||
enum Nc1hwc0DimIndex { kNc1hwc0N, kNc1hwc0C1, kNc1hwc0H, kNc1hwc0W, kNc1hwc0C0, kNc1hwc0DimsNum }; | |||
enum C1hwncoc0DimIndex { | |||
kC1hwncoc0C1, | |||
@@ -66,31 +41,11 @@ enum C1hwncoc0DimIndex { | |||
kC1hwncoc0DimsNum | |||
}; | |||
enum FracZDimIndex { | |||
kFracZHWC1, | |||
kFracZN0, | |||
kFracZNi, | |||
kFracZC0, | |||
kFracZDimsNum | |||
}; | |||
enum FracZDimIndex { kFracZHWC1, kFracZN0, kFracZNi, kFracZC0, kFracZDimsNum }; | |||
enum DhwcnDimIndex { | |||
kDhwcnD, | |||
kDhwcnH, | |||
kDhwcnW, | |||
kDhwcnC, | |||
kDhwcnN, | |||
kDhwcnDimsNum | |||
}; | |||
enum DhwcnDimIndex { kDhwcnD, kDhwcnH, kDhwcnW, kDhwcnC, kDhwcnN, kDhwcnDimsNum }; | |||
enum DhwncDimIndex { | |||
kDhwncD, | |||
kDhwncH, | |||
kDhwncW, | |||
kDhwncN, | |||
kDhwncC, | |||
kDhwncDimsNum | |||
}; | |||
enum DhwncDimIndex { kDhwncD, kDhwncH, kDhwncW, kDhwncN, kDhwncC, kDhwncDimsNum }; | |||
} // namespace formats | |||
} // namespace ge | |||
#endif // GE_COMMON_FORMATS_UTILS_FORMATS_DEFINITIONS_H_ |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2019 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -22,46 +22,46 @@ | |||
namespace { | |||
const std::vector<ge::DataType> kEmptyDatatypeVector; | |||
std::map<ge::DataType, std::vector<ge::DataType>> g_translatable_data_type = { | |||
// key:src datatype, value:dst datatype | |||
{ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}, | |||
{ge::DT_BOOL, {ge::DT_INT32}}, | |||
{ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||
{ge::DT_INT64, {ge::DT_INT32}}}; | |||
// key:src datatype, value:dst datatype | |||
{ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}, | |||
{ge::DT_BOOL, {ge::DT_INT32}}, | |||
{ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||
{ge::DT_INT64, {ge::DT_INT32}}}; | |||
std::map<ge::DataType, std::vector<ge::DataType>> g_reverse_translatable_data_type = { | |||
// key:dst datatype,value:src datatype | |||
{ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||
{ge::DT_INT32, {ge::DT_BOOL, ge::DT_INT64}}, | |||
{ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}}; | |||
// key:dst datatype,value:src datatype | |||
{ge::DT_FLOAT16, {ge::DT_FLOAT, ge::DT_FLOAT16}}, | |||
{ge::DT_INT32, {ge::DT_BOOL, ge::DT_INT64}}, | |||
{ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}}; | |||
std::map<ge::DataType, ge::proto::DataType> g_dump_data_type_map = { | |||
// key:ge datatype,value:proto datatype | |||
{ge::DT_UNDEFINED, ge::proto::DT_UNDEFINED}, | |||
{ge::DT_FLOAT, ge::proto::DT_FLOAT}, | |||
{ge::DT_FLOAT16, ge::proto::DT_FLOAT16}, | |||
{ge::DT_INT8, ge::proto::DT_INT8}, | |||
{ge::DT_UINT8, ge::proto::DT_UINT8}, | |||
{ge::DT_INT16, ge::proto::DT_INT16}, | |||
{ge::DT_UINT16, ge::proto::DT_UINT16}, | |||
{ge::DT_INT32, ge::proto::DT_INT32}, | |||
{ge::DT_INT64, ge::proto::DT_INT64}, | |||
{ge::DT_UINT32, ge::proto::DT_UINT32}, | |||
{ge::DT_UINT64, ge::proto::DT_UINT64}, | |||
{ge::DT_BOOL, ge::proto::DT_BOOL}, | |||
{ge::DT_DOUBLE, ge::proto::DT_DOUBLE}, | |||
{ge::DT_DUAL, ge::proto::DT_DUAL}, | |||
{ge::DT_DUAL_SUB_INT8, ge::proto::DT_DUAL_SUB_INT8}, | |||
{ge::DT_DUAL_SUB_UINT8, ge::proto::DT_DUAL_SUB_UINT8}, | |||
{ge::DT_COMPLEX64, ge::proto::DT_COMPLEX64}, | |||
{ge::DT_COMPLEX128, ge::proto::DT_COMPLEX128}, | |||
{ge::DT_QINT8, ge::proto::DT_QINT8}, | |||
{ge::DT_QINT16, ge::proto::DT_QINT16}, | |||
{ge::DT_QINT32, ge::proto::DT_QINT32}, | |||
{ge::DT_QUINT8, ge::proto::DT_QUINT8}, | |||
{ge::DT_QUINT16, ge::proto::DT_QUINT16}, | |||
{ge::DT_RESOURCE, ge::proto::DT_RESOURCE}, | |||
{ge::DT_STRING_REF, ge::proto::DT_STRING_REF}, | |||
{ge::DT_STRING, ge::proto::DT_STRING}, | |||
// key:ge datatype,value:proto datatype | |||
{ge::DT_UNDEFINED, ge::proto::DT_UNDEFINED}, | |||
{ge::DT_FLOAT, ge::proto::DT_FLOAT}, | |||
{ge::DT_FLOAT16, ge::proto::DT_FLOAT16}, | |||
{ge::DT_INT8, ge::proto::DT_INT8}, | |||
{ge::DT_UINT8, ge::proto::DT_UINT8}, | |||
{ge::DT_INT16, ge::proto::DT_INT16}, | |||
{ge::DT_UINT16, ge::proto::DT_UINT16}, | |||
{ge::DT_INT32, ge::proto::DT_INT32}, | |||
{ge::DT_INT64, ge::proto::DT_INT64}, | |||
{ge::DT_UINT32, ge::proto::DT_UINT32}, | |||
{ge::DT_UINT64, ge::proto::DT_UINT64}, | |||
{ge::DT_BOOL, ge::proto::DT_BOOL}, | |||
{ge::DT_DOUBLE, ge::proto::DT_DOUBLE}, | |||
{ge::DT_DUAL, ge::proto::DT_DUAL}, | |||
{ge::DT_DUAL_SUB_INT8, ge::proto::DT_DUAL_SUB_INT8}, | |||
{ge::DT_DUAL_SUB_UINT8, ge::proto::DT_DUAL_SUB_UINT8}, | |||
{ge::DT_COMPLEX64, ge::proto::DT_COMPLEX64}, | |||
{ge::DT_COMPLEX128, ge::proto::DT_COMPLEX128}, | |||
{ge::DT_QINT8, ge::proto::DT_QINT8}, | |||
{ge::DT_QINT16, ge::proto::DT_QINT16}, | |||
{ge::DT_QINT32, ge::proto::DT_QINT32}, | |||
{ge::DT_QUINT8, ge::proto::DT_QUINT8}, | |||
{ge::DT_QUINT16, ge::proto::DT_QUINT16}, | |||
{ge::DT_RESOURCE, ge::proto::DT_RESOURCE}, | |||
{ge::DT_STRING_REF, ge::proto::DT_STRING_REF}, | |||
{ge::DT_STRING, ge::proto::DT_STRING}, | |||
}; | |||
} // namespace | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -37,10 +37,10 @@ static const int32_t kGeSizeUint16 = sizeof(uint16_t); | |||
static const int32_t kGeSizeUint32 = sizeof(uint32_t); | |||
static std::map<ge::DataType, int32_t> CONST_OPDATA_TYPE_SIZE_MAP = { | |||
{ge::DT_FLOAT, kGeSizeFloat}, {ge::DT_FLOAT16, kGeSizeHalfFloat}, {ge::DT_INT8, kGeSizeInt8}, | |||
{ge::DT_INT16, kGeSizeInt16}, {ge::DT_INT32, kGeSizeInt32}, {ge::DT_INT64, kGeSizeInt64}, | |||
{ge::DT_UINT8, kGeSizeUint8}, {ge::DT_UINT16, kGeSizeUint16}, {ge::DT_UINT32, kGeSizeUint32}, | |||
{ge::DT_UINT64, kGeSizeUint64}, {ge::DT_DOUBLE, kGeSizeDouble}, {ge::DT_BOOL, kGeSizeBool}}; | |||
{ge::DT_FLOAT, kGeSizeFloat}, {ge::DT_FLOAT16, kGeSizeHalfFloat}, {ge::DT_INT8, kGeSizeInt8}, | |||
{ge::DT_INT16, kGeSizeInt16}, {ge::DT_INT32, kGeSizeInt32}, {ge::DT_INT64, kGeSizeInt64}, | |||
{ge::DT_UINT8, kGeSizeUint8}, {ge::DT_UINT16, kGeSizeUint16}, {ge::DT_UINT32, kGeSizeUint32}, | |||
{ge::DT_UINT64, kGeSizeUint64}, {ge::DT_DOUBLE, kGeSizeDouble}, {ge::DT_BOOL, kGeSizeBool}}; | |||
class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY DataTypeUtil { | |||
public: | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -45,8 +45,8 @@ std::string OpTilingManager::GetPath() { | |||
if (opp_path_env != nullptr) { | |||
char resolved_path[PATH_MAX]; | |||
if (realpath(opp_path_env, resolved_path) == NULL) { | |||
ErrorManager::GetInstance().ATCReportErrMessage( | |||
"E19024", {"env", "value", "situation"}, {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | |||
ErrorManager::GetInstance().ATCReportErrMessage("E19024", {"env", "value", "situation"}, | |||
{"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | |||
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); | |||
return std::string(); | |||
} | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -36,4 +36,3 @@ class OpTilingManager { | |||
} // namespace ge | |||
#endif // GE_COMMON_GE_OP_TILING_MANAGER_H_ | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -93,13 +93,15 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||
std::vector<std::string> path_vec; | |||
SplitPath(path, path_vec); | |||
for (const auto &single_path : path_vec) { | |||
GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, GELOGE(GE_PLGMGR_PATH_INVALID, | |||
"The shared library file path is too long!"); | |||
GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, | |||
GELOGE(GE_PLGMGR_PATH_INVALID, "The shared library file path is too long!"); | |||
continue); | |||
// load break when number of loaded so reach maximum | |||
if (num_of_loaded_so >= kMaxNumOfSo) { | |||
GELOGW("The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||
" and only the first %d shared libraries will be loaded.", kMaxNumOfSo); | |||
GELOGW( | |||
"The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||
" and only the first %d shared libraries will be loaded.", | |||
kMaxNumOfSo); | |||
break; | |||
} | |||
@@ -180,9 +182,9 @@ Status PluginManager::ValidateSo(const string &file_path, int64_t size_of_loaded | |||
// load continue if the total size of so reaches maximum when it is loaded | |||
if (size_of_loaded_so + file_size > kMaxSizeOfLoadedSo) { | |||
GELOGW( | |||
"%s is skipped because the size of loaded share library reaches maximum if it is loaded! " | |||
"(size: %ldB, size of loaded share library: %ldB, maximum: %dB)", | |||
file_path.c_str(), file_size, size_of_loaded_so, kMaxSizeOfLoadedSo); | |||
"%s is skipped because the size of loaded share library reaches maximum if it is loaded! " | |||
"(size: %ldB, size of loaded share library: %ldB, maximum: %dB)", | |||
file_path.c_str(), file_size, size_of_loaded_so, kMaxSizeOfLoadedSo); | |||
return FAILED; | |||
} | |||
@@ -229,8 +231,10 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||
// load break when number of loaded so reach maximum | |||
if (num_of_loaded_so >= kMaxNumOfSo) { | |||
GELOGW("The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||
" and only the first %d shared libraries will be loaded.", kMaxNumOfSo); | |||
GELOGW( | |||
"The number of dynamic libraries loaded exceeds the kMaxNumOfSo," | |||
" and only the first %d shared libraries will be loaded.", | |||
kMaxNumOfSo); | |||
break; | |||
} | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -94,6 +94,13 @@ void TBEPluginManager::ProcessSoFullName(vector<string> &file_list, string &caff | |||
full_name.compare(full_name.size() - caffe_parser_so_suff.size(), caffe_parser_so_suff.size(), | |||
caffe_parser_so_suff) == 0) { | |||
caffe_parser_path = full_name; | |||
} else if ((full_name.size() >= aicpu_so_suff.size() && | |||
full_name.compare(full_name.size() - aicpu_so_suff.size(), aicpu_so_suff.size(), aicpu_so_suff) == 0) || | |||
(full_name.size() >= aicpu_host_so_suff.size() && | |||
full_name.compare(full_name.size() - aicpu_host_so_suff.size(), aicpu_host_so_suff.size(), | |||
aicpu_host_so_suff) == 0)) { | |||
// aicpu so, Put the file path into the omgcontext and save into the model in the builder stage. | |||
domi::GetContext().aicpu_op_run_paths.push_back(full_name); | |||
} else { | |||
// Save parser so path into file_list vector | |||
file_list.push_back(full_name); | |||
@@ -186,8 +193,8 @@ void TBEPluginManager::LoadCustomOpLib() { | |||
} | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY | |||
void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::LoadPluginSo( | |||
const std::map<string, string> &options) { | |||
vector<string> file_list; | |||
string caffe_parser_path; | |||
std::string plugin_path; | |||
@@ -223,10 +230,39 @@ void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | |||
} | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY | |||
void TBEPluginManager::InitPreparation(const std::map<string, string> &options) { | |||
Status TBEPluginManager::CheckCustomAiCpuOpLib() { | |||
std::vector<std::string> vec_op_type; | |||
domi::OpRegistry::Instance()->GetOpTypeByImplyType(vec_op_type, domi::ImplyType::CUSTOM); | |||
for (size_t i = 0; i < vec_op_type.size(); i++) { | |||
bool aicpu_so_exist = false; | |||
std::string ai_cpu_so_name = "lib" + vec_op_type[i] + "_aicpu.so"; | |||
for (size_t j = 0; j < domi::GetContext().aicpu_op_run_paths.size(); j++) { | |||
string bin_file_path = domi::GetContext().aicpu_op_run_paths[j]; | |||
if (bin_file_path.size() >= ai_cpu_so_name.size() && | |||
bin_file_path.compare(bin_file_path.size() - ai_cpu_so_name.size(), ai_cpu_so_name.size(), ai_cpu_so_name) == | |||
0) { | |||
aicpu_so_exist = true; | |||
break; | |||
} | |||
} | |||
if (!aicpu_so_exist) { | |||
GELOGE(FAILED, "Can't find aicpu run so(%s), please check the plugin path!", ai_cpu_so_name.c_str()); | |||
return FAILED; | |||
} | |||
} | |||
return SUCCESS; | |||
} | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::InitPreparation( | |||
const std::map<string, string> &options) { | |||
options_.insert(options.begin(), options.end()); | |||
// Load TBE plugin | |||
TBEPluginManager::Instance().LoadCustomOpLib(); | |||
Status ret = CheckCustomAiCpuOpLib(); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Check custom aicpu run so failed!"); | |||
return; | |||
} | |||
} | |||
} // namespace ge |
@@ -1,5 +1,5 @@ | |||
/** | |||
* Copyright 2020 Huawei Technologies Co., Ltd | |||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
@@ -32,23 +32,23 @@ | |||
namespace ge { | |||
using SoHandlesVec = std::vector<void *>; | |||
using std::vector; | |||
using std::string; | |||
using std::map; | |||
using std::function; | |||
using std::map; | |||
using std::string; | |||
using std::vector; | |||
class TBEPluginManager { | |||
public: | |||
Status Finalize(); | |||
// Get TBEPluginManager singleton instance | |||
static TBEPluginManager& Instance(); | |||
static TBEPluginManager &Instance(); | |||
static string GetPath(); | |||
static void InitPreparation(const std::map<string, string> &options); | |||
void LoadPluginSo(const std::map< string, string> &options); | |||
void LoadPluginSo(const std::map<string, string> &options); | |||
private: | |||
TBEPluginManager() = default; | |||
@@ -62,6 +62,7 @@ class TBEPluginManager { | |||
static void GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path); | |||
static void GetCustomOpPath(std::string &customop_path); | |||
void LoadCustomOpLib(); | |||
static Status CheckCustomAiCpuOpLib(); | |||
SoHandlesVec handles_vec_; | |||
static std::map<string, string> options_; | |||
@@ -71,10 +71,7 @@ GE_COMMON_LOCAL_C_INCLUDES := \ | |||
$(TOPDIR)third_party/openssl/include/x86/include \ | |||
$(TOPDIR)framework/domi \ | |||
$(TOPDIR)framework/domi/common \ | |||
$(TOPDIR)framework/domi/common/op \ | |||
$(TOPDIR)graphengine/ge \ | |||
$(TOPDIR)graphengine/ge/common \ | |||
$(TOPDIR)graphengine/ge/common/op \ | |||
$(TOPDIR)framework/domi/common/op | |||
#compile host libge_common | |||
include $(CLEAR_VARS) | |||
@@ -1007,9 +1007,10 @@ Status ModelCacheHelper::RecoverVarAddrAndTensorDesc(const Json &json) const { | |||
return PARAM_INVALID; | |||
} | |||
// Offset is needed by SaveVarVddr instead of logic address | |||
ret = VarManager::Instance(session_id_)->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, | |||
reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(offset)), | |||
tensor_addr_mgr.memory_type); | |||
ret = | |||
VarManager::Instance(session_id_) | |||
->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, | |||
reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(offset)), tensor_addr_mgr.memory_type); | |||
if (ret != SUCCESS) { | |||
GELOGW("Fail to recover VarAddr or TensorDesc of var[%s].", iter.first.c_str()); | |||
return ret; | |||
@@ -1496,6 +1497,7 @@ Status ModelCacheHelper::ParseMemResourceFromJson(const Json &json, map<rtMemTyp | |||
} | |||
mem_resource.clear(); | |||
for (const Json &mem_resource_json : json) { | |||
MemResource var_addr_mgr; | |||
try { | |||
rtMemType_t mem_type = mem_resource_json[kMemType].get<rtMemType_t>(); | |||
uint64_t var_mem_size = mem_resource_json[kVarMemSize].get<int64_t>(); | |||
@@ -42,7 +42,7 @@ class ModelCacheHelper { | |||
ModelCacheHelper(uint64_t session_id, uint32_t graph_id, ComputeGraphPtr &compute_graph); | |||
~ModelCacheHelper(); | |||
Status SaveCacheInfoToCache () const; | |||
Status SaveCacheInfoToCache() const; | |||
Status SaveVarManagerToCache(bool before_build) const; | |||
Status SaveOmModelToCache(const GeModelPtr &ge_model) const; | |||
bool IsModelCacheHit() const; | |||
@@ -97,7 +97,7 @@ class ModelCacheHelper { | |||
std::vector<std::pair<std::string, VarAddrMgr>> &var_addr_mgr_vector, | |||
std::unordered_set<uint64_t> &var_offset_set); | |||
static Status ParseCurVarTensorDescMapFromJson( | |||
const Json &json, std::unordered_map<std::string, ge::GeTensorDesc> &cur_var_tensor_desc_map); | |||
const Json &json, std::unordered_map<std::string, ge::GeTensorDesc> &cur_var_tensor_desc_map); | |||
static Status ParseTransRoadsFromJson(const Json &json, | |||
std::unordered_map<std::string, std::vector<TransNodeInfo>> &trans_roads); | |||
static Status ParseChangedGraphIdFromJson(const Json &json, | |||