Compare commits

...

No commits in common. 'master' and 'r0.1' have entirely different histories.
master ... r0.1

100 changed files with 1507 additions and 17604 deletions
Unified View
  1. +3
    -2
      .clang-format
  2. +0
    -28
      .gitee/PULL_REQUEST_TEMPLATE.md
  3. +0
    -19
      .github/ISSUE_TEMPLATE/RFC.md
  4. +0
    -43
      .github/ISSUE_TEMPLATE/bug-report.md
  5. +0
    -19
      .github/ISSUE_TEMPLATE/task-tracking.md
  6. +0
    -26
      .github/PULL_REQUEST_TEMPLATE.md
  7. +5
    -41
      .gitignore
  8. +12
    -6
      .gitmodules
  9. +0
    -55
      .jenkins/check/OWNERS
  10. +0
    -53
      .jenkins/check/config/filter_cppcheck.txt
  11. +0
    -72
      .jenkins/check/config/filter_cpplint.txt
  12. +0
    -48
      .jenkins/check/config/filter_linklint.txt
  13. +0
    -138
      .jenkins/check/config/filter_pylint.txt
  14. +0
    -201
      .jenkins/check/config/whitelizard.txt
  15. +0
    -73
      .jenkins/task/config/mapping_task.yaml
  16. +17
    -95
      CMakeLists.txt
  17. +16
    -35
      CONTRIBUTING.md
  18. +0
    -28
      OWNERS
  19. +33
    -213
      README.md
  20. +0
    -297
      README_CN.md
  21. +63
    -3289
      RELEASE.md
  22. +2
    -15
      SECURITY.md
  23. +303
    -6500
      Third_Party_Open_Source_Software_Notice
  24. +0
    -1
      akg
  25. +19
    -0
      autogen.sh
  26. +0
    -84
      build.bat
  27. +421
    -55
      build.sh
  28. +0
    -10
      cmake/OWNERS
  29. +0
    -54
      cmake/change_rpath.cmake
  30. +0
    -141
      cmake/check_requirements.cmake
  31. +64
    -42
      cmake/dependency_graphengine.cmake
  32. +2
    -3
      cmake/dependency_gtest.cmake
  33. +6
    -8
      cmake/dependency_protobuf.cmake
  34. +2
    -9
      cmake/dependency_securec.cmake
  35. +0
    -47
      cmake/dependency_securec_arm.cmake
  36. +3
    -4
      cmake/dependency_utils.cmake
  37. +0
    -39
      cmake/external_libs/absl.cmake
  38. +0
    -22
      cmake/external_libs/c-ares.cmake
  39. +0
    -37
      cmake/external_libs/cmsis.cmake
  40. +0
    -21
      cmake/external_libs/cppjieba.cmake
  41. +5
    -0
      cmake/external_libs/dlpack.cmake
  42. +5
    -0
      cmake/external_libs/dmlc_core.cmake
  43. +4
    -10
      cmake/external_libs/eigen.cmake
  44. +14
    -113
      cmake/external_libs/flatbuffers.cmake
  45. +7
    -49
      cmake/external_libs/glog.cmake
  46. +0
    -129
      cmake/external_libs/grpc.cmake
  47. +8
    -62
      cmake/external_libs/gtest.cmake
  48. +0
    -69
      cmake/external_libs/icu4c.cmake
  49. +6
    -49
      cmake/external_libs/jpeg_turbo.cmake
  50. +9
    -26
      cmake/external_libs/json.cmake
  51. +0
    -30
      cmake/external_libs/libevent.cmake
  52. +7
    -27
      cmake/external_libs/libtiff.cmake
  53. +10
    -45
      cmake/external_libs/mkl_dnn.cmake
  54. +5
    -12
      cmake/external_libs/nccl.cmake
  55. +3
    -10
      cmake/external_libs/ompi.cmake
  56. +5
    -0
      cmake/external_libs/onnx.cmake
  57. +0
    -55
      cmake/external_libs/opencl.cmake
  58. +29
    -137
      cmake/external_libs/opencv.cmake
  59. +0
    -78
      cmake/external_libs/openssl.cmake
  60. +43
    -114
      cmake/external_libs/protobuf.cmake
  61. +0
    -73
      cmake/external_libs/protobuf_arm.cmake
  62. +3
    -52
      cmake/external_libs/pybind11.cmake
  63. +6
    -0
      cmake/external_libs/rang.cmake
  64. +0
    -22
      cmake/external_libs/re2.cmake
  65. +0
    -58
      cmake/external_libs/sentencepiece.cmake
  66. +10
    -35
      cmake/external_libs/sqlite.cmake
  67. +0
    -24
      cmake/external_libs/tinyxml2.cmake
  68. +8
    -0
      cmake/external_libs/tvm_gpu.cmake
  69. +10
    -0
      cmake/external_libs/tvm_predict.cmake
  70. +0
    -17
      cmake/external_libs/zlib.cmake
  71. +0
    -361
      cmake/lite_ios.cmake
  72. +22
    -49
      cmake/mind_expression.cmake
  73. +36
    -96
      cmake/options.cmake
  74. +0
    -392
      cmake/package.cmake
  75. +0
    -1027
      cmake/package_lite.cmake
  76. +0
    -249
      cmake/package_mac.cmake
  77. +0
    -164
      cmake/package_script.cmake
  78. +0
    -173
      cmake/package_tar.cmake
  79. +0
    -248
      cmake/package_win.cmake
  80. +95
    -212
      cmake/utils.cmake
  81. +0
    -12
      config/data_dump.json
  82. +22
    -0
      config/e2e_dump_config.json
  83. +22
    -0
      config/e2e_dump_config_0.json
  84. +22
    -0
      config/e2e_dump_config_1.json
  85. +0
    -742
      config/op_info.config
  86. +120
    -0
      dbg_dump_parser.sh
  87. BIN
      docs/Automatic-parallel.png
  88. BIN
      docs/MindSpore-Lite-architecture.png
  89. BIN
      docs/MindSpore-architecture-zh.png
  90. BIN
      docs/MindSpore-architecture.png
  91. +0
    -9
      docs/OWNERS
  92. BIN
      docs/api/api_python/dataset/browse_dataset.png
  93. +0
    -15
      docs/api/api_python/dataset/mindspore.dataset.BatchInfo.rst
  94. +0
    -43
      docs/api/api_python/dataset/mindspore.dataset.BuiltinSampler.b.rst
  95. +0
    -11
      docs/api/api_python/dataset/mindspore.dataset.BuiltinSampler.rst
  96. +0
    -217
      docs/api/api_python/dataset/mindspore.dataset.CLUEDataset.rst
  97. +0
    -44
      docs/api/api_python/dataset/mindspore.dataset.CSVDataset.rst
  98. +0
    -127
      docs/api/api_python/dataset/mindspore.dataset.Caltech101Dataset.rst
  99. +0
    -112
      docs/api/api_python/dataset/mindspore.dataset.Caltech256Dataset.rst
  100. +0
    -132
      docs/api/api_python/dataset/mindspore.dataset.CelebADataset.rst

+ 3
- 2
.clang-format View File

@@ -52,7 +52,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 2 ContinuationIndentWidth: 2
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DerivePointerAlignment: false
DerivePointerAlignment: true
DisableFormat: false DisableFormat: false
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true FixNamespaceComments: true
@@ -94,7 +94,7 @@ PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10 PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200 PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
PointerAlignment: Left
RawStringFormats: RawStringFormats:
- Language: Cpp - Language: Cpp
Delimiters: Delimiters:
@@ -124,6 +124,7 @@ RawStringFormats:
CanonicalDelimiter: '' CanonicalDelimiter: ''
BasedOnStyle: google BasedOnStyle: google
ReflowComments: true ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true SortUsingDeclarations: true
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true


+ 0
- 28
.gitee/PULL_REQUEST_TEMPLATE.md View File

@@ -1,28 +0,0 @@
<!-- Thanks for sending a pull request! Here are some tips for you:

1) If this is your first time, please read our contributor guidelines: https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md

2) If you want to contribute your code but don't know who will review and merge, please add label `mindspore-assistant` to the pull request, we will find and do it as soon as possible.
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:



+ 0
- 19
.github/ISSUE_TEMPLATE/RFC.md View File

@@ -1,19 +0,0 @@
---
name: RFC
about: Use this template for the new feature or enhancement
labels: kind/feature or kind/enhancement

---

## Background
- Describe the status of the problem you wish to solve
- Attach the relevant issue if have

## Introduction
- Describe the general solution, design and/or pseudo-code

## Trail
| No. | Task Description | Related Issue(URL) |
| --- | ---------------- | ------------------ |
| 1 | | |
| 2 | | |

+ 0
- 43
.github/ISSUE_TEMPLATE/bug-report.md View File

@@ -1,43 +0,0 @@
---
name: Bug Report
about: Use this template for reporting a bug
labels: kind/bug

---

<!-- Thanks for sending an issue! Here are some tips for you:

If this is your first time, please read our contributor guidelines: https://github.com/mindspore-ai/mindspore/blob/master/CONTRIBUTING.md
-->

## Environment
### Hardware Environment(`Ascend`/`GPU`/`CPU`):
> Uncomment only one ` /device <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> `/device ascend`</br>
> `/device gpu`</br>
> `/device cpu`</br>

### Software Environment:
- **MindSpore version (source or binary)**:
- **Python version (e.g., Python 3.7.5)**:
- **OS platform and distribution (e.g., Linux Ubuntu 16.04)**:
- **GCC/Compiler version (if compiled from source)**:

## Describe the current behavior


## Describe the expected behavior


## Steps to reproduce the issue
1.
2.
3.

## Related log / screenshot


## Special notes for this issue



+ 0
- 19
.github/ISSUE_TEMPLATE/task-tracking.md View File

@@ -1,19 +0,0 @@
---
name: Task
about: Use this template for task tracking
labels: kind/task

---

## Task Description


## Task Goal


## Sub Task
| No. | Task Description | Issue ID |
| --- | ---------------- | -------- |
| 1 | | |
| 2 | | |


+ 0
- 26
.github/PULL_REQUEST_TEMPLATE.md View File

@@ -1,26 +0,0 @@
<!-- Thanks for sending a pull request! Here are some tips for you:

1) If this is your first time, please read our contributor guidelines: https://github.com/mindspore-ai/mindspore/blob/master/CONTRIBUTING.md

2) If you want to contribute your code but don't know who will review and merge, please add label `mindspore-assistant` to the pull request, we will find and do it as soon as possible.
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> `/kind bug`</br>
> `/kind task`</br>
> `/kind feature`</br>

**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:


+ 5
- 41
.gitignore View File

@@ -3,33 +3,6 @@ build/
mindspore/lib mindspore/lib
output output
*.ir *.ir
st_tests
kernel_meta/
somas_meta/
trace_code_graph_*

# mindspore lite java
mindspore/lite/java/java/.gradle
mindspore/lite/java/java/build
mindspore/lite/java/java/gradle
mindspore/lite/java/java/gradlew
mindspore/lite/java/java/gradlew.bat
mindspore/lite/java/java/app/build
mindspore/lite/java/java/app/libs

# flatbuffer
mindspore/lite/tools/converter/parser/tflite/schema_generated.h
mindspore/lite/tools/converter/parser/caffe/caffe.pb.cc
mindspore/lite/tools/converter/parser/caffe/caffe.pb.h
mindspore/lite/tools/converter/parser/onnx/onnx.pb.h
mindspore/lite/tools/converter/parser/onnx/onnx.pb.h
mindspore/lite/tools/converter/schema/*.h
mindspore/lite/tools/converter/schema/inner
mindspore/lite/schema/*.h
mindspore/lite/schema/inner

mindspore/lite/src/runtime/kernel/opencl/cl/fp16/*.inc
mindspore/lite/src/runtime/kernel/opencl/cl/fp32/*.inc


# Cmake files # Cmake files
CMakeFiles/ CMakeFiles/
@@ -53,8 +26,6 @@ cmake-build-debug
*_pb2.py *_pb2.py
*.pb.h *.pb.h
*.pb.cc *.pb.cc
*.pb
*_grpc.py


# Object files # Object files
*.o *.o
@@ -94,16 +65,9 @@ test_temp_summary_event_file/
*.ckpt *.ckpt
*.shp *.shp
*.pkl *.pkl
*.pb
.clangd .clangd
mindspore/python/mindspore/version.py
mindspore/python/mindspore/default_config.py
mindspore/python/mindspore/device_target.py
mindspore/python/mindspore/package_name.py
mindspore/python/mindspore/.commit_id

# lite test file
mindspore/lite/test/do_test/

# lite opencl compile file
*.cl.inc
mindspore/version.py
mindspore/default_config.py
mindspore/.commit_id
onnx.proto
mindspore/ccsrc/onnx.proto

+ 12
- 6
.gitmodules View File

@@ -1,9 +1,15 @@
[submodule "akg"]
path = akg
url = https://gitee.com/mindspore/akg.git
[submodule "third_party/flatbuffers"]
path = third_party/flatbuffers
url = https://github.com/google/flatbuffers.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
[submodule "third_party/incubator-tvm"]
path = third_party/incubator-tvm
url = https://github.com/apache/incubator-tvm.git
[submodule "third_party/protobuf"]
path = third_party/protobuf
url = https://github.com/protocolbuffers/protobuf.git
[submodule "graphengine"] [submodule "graphengine"]
path = graphengine path = graphengine
url = https://gitee.com/mindspore/graphengine.git url = https://gitee.com/mindspore/graphengine.git
[submodule "tests/models"]
path = tests/models
url = https://gitee.com/mindspore/models.git

+ 0
- 55
.jenkins/check/OWNERS View File

@@ -1,55 +0,0 @@
approvers:
- anyrenwei
- baochong
- c_34
- chujinjin
- ckey_dou
- cristoval
- ddwsky
- gaoxiong1
- ginfung
- guoqi1024
- hangangqiang
- heleiwang
- HilbertDavid
- hwhewei
- jjfeing
- john_tzanakakis
- jonyguo
- jpc_chenjianping
- kingxian
- liangchenghui
- lilongfei15
- limingqi107
- linqingke
- liucunwei
- mickf
- nsyca
- ouwenchang
- pandoublefeng
- robingrosman
- stsuteng
- tiancixiao
- tom__chen
- wangyue01
- wenkai_dist
- wilfchen
- wuxuejian
- xu-yfei
- yelihua
- yuchaojie
- zh_qh
- zhaizhiqiang
- zhang_xue_tong
- zhanghaibo5
- zhanyuan1
- zhoufeng54
- zlq2020
- zqstar
- z0020952
- chenshushu2020
reviewers:
- nicholas_yhr
- liubuyu
- chengxb7532
- lx0095

+ 0
- 53
.jenkins/check/config/filter_cppcheck.txt View File

@@ -1,53 +0,0 @@
# MindSpore
"mindspore/mindspore/ccsrc/debug/anf_ir_utils.cc" "stlFindInsert"
"mindspore/mindspore/ccsrc/backend/graph_compiler/transform.cc" "containerOutOfBounds"
"mindspore/mindspore/ccsrc/backend/graph_compiler/transform.cc" "constVariable"
"mindspore/mindspore/ccsrc/utils/tensorprint_utils.cc" "invalidPointerCast"
"mindspore/mindspore/ccsrc/plugin/device/gpu/hal/device/mpi/mpi_initializer.cc" "syntaxError"
"mindspore/mindspore/core/abstract/prim_nn.cc" "zerodivcond"
"mindspore/mindspore/ccsrc/frontend/operator/ops_front_infer_function.cc" "zerodivcond"
"mindspore/mindspore/ccsrc/pipeline/jit/pipeline_split.cc" "zerodivcond"
"mindspore/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_stream_assign.cc" "useStlAlgorithm"
"mindspore/mindspore/ccsrc/frontend/operator/ops_front_infer_function.cc" "uninitvar"
"mindspore/mindspore/ccsrc/pipeline/jit/action.cc" "constVariable"
"mindspore/mindspore/ccsrc/pipeline/jit/validator.cc" "constVariable"
"mindspore/mindspore/ccsrc/utils/tensorprint_utils.cc" "invalidPointerCast"
"mindspore/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/ir_fission/bn_grad_split.cc" "knownConditionTrueFalse"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_apply_ftrl_cpu_kernel.cc" "containerOutOfBounds"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_apply_adam_cpu_kernel.cc" "containerOutOfBounds"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_apply_lazy_adam_cpu_kernel.cc" "containerOutOfBounds"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_apply_proximal_adagrad_cpu_kernel.cc" "containerOutOfBounds"
"mindspore/mindspore/ccsrc/frontend/parallel/auto_parallel/rec_core/rec_generate_strategy.cc" "containerOutOfBounds"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/embedding_look_up_cpu_kernel.cc" "containerOutOfBounds"
"mindspore/mindspore/core/ops/strided_slice.cc" "zerodivcond"
"mindspore/mindspore/core/ops/avg_pool_3d.cc" "zerodivcond"
"mindspore/mindspore/ccsrc/plugin/device/ascend/hal/hccl_adapter/hccl_adapter.cc" "useStlAlgorithm"
"mindspore/mindspore/ccsrc/plugin/device/gpu/kernel/arrays/cast_gpu_kernel.cc" "unknownMacro"
"mindspore/mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_memory_manager.cc" "nullPointerArithmeticRedundantCheck"
"mindspore/mindspore/ccsrc/pipeline/jit/static_analysis/auto_monad.cc" "containerOutOfBounds"
"mindspore/mindspore/core/load_mindir/anf_model_parser.cc" "stlIfStrFind"
"mindspore/mindspore/ccsrc/frontend/optimizer/ad/kpynative.cc" "containerOutOfBounds"

# MindData
"mindspore/mindspore/ccsrc/minddata/dataset/engine/dataset_iterator.cc" "useStlAlgorithm"
"mindspore/mindspore/ccsrc/minddata/dataset/core/tensor_shape.cc" "useStlAlgorithm"
"mindspore/mindspore/ccsrc/minddata/dataset/util/arena.cc" "useStlAlgorithm"
"mindspore/mindspore/ccsrc/minddata/dataset/api/python/pybind_register.cc" "syntaxError"
"mindspore/mindspore/ccsrc/minddata/dataset/engine/datasetops/rename_op.cc" "accessMoved"
"mindspore/mindspore/ccsrc/minddata/mindrecord/meta/shard_header.cc" "useStlAlgorithm"
"mindspore/mindspore/ccsrc/minddata/mindrecord/common/shard_pybind.cc" "syntaxError"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/resize_cubic_op.cc" "constParameter"

# Lite
"mindspore/mindspore/core/mindrt/src/thread/" "useStlAlgorithm"
"mindspore/mindspore/lite/test/" "syntaxError"
"mindspore/mindspore/lite/test/ut/tools/converter/registry/pass_registry_test.cc" "unknownMacro"
"mindspore/mindspore/lite/src/ops/unsqueeze.cc" "useStlAlgorithm"
"mindspore/mindspore/lite/tools/common/flag_parser.cc" "useStlAlgorithm"
"mindspore/mindspore/lite/tools/common/tensor_util.cc" "useStlAlgorithm"
"mindspore/mindspore/lite/tools/converter/parser/onnx/onnx_relu_parser.cc" "useStlAlgorithm"
"mindspore/mindspore/lite/tools/converter/quantizer/quantize_util.cc" "useStlAlgorithm"
"mindspore/mindspore/lite/src/runtime/kernel/opencl/kernel/" "unreadVariable"
"mindspore/mindspore/lite/src/runtime/kernel/opencl/cl/" "unreadVariable"
"mindspore/mindspore/lite/examples/quick_start_micro/" "syntaxError"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental" "unreadVariable"

+ 0
- 72
.jenkins/check/config/filter_cpplint.txt View File

@@ -1,72 +0,0 @@
# MindSpore
"mindspore/" "build/header_guard"
"mindspore/" "build/c++11"
"mindspore/include/inference.h" "runtime/references"
"mindspore/include/infer_tensor.h" "runtime/references"
"mindspore/include/inference.h" "runtime/explicit"
"mindspore/mindspore/core/abstract/utils.cc" "build/include_what_you_use"
"mindspore/mindspore/ccsrc/plugin/device/ascend/optimizer/buffer_fusion/ub_pattern_fusion.cc" "build/include_what_you_use"
"mindspore/mindspore/ccsrc/plugin/device/ascend/hal/device/profiling/profiling_callback_register.cc" "runtime/references"
"mindspore/mindspore/ccsrc/plugin/device/ascend/hal/device/profiling/profiling_manager.h" "runtime/references"
"mindspore/mindspore/ccsrc/plugin/device/ascend/hal/device/profiling/profiling_reporter.h" "runtime/references"
"mindspore/mindspore/core/mindrt/src/actor/actormgr.h" "runtime/references"
"mindspore/mindspore/core/mindrt/src/actor/actorpolicyinterface.h" "runtime/references"
"mindspore/mindspore/core/mindrt/src/actor/actorthread.h" "runtime/references"
"mindspore/mindspore/core/mindrt/src/actor/actorpolicy.h" "runtime/references"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/" "readability/casting"
"mindspore/mindspore/ccsrc/plugin/device/gpu/hal/device/gpu_kernel_runtime.cc" "build/include_what_you_use"
"mindspore/mindspore/ccsrc/utils/convert_utils_py.cc" "whitespace/indent"

# Modelzoo
"mindspore/model_zoo/official/cv/yolov4_tiny/infer/mxbase/src/Yolov4TinyDetection.h" "runtime/references"
"mindspore/model_zoo/official/cv/yolov4_tiny/infer/mxbase/src/PostProcess/Yolov4TinyMindsporePost.h" "runtime/references"
"mindspore/model_zoo/official/cv/resnet/infer/ResNet18/mxbase/Resnet18ClassifyOpencv.h" "runtime/references"

# MindData
"mindspore/mindspore/ccsrc/minddata/mindrecord/include/shard_page.h" "runtime/string"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/tensor_op.h" "runtime/references"
"mindspore/mindspore/ccsrc/minddata/dataset/engine/tdt/tdt_plugin.h" "runtime/references"
"mindspore/mindspore/ccsrc/minddata/dataset/util/bit.h" "runtime/references"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc" "runtime/int"
"mindspore/mindspore/ccsrc/minddata/dataset/util" "build/include"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h" "runtime/references"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc" "runtime/references"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.h" "runtime/explicit"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/resize_cubic_op.h" "runtime/references"
"mindspore/mindspore/ccsrc/minddata/dataset/kernels/image/resize_cubic_op.cc" "runtime/references"

# Lite
"mindspore/mindspore/lite/include/lite_utils.h" "build/include_what_you_use"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/" "readability/casting"
"mindspore/mindspore/lite/tools/converter/micro/coder/wrapper/" "readability/casting"
"mindspore/mindspore/lite/tools/converter/parser/tflite/tflite_node_parser.h" "runtime/references"
"mindspore/mindspore/lite/tools/converter/model_parser.h" "build/namespaces"
"mindspore/mindspore/lite/tools/converter/parser/caffe/caffe_node_parser.cc" "readability/casting"
"mindspore/mindspore/lite/tools/converter/optimizer.h" "build/namespaces"
"mindspore/mindspore/lite/tools/converter/quantizer/quantize_util.h" "runtime/references"
"mindspore/mindspore/lite/tools/converter/legacy_optimizer/fusion/fusion_pass.h" "runtime/references"
"mindspore/mindspore/lite/tools/benchmark/benchmark.cc" "runtime/threadsafe_fn"
"mindspore/mindspore/lite/tools/benchmark/benchmark_base.cc" "runtime/threadsafe_fn"
"mindspore/mindspore/lite/tools/benchmark/benchmark_unified_api.cc" "runtime/threadsafe_fn"
"mindspore/mindspore/lite/tools/benchmark/run_benchmark.cc" "runtime/threadsafe_fn"
"mindspore/mindspore/lite/src/executor.h" "runtime/references"
"mindspore/mindspore/lite/src/lite_kernel.h" "runtime/references"
"mindspore/mindspore/lite/src/runtime/opencl/opencl_runtime.h" "runtime/references"
"mindspore/mindspore/lite/src/runtime/opencl/opencl_executor.h" "runtime/references"
"mindspore/mindspore/lite/src/runtime/opencl/opencl_wrapper.h" "readability/casting"
"mindspore/mindspore/lite/src/runtime/kernel/opencl/cl/" "legal/copyright"
"mindspore/mindspore/lite/src/runtime/kernel/opencl/cl/" "readability/casting"
"mindspore/mindspore/lite/src/runtime/kernel/opencl/cl/" "readability/fn_size"
"mindspore/mindspore/lite/src/runtime/thread_pool.c" "readability/casting"
"mindspore/mindspore/lite/src/runtime/thread_pool.c" "runtime/arrays"
"mindspore/mindspore/lite/src/runtime/thread_pool.c" "runtime/int"
"mindspore/mindspore/lite/src/ops/ops_def.cc" "runtime/int"
"mindspore/mindspore/lite/examples/runtime_gpu_extend/src/cl" "legal/copyright"
"mindspore/mindspore/lite/examples/runtime_gpu_extend/src/cl" "readability/casting"
"mindspore/mindspore/lite/examples/runtime_gpu_extend/src/cl" "readability/fn_size"
"mindspore/mindspore/lite/examples/quick_start_c/main.c" "readability/casting"
"mindspore/mindspore/lite/examples/quick_start_c/main.c" "runtime/threadsafe_fn"
"mindspore/mindspore/lite/examples/quick_start_micro" "readability/casting"
"mindspore/mindspore/core/mindrt/include/async/try.h" "runtime/explicit"
"mindspore/mindspore/core/mindrt/include/async/failure.h" "runtime/explicit"
"mindspore/mindspore/core/mindrt/include/async/defer.h" "runtime/explicit"

+ 0
- 48
.jenkins/check/config/filter_linklint.txt View File

@@ -1,48 +0,0 @@
# akg-third-party
# file directory: mindspore/akg/third_party/incubator-tvm/

https://docs.tvm.ai/vta/tutorials/index.html
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/blogpost/vta_stack.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/passupdomain_problem.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/stage_graph.png:align
https://docs.tvm.ai/tutorials/get_started.html#sphx-glr-tutorials-get-started-py
http://docs.tvm.ai/tutorials/deployment/cross_compilation_and_rpc.html#sphx-glr-tutorials-deployment-cross-compilation-and-rpc-py
https://docs.tvm.ai/api/python/module.html#tvm.module.Module.time_evaluatornum
https://arxiv.org/abs/1509.09308https://github.com/andravin/wincnn
https://homes.cs.washington.edu/~cyulin/media/gnn_model/gcn_%s.torch
https://docs.tvm.ai/api/python/schedule.html#tvm.schedule.Stage.storage_align
https://homes.cs.washington.edu/~haichen/
https://docs.tvm.ai/dev/relay_pass_infra.html
https://en.cppreference.com/w/cpp/numeric/math/roundhttps://en.cppreference.com/w/cpp/numeric/math/nearbyint
https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.htmlandhttps://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.sparse.bsr_matrix.htmlfor
https://arxiv.org/abs/1706.02515alpha
https://tinyurl.com/y5k6fz5w.We
https://tinyurl.com/y4d7hrzf.We
https://raw.githubusercontent.com/uwsampl/tvm-distro/master/tophub
https://arxiv.org/abs/1409.3215-
https://arxiv.org/abs/1706.02515alpha
https://discuss.tvm.ai/t/pool2d-gives-bad-output-for-integer-inputs/3377low
http://www.apache.org/licenses/LICENSE-2.0////
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/gatherbound.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/inferbound_traversal.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/relay/let_scope.png:align
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/blogpost/vta_overview.png:align
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/developer/dataflow.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/inferbound_phases.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/passupdomain_div.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/passupdomain_min.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/relay/dataflow.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/relay/dataflow_vs_func.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/gatherbound_problem.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/relations.png:align
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/developer/vta_instructions.png:align
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/developer/gemm_core.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/union.png:align
https://raw.githubusercontent.com/tvmai/tvmai.github.io/master/images/docs/inferbound/passupdomain_nodiv.png:align
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/developer/alu_core.png:align
http://raw.githubusercontent.com/uwsaml/web-data/master/vta/developer/2d_dma.png:align
https://raw.githubusercontent.com/dmlc/web-data/master/tensorflow/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28_nopp.tgz
https://github.com/google/googletestcd
https://github.com/dmlc/dgl/blob/master/examples/pytorch/gcn/train.pyfrom
https://github.com/FrozenGene/tflite/releases/download/v1.13.1/tflite-1.13.1-py3-none-any.whlpip3
https://github.com/siju-samuel/darknet/blob/master/

+ 0
- 138
.jenkins/check/config/filter_pylint.txt View File

@@ -1,138 +0,0 @@
# Overall
"mindspore/" "invalid-name"
"mindspore/" "arguments-differ"
"mindspore/" "unused-argument"
"mindspore/model_zoo/" "no-value-for-parameter"
"mindspore/model_zoo/" "import-self"
"mindspore/tests/" "missing-docstring"
"mindspore/tests/" "import-self"

# Mindspore
"mindspore/mindspore/python/mindspore/_check_deps_version.py" "broad-except"
"mindspore/mindspore/python/mindspore/_check_version.py" "unused-import"
"mindspore/mindspore/python/mindspore/_check_version.py" "broad-except"
"mindspore/mindspore/python/mindspore/common/api.py" "protected-access"
"mindspore/mindspore/python/mindspore/common/parameter.py" "protected-access"
"mindspore/mindspore/python/mindspore/common/hook_handle.py" "protected-access"
"mindspore/mindspore/python/mindspore/common/dtype.py" "undefined-all-variable"
"mindspore/mindspore/python/mindspore/context.py" "protected-access"
"mindspore/mindspore/python/mindspore/ops/operations" "super-init-not-called"
"mindspore/mindspore/python/mindspore/ops/operations/_quant_ops.py" "unused-import"
"mindspore/mindspore/python/mindspore/ops/operations/nn_ops.py" "redefined-builtin"
"mindspore/mindspore/python/mindspore/ops/operations/_thor_ops.py" "dangerous-default-value"
"mindspore/mindspore/python/mindspore/ops/operations/_thor_ops.py" "redefined-outer-name"
"mindspore/mindspore/python/mindspore/ops/operations/_thor_ops.py" "unused-import"
"mindspore/mindspore/python/mindspore/ops/_op_impl/_custom_op" "dangerous-default-value
"mindspore/mindspore/python/mindspore/ops/_op_impl/_custom_op" "simplifiable-if-expression"
"mindspore/mindspore/python/mindspore/ops/_op_impl/_custom_op" "unused-variable"
"mindspore/mindspore/python/mindspore/ops/composite/base.py" "protected-acces"
"mindspore/mindspore/python/mindspore/ops/primitive.py" "assignment-from-none"
"mindspore/mindspore/python/mindspore/nn/cell.py" "assignment-from-none"
"mindspore/mindspore/python/mindspore/_extends/parse/resources.py" "bad-whitespace"
"mindspore/mindspore/python/mindspore/_extends/parse/parser.py" "broad-except"
"mindspore/mindspore/python/mindspore/_extends/parse/parser.py" "protected-access"
"mindspore/mindspore/python/mindspore/_extends/parse/parser.py" "eval-used"
"mindspore/mindspore/python/mindspore/nn/cell.py" "protected-access"
"mindspore/mindspore/python/mindspore/nn/optim/ftrl.py" "unused-import"
"mindspore/mindspore/python/mindspore/train/amp.py" "protected-access"
"mindspore/mindspore/python/mindspore/train/serialization.py" "protected-access"
"mindspore/mindspore/python/mindspore/train/model.py" "protected-access"
"mindspore/mindspore/python/mindspore/log.py" "protected-access"
"mindspore/mindspore/python/mindspore/rewrite/api/node.py" "protected-access"
"mindspore/mindspore/python/mindspore/rewrite/node.py" "protected-access"
"mindspore/mindspore/python/mindspore/rewrite/symbol_tree.py" "protected-access"
"mindspore/mindspore/python/mindspore/rewrite/parser_register.py" "protected-access"
"mindspore/mindspore/python/mindspore/rewrite/api/pattern_engine.py" "protected-access"
"mindspore/mindspore/python/mindspore/rewrite/symbol_tree.py" "inconsistent-return-statements"
"mindspore/model_zoo/official/cv" "missing-docstring"
"mindspore/model_zoo/official/cv" "c-extension-no-member"
"mindspore/model_zoo/official/nlp/bert_thor/src/bert_model.py" "redefined-outer-name"
"mindspore/mindspore/python/mindspore/_extends/parallel_compile/akg_compiler/akg_process.py" "Catching too general exception BaseException"
"mindspore/mindspore/python/mindspore/_extends/graph_kernel/model/model.py" "super-on-old-class"
"mindspore/mindspore/python/mindspore/ops/_grad/grad_math_ops.py" "invalid-unary-operand-type"

# MindData
"mindspore/mindspore/python/mindspore/dataset/__init__.py" "redefined-builtin"
"mindspore/mindspore/python/mindspore/dataset/engine/__init__.py" "redefined-builtin"
"mindspore/mindspore/python/mindspore/dataset/engine/datasets.py" "redefined-builtin"
"mindspore/mindspore/python/mindspore/dataset/engine/datasets.py" "broad-except"
"mindspore/mindspore/python/mindspore/dataset/transforms/py_transforms_util.py" "broad-except"

# Tests
"mindspore/tests/vm_impl/array_ops_vm_impl.py" "unused-variable"
"mindspore/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_compile.py" "unused-import"
"mindspore/tests/ut/cpp/python_input/gtest_input/pipeline/infer/primitive_test.py" "super-init-not-called"
"mindspore/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py" "super-init-not-called"
"mindspore/tests/ut/cpp/python_input/gtest_input/pre_activate" "unused-variable"
"mindspore/tests/ut/cpp/python_input/gtest_input/tbe" "unused-variable"
"mindspore/tests/ut/python/train/summary/test_summary_abnormal_input.py" "bare-except"
"mindspore/tests/ut/python/train/summary/test_graph_summary.py" "protected-access"
"mindspore/tests/ut/python/parameter_feature/test_parameter.py" "unused-variable"
"mindspore/tests/ut/python/parameter_feature/test_parameter.py" "singleton-comparison"
"mindspore/tests/ut/python/optimizer/test_debug_location.py" "no-value-for-parameter"
"mindspore/tests/ut/python/ops/test_control_ops.py" "superfluous-parens"
"mindspore/tests/ut/python/ops/test_control_ops.py" "unused-variable"
"mindspore/tests/ut/python/keep_order/test_keep_order.py" "redefined-outer-name"
"mindspore/tests/ut/python/ir/test_tensor.py" "protected-access"
"mindspore/tests/ut/python/dataset/test_sampler.py" "unused-variable"
"mindspore/tests/ut/python/dataset/test_minddataset_padded.py" "redefined-outer-name"
"mindspore/tests/ut/python/dataset/test_minddataset_padded.py" "unused-variable"
"mindspore/tests/ut/python/dataset/test_minddataset_padded.py" "expression-not-assigned"
"mindspore/tests/ut/python/dataset/test_batch.py" "broad-except"
"mindspore/tests/ut/python/dataset/test_config.py" "broad-except"
"mindspore/tests/ut/python/dataset/test_minddataset.py" "redefined-outer-name"
"mindspore/tests/ut/python/dataset/test_minddataset_sampler.py" "redefined-outer-name"
"mindspore/tests/ut/python/dataset/test_serdes_dataset.py" "redefined-outer-name"
"mindspore/tests/ut/python/dataset/test_serdes_dataset.py" "unused-import"
"mindspore/tests/ut/python/dataset/test_shuffle.py" "broad-except"
"mindspore/tests/ut/python/dataset/test_to_type.py" "broad-except"
"mindspore/tests/ut/python/dataset/test_uniform_augment.py" "broad-except"
"mindspore/tests/ut/python/dataset/test_zip.py" "broad-except"
"mindspore/tests/ut/python/mindrecord/test_cifar10_to_mindrecord.py" "redefined-outer-name"
"mindspore/tests/ut/python/mindrecord/test_cifar100_to_mindrecord.py" "redefined-outer-name"
"mindspore/tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py" "redefined-outer-name"
"mindspore/tests/ut/python/mindrecord/test_mindrecord_exception.py" "redefined-outer-name"
"mindspore/tests/ut/python/mindrecord/test_mnist_to_mr.py" "redefined-outer-name"
"mindspore/tests/ut/python/nn/test_batchnorm.py" "no-value-for-parameter"
"mindspore/tests/ut/python/onnx/test_onnx.py" "unused-variable"
"mindspore/tests/ut/python/ops" "super-init-not-called"
"mindspore/tests/ut/python/ops/test_tensor_slice.py" "redefined-outer-name"
"mindspore/tests/ut/python/optimizer/test_debug_location.py" "super-init-not-called"
"mindspore/tests/ut/python/parallel/" "protected-access"
"mindspore/tests/ut/python/parameter_feature/test_var_grad.py" "bad-super-call"
"mindspore/tests/ut/python/parameter_feature/test_var_grad.py" "redefined-outer-name"
"mindspore/tests/ut/python/pipeline/parse/test_cont_break.py" "unused-variable"
"mindspore/tests/ut/python/pynative_mode" "no-else-return"
"mindspore/tests/ut/python/pynative_mode" "superfluous-parens"
"mindspore/tests/ut/python/pynative_mode" "unused-variable"
"mindspore/tests/ut/python/pynative_mode/test_stop_gradient.py" "redefined-outer-name"
"mindspore/tests/ut/python/pynative_mode/test_stop_gradient.py" "super-init-not-called"
"mindspore/tests/ut/python/rewrite/test_flatten_recursive_stmt.py" "consider-using-ternary"
"mindspore/tests/ut/python/rewrite/test_node.py" "syntax-error"
"mindspore/tests/ut/python/rewrite/test_node.py" "protected-access"
"mindspore/tests/ut/python/rewrite/test_symbol_tree.py" "len-as-condition"
"mindspore/tests/ut/python/test_log.py" "possibly-unused-variable"
"mindspore/tests/ut/python/test_log.py" "protected-access"
"mindspore/tests/ut/python/train/summary/test_summary_collector.py" "protected-access"
"mindspore/tests/ut/python/pipeline/parse/test_super.py" "bad-super-call"
"mindspore/tests/ut/python/pipeline/parse/test_super.py" "assignment-from-none"
"mindspore/tests/ut/python/pipeline/parse/test_dictionary.py" "consider-iterating-dictionary"
"mindspore/tests/ut/python/pipeline/parse/test_use_undefined_name_or_unsupported_builtin_function.py" "pointless-statement"
"mindspore/tests/st/networks/test_gpu_resnet.py" "superfluous-parens"
"mindspore/tests/st/networks/test_gpu_resnet.py" "unused-variable"
"mindspore/tests/st/networks/test_gpu_lstm.py" "unused-variable"
"mindspore/tests/st/networks/test_gpu_lstm.py" "redefined-outer-name"
"mindspore/tests/st/networks/test_gpu_lstm.py" "superfluous-parens"
"mindspore/tests/st/networks/test_gpu_alexnet.py" "unused-variable"
"mindspore/tests/st/networks/test_gpu_lenet.py" "unused-variable"
"mindspore/tests/st/ops/custom_ops_tbe/cus_add3.py" "unused-import"
"mindspore/tests/st/ops/ascend/test_aicpu_ops/test_strided_slice.py" "redefined-outer-name"
"mindspore/tests/st/ops/ascend/test_aicpu_ops/test_strided_slice.py" "redefined-builtin"
"mindspore/tests/st/ops/ascend/test_aicpu_ops/test_strided_slice_grad.py" "redefined-outer-name"
"mindspore/tests/st/pynative/parser/test_parser_construct.py" "bad-super-call"
"mindspore/tests/ut/python/optimizer/test_auto_grad.py" "broad-except"

#MindSpore Lite
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/generator.py" "redefined-builtin"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/generator.py" "exec-used"
"mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/generator.py" "global-variable-undefined"

+ 0
- 201
.jenkins/check/config/whitelizard.txt View File

@@ -1,201 +0,0 @@
# Scene1:
# function_name1, function_name2
# Scene2:
# file_path:function_name1, function_name2
#
mindspore/mindspore/core/mindrt/src/thread/actor_threadpool.cc:mindspore::ActorWorker::RunWithSpin
mindspore/mindspore/lite/src/ops/primitive_c.cc:mindspore::lite::PrimitiveC::Create
mindspore/mindspore/ccsrc/minddata/dataset/engine/datasetops/source/csv_op.cc:mindspore::dataset::CsvOp::CsvParser::InitCsvParser
mindspore/mindspore/lite/tools/converter/graphdef_transform.cc:mindspore::lite::GraphDefTransform::Transform
mindspore/mindspore/lite/providers/nnie_proposal/src/proposal.cc:mindspore::proposal::Rpn
mindspore/mindspore/core/abstract/primitive_infer_map.cc:mindspore::abstract::GetPrimitiveToEvalImplMap
mindspore/mindspore/ccsrc/frontend/optimizer/irpass.cc:mindspore::opt::irpass::OptimizeIRPassLib::OptimizeIRPassLib
mindspore/mindspore/ccsrc/frontend/parallel/ops_info/gather_v2_p_info.cc:mindspore::parallel::GatherV2PInfo::CheckStrategy
mindspore/mindspore/ccsrc/plugin/device/gpu/hal/device/gpu_kernel_runtime.cc:mindspore::device::gpu::GPUKernelRuntime::LaunchKernelDynamic
mindspore/mindspore/ccsrc/pipeline/jit/init.cc:PYBIND11_MODULE
mindspore/mindspore/ccsrc/plugin/device/gpu/kernel/math/unary_op_gpu_kernel.h:mindspore::kernel::UnaryOpGpuKernel::Launch
mindspore/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/dynamic_rnn_grad_fission_v2.cc:mindspore::opt::AddLSTMInputGradNode
mindspore/model_zoo/official/recommend/wide_and_deep/src/wide_and_deep.py:__init__
mindspore/model_zoo/official/recommend/wide_and_deep_multitable/src/wide_and_deep.py:__init__
mindspore/mindspore/ccsrc/pipeline/jit/resource.cc:mindspore::pipeline::GetMethodMap
mindspore/mindspore/python/mindspore/ops/operations/array_ops.py:_compute_slicing_shape
mindspore/mindspore/python/mindspore/context.py:set_auto_parallel_context
mindspore/mindspore/python/mindspore/common/tensor.py:__init__
mindspore/mindspore/python/mindspore/common/parameter.py:set_data
mindspore/mindspore/ccsrc/pybind_api/ir/tensor_py.cc:mindspore::tensor::GetDataType
mindspore/mindspore/lite/nnacl/fp32/avg_pooling_fp32.c:AvgPooling
mindspore/mindspore/lite/src/runtime/thread_pool.c:GetArch
mindspore/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d.cc:mindspore::kernel::UseWinograd4x4To6x6
mindspore/mindspore/lite/src/scheduler.cc:mindspore::lite::Scheduler::FindBackendKernel
mindspore/mindspore/lite/nnacl/infer/strided_slice_infer.c:StridedSliceInferShape
mindspore/mindspore/lite/nnacl/fp16/pack_fp16.c:PackNHWCToNCHWFp16
mindspore/mindspore/lite/src/ios_reg_ops.cc:mindspore::lite::IosRegisterOps
mindspore/mindspore/lite/src/ios_reg_kernels.h:mindspore::kernel::IosRegisterKernels
mindspore/mindspore/lite/nnacl/infer/infer_register.c:RegisterInfer
mindspore/mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.cc:mindspore::kernel::QuantDTypeCastCPUKernel::QuantDTypeCast
mindspore/mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.cc:mindspore::kernel::QuantDTypeCastCPUKernel::Run
mindspore/mindspore/ccsrc/pipeline/jit/static_analysis/prim.cc:mindspore::abstract::ConvertAbstractToPython
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/infer/strided_slice_infer.c:StridedSliceInferShape
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_transform_fp16.c:WinogradInputTransformFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/pooling_fp16.c:AvgPoolingFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/pooling_fp16.c:MaxPoolingFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform4x2UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform4x2ReluUnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform4x2Relu6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform8x6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform8x6ReluUnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform8x6Relu6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/pooling_int8.c:AvgPoolingOptInt8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/pooling_int8.c:MaxPoolingWithQuantInt8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv3x3_int8.c:Conv3x3Int8OutputUnit
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv_int8.c:Conv1x1PreOptPeroc
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/infer/infer_register.c:RegisterInfer
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad/gemm.c:RowMajor2Col12MajorStride
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32_grad/gemm.c:RowMajor2Col8MajorStride
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_transform_fp16.c:Conv3x3Fp16InputUnit
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_transform_fp16.c:Conv3x3Fp16FilterTransform
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/pooling_fp16.c:AvgPoolingFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/pooling_fp16.c:MaxPoolingFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/pack_fp16.c:PackNHWCToNCHWFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:InputTransform6x6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:InputTransform8x8UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform4x2Relu6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform8x6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform8x6ReluUnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/winograd_utils_fp16.c:OutputTransform8x6Relu6UnitFp16
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/pooling_int8.c:AvgPoolingOptInt8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv3x3_int8.c:Conv3x3Int8InputUnit
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv3x3_int8.c:Conv3x3Int8FilterTransform
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv3x3_int8.c:Conv3x3Int8OutputUnit
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv_int8.c:Conv1x1PreOptPeroc
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/conv_int8.c:Conv1x1PreOptPert
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/pack_int8.c:PackNHWCToNCHWInt8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/pooling_fp32.c:AvgPooling
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/matmul_fp32.c:MatMul4x1Kernel
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/conv_common_fp32.c:SWConv3x32Kernel, SWConv4x24Kernel, SWConv12x8Kernel, SWConv8x8Kernel, SWConv4x8Kernel, SWConv6x16Kernel, SWConv4x16Kernel
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/conv_depthwise_fp32.c:DepthwiseSW3x32Kernel, DepthwiseSW4x24Kernel, DepthwiseSW12x8Kernel, DepthwiseSW8x8Kernel, DepthwiseSW4x8Kernel, DepthwiseSW6x16Kernel, DepthwiseSW4x16Kernel
mindspore/mindspore/core/ir/dtype/type.cc:mindspore::ObjectIdLabel
mindspore/mindspore/python/mindspore/ops/_op_impl/_custom_op/dsd_impl.py:dsd_matmul
mindspore/mindspore/python/mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py:dsdbpropimpl
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/conv_1x1_x86_fp32.c:Conv1x1SW3x32Kernel, Conv1x1SW4x24Kernel, Conv1x1SW12x8Kernel, Conv1x1SW8x8Kernel, Conv1x1SW4x8Kernel, Conv1x1SW6x16Kernel, Conv1x1SW4x16Kernel, Conv1x1SW1x32Kernel, Conv1x1SW1x24Kernel, Conv1x1SW1x16Kernel, Conv1x1SW1x8Kernel
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/matmul_fp32.c:MatMul3x32Kernel, MatMul4x24Kernel, MatMul12x8Kernel, MatMul8x8Kernel, MatMul4x8Kernel, MatMul6x16Kernel, MatMul4x16Kernel, MatVecMul1x32Kernel, MatVecMul1x24Kernel, MatVecMul1x16Kernel, MatVecMul1x8Kernel
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/TiledC4MatMulFp32.c:TiledC4MatmulFp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/PostFuncBiasReluC4.c:PostFuncBiasReluC4
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/WinogradTrans.c:WinogradTransRight
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/WinogradTrans.c:WinogradTransLeft
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/WinogradPostFuncBiasReluC4.c:WinogradPostFuncBiasReluC4
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/PostFuncBiasReluC8.c:PostFuncBiasReluC8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/WinogradPostFuncBiasReluC8.c:WinogradPostFuncBiasReluC8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/deconv_winograd_fp32.c:PackDeConvWgDataFp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/WinogradPostFuncBiasReluC4.c:WinogradPostFuncBiasReluC4
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/sse/PostFuncBiasReluC8.c:PostFuncBiasReluC8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/WinogradTransAvx.c:WinogradTransLeft
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/WinogradTransAvx.c:WinogradTransRight
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/PostFuncBiasReluC8.c:PostFuncBiasReluC8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/WinogradPostFuncBiasReluC8.c:WinogradPostFuncBiasReluC8
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/deconv_winograd_fp32.c:PackDeConvWgDataFp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/deconv_winograd_fp32.c:DeConvWgMerge
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/intrinsics/avx/TiledC8MatMulFp32.c:TiledC8MatmulFp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/quant_dtype_cast_fp16.c:Fp16ToInt8_arm64
mindspore/mindspore/ccsrc/backend/common/session/gpu_session.cc:mindspore::session::gpu::GPUSession::LoadInputData
mindspore/mindspore/ccsrc/debug/dump_proto.cc:mindspore::ProtoExporter::SetNodeOutputType
mindspore/mindspore/ccsrc/debug/dump_proto.cc:mindspore::ProtoExporter::SetValueToProto
mindspore/mindspore/ccsrc/debug/dump_proto.cc:mindspore::ProtoExporter::SetScalarToProto
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_10x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_10x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_11x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_11x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_1x96_kernel_nhwc_fp32.c:nnacl_gemm_avx512_1x96_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_1x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_1x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_4x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_4x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_3x64_kernel_nhwc_fp32.c:nnacl_gemm_avx512_3x64_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_1x64_kernel_nhwc_fp32.c:nnacl_gemm_avx512_1x64_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_7x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_7x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_5x64_kernel_nhwc_fp32.c:nnacl_gemm_avx512_5x64_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_3x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_3x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_3x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_3x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_6x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_6x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_3x96_kernel_nhwc_fp32.c:nnacl_gemm_avx512_3x96_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_2x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_2x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_4x80_kernel_nhwc_fp32.c:nnacl_gemm_avx512_4x80_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_4x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_4x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_1x80_kernel_nhwc_fp32.c:nnacl_gemm_avx512_1x80_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_2x80_kernel_nhwc_fp32.c:nnacl_gemm_avx512_2x80_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_9x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_9x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_8x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_8x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_4x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_4x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_6x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_6x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_8x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_8x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_2x64_kernel_nhwc_fp32.c:nnacl_gemm_avx512_2x64_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_6x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_6x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_5x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_5x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_9x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_9x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_7x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_7x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_4x96_kernel_nhwc_fp32.c:nnacl_gemm_avx512_4x96_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_3x80_kernel_nhwc_fp32.c:nnacl_gemm_avx512_3x80_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_2x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_2x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_4x64_kernel_nhwc_fp32.c:nnacl_gemm_avx512_4x64_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_12x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_12x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_10x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_10x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_5x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_5x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_11x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_11x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_5x80_kernel_nhwc_fp32.c:nnacl_gemm_avx512_5x80_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_8x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_8x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_1x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_1x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_3x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_3x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_12x32_kernel_nhwc_fp32.c:nnacl_gemm_avx512_12x32_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_2x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_2x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_1x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_1x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_2x96_kernel_nhwc_fp32.c:nnacl_gemm_avx512_2x96_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_7x16_kernel_nhwc_fp32.c:nnacl_gemm_avx512_7x16_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_5x48_kernel_nhwc_fp32.c:nnacl_gemm_avx512_5x48_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_avx512/nnacl_gemm_avx512_6x64_kernel_nhwc_fp32.c:nnacl_gemm_avx512_6x64_kernel_nhwc_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x24_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_3x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_2x32_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_2x32_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_12x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_12x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_2x16_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_2x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_8x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_8x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_2x24_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_2x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x16_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_3x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x32_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_3x32_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_2x16_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_2x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x32_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_3x32_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_6x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_6x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_6x16_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_6x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_6x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_6x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_9x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_9x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_8x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_8x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_10x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_10x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_6x16_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_6x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_4x24_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_4x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_11x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_11x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_11x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_11x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_10x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_10x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x16_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_3x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_7x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_7x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_4x24_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_4x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_12x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_12x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_5x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_5x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_3x8_kernel_nc8hw8_fp32
mindspore/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc:mindspore::kernel::MatmulFp32BaseCPUKernel::init_global_variable
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_3x24_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_3x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_4x16_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_4x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_1x24_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_1x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_4x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_4x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_5x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_5x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_7x8_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_7x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_4x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_4x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_5x16_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_5x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_1x32_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_1x32_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_5x16_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_5x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_9x8_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_9x8_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_4x16_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_4x16_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_2x32_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_2x32_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_2x24_kernel_nc8hw8_fp32.c:nnacl_gemm_fma_2x24_kernel_nc8hw8_fp32
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/HPC-generator/gemm_fma/nnacl_gemm_fma_1x32_kernel_nc8hw8_fp32_asm.c:nnacl_gemm_fma_1x32_kernel_nc8hw8_fp32
mindspore/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc:mindspore::kernel::MatmulFp32BaseCPUKernel::Run
mindspore/mindspore/ccsrc/frontend/parallel/auto_parallel/rec_core/rec_partition.cc:mindspore::parallel::GetWeights
mindspore/mindspore/ccsrc/frontend/parallel/auto_parallel/rec_core/rec_partition.cc:mindspore::parallel::PartitionNode
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp16/instance_norm_fp16.c:InstanceNormNC8HW8Fp16
mindspore/mindspore/lite/src/runtime/kernel/arm/fp32/matmul_fp32_base.cc:mindspore::kernel::MatmulFp32BaseCPUKernel::init_global_variable
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/fp32/conv_winograd_fp32.c:ConvWinogardFp32
mindspore/mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fusion/lamb_next_mv_with_decay_v1_rule.cc:mindspore::opt::MatchAdd5Pattern
mindspore/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/experimental/conv_fp32_nchwx_avx512.c:conv2d_compute_fp32_nchwx_avx512

+ 0
- 73
.jenkins/task/config/mapping_task.yaml View File

@@ -1,73 +0,0 @@
# Copyright 2021 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.
# ============================================================================

MS_ALL:
include/api
mindspore/core
mindspore/ccsrc/cxx_api
mindspore/ccsrc/backend/common
mindspore/ccsrc/plugin/device/cpu/kernel/nnacl
mindspore/ccsrc/minddata
mindspore/ccsrc/CMakeLists.txt
mindspore/lite/java
mindspore/lite/src/train
mindspore/lite/src/runtime/kernel/arm/fp32
mindspore/lite/src/runtime/kernel/arm/fp32_grad
mindspore/ccsrc/backend/kernel_compiler
mindspore/ccsrc/fl
mindspore/ccsrc/ps
MS_CLOUD:
mindspore/python
mindspore/ccsrc
tests/st
MS_LITE:
include/c_api
include/api/allocator.h
include/api/delegate.h
include/api/kernel.h
include/api/model_parallel_runner.h
mindspore/lite/
cmake/package_lite.cmake
MS_CLOUD_UT:
tests/ut
MS_CLOUD_UT_CPP:
tests/ut/cpp
MS_CLOUD_UT_PYTHON:
tests/ut/python
MS_CLOUD_ST_ASCEND:
tests/st/ops/ascend
MS_CLOUD_ST_GPU:
tests/st/ops/gpu
MS_CLOUD_ST_CPU:
tests/st/ops/cpu
MS_CI:
.jenkins
.clang-format
MS_DOCS:
docker
docs
scripts
README.md
Readme.md
readme.md
README_CN.md
RELEASE.md
release.md
PULL_REQUEST_TEMPLATE.md
CONTRIBUTING.md
LICENSE
NOTICE
SECURITY.md
Third_Party_Open_Source_Software

+ 17
- 95
CMakeLists.txt View File

@@ -1,89 +1,29 @@
cmake_minimum_required(VERSION 3.14.0)
project(MindSpore)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0)
message(FATAL_ERROR "GCC version ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.3.0)
message(WARNING "GCC version ${CMAKE_CXX_COMPILER_VERSION} is greater than 7.3.0, may cause unknown problems.")
endif()
endif()
cmake_minimum_required(VERSION 3.14)
project (MindSpore)


include(${CMAKE_SOURCE_DIR}/cmake/options.cmake) include(${CMAKE_SOURCE_DIR}/cmake/options.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/check_requirements.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
if(NOT ENABLE_GLIBCXX)
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wno-inconsistent-missing-override \
-Wno-unused-lambda-capture -Wno-unneeded-internal-declaration -Wno-unused-variable \
-Wno-return-std-move -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
elseif(ENABLE_SYM_FILE)
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -g -ggdb -Wl,--allow-shlib-undefined \
-DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
else()
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wl,--allow-shlib-undefined \
-DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
endif()


if(ENABLE_PYTHON)
add_compile_definitions(ENABLE_PYTHON)
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer \
-D_LIBCPP_INLINE_VISIBILITY='' -D_LIBCPP_DISABLE_EXTERN_TEMPLATE=1 -DHALF_ENABLE_CPP11_USER_LITERALS=0 \
-D_FORTIFY_SOURCE=2 -Wno-cpp -Wno-inconsistent-missing-override -Wno-unused-lambda-capture \
-Wno-unneeded-internal-declaration -Wno-unused-variable -Wno-return-std-move")
else()
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer \
-Wl,--allow-shlib-undefined -D_LIBCPP_INLINE_VISIBILITY='' -D_LIBCPP_DISABLE_EXTERN_TEMPLATE=1 \
-DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2 -Wno-cpp")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -std=c++17 \
-Werror -Wall -Wno-deprecated-declarations -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -Wl,--allow-shlib-undefined -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)=' -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2 -Wno-cpp")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wl,--allow-shlib-undefined -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -std=c++17 -Werror -Wall -Wno-deprecated-declarations -fPIC")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


set(PYBIND11_CPP_STANDARD -std=c++17) set(PYBIND11_CPP_STANDARD -std=c++17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS}")


if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux")
add_subdirectory("${CMAKE_SOURCE_DIR}/akg")
endif()

find_package(Threads)
include(${CMAKE_SOURCE_DIR}/cmake/mind_expression.cmake) include(${CMAKE_SOURCE_DIR}/cmake/mind_expression.cmake)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/securec/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include/flatbuffers) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include/flatbuffers)


if(ENABLE_FAST_HASH_TABLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_FAST_HASH_TABLE=1")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/robin_hood/include)
endif()

include(${CMAKE_SOURCE_DIR}/cmake/dependency_utils.cmake) include(${CMAKE_SOURCE_DIR}/cmake/dependency_utils.cmake)
find_package(Python3 COMPONENTS Interpreter Development) find_package(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND) if(Python3_FOUND)
set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
set(PYTHON_LIBRARIES "${Python3_LIBRARIES}") set(PYTHON_LIBRARIES "${Python3_LIBRARIES}")
if(WIN32)
if(Python3_DIR)
message("Python3_DIR set already: " ${Python3_DIR})
else()
string(LENGTH ${PYTHON_LIBRARIES} PYTHON_LIBRARIES_LEN)
string(LENGTH "libpythonxx.a" Python3_NAME_LEN)
math(EXPR Python3_DIR_LEN ${PYTHON_LIBRARIES_LEN}-${Python3_NAME_LEN})
string(SUBSTRING ${Python3_LIBRARIES} 0 ${Python3_DIR_LEN} Python3_DIR)
message("Python3_DIR: " ${Python3_DIR})
endif()
link_directories(${Python3_DIR})
endif()
else() else()
find_python_package(py_inc py_lib) find_python_package(py_inc py_lib)
set(PYTHON_INCLUDE_DIRS "${py_inc}") set(PYTHON_INCLUDE_DIRS "${py_inc}")
@@ -96,38 +36,20 @@ include_directories(${PYTHON_INCLUDE_DIRS})
set(MS_CCSRC_PATH ${CMAKE_SOURCE_DIR}/mindspore/ccsrc) set(MS_CCSRC_PATH ${CMAKE_SOURCE_DIR}/mindspore/ccsrc)
set(MS_CCSRC_BUILD_PATH ${BUILD_PATH}/mindspore/mindspore/ccsrc) set(MS_CCSRC_BUILD_PATH ${BUILD_PATH}/mindspore/mindspore/ccsrc)


if(ENABLE_D OR ENABLE_ACL OR ENABLE_TESTCASES)
if (ENABLE_GE)
link_directories(${CMAKE_SOURCE_DIR}/third_party/ge/lib)
else()
include(${CMAKE_SOURCE_DIR}/cmake/dependency_graphengine.cmake) include(${CMAKE_SOURCE_DIR}/cmake/dependency_graphengine.cmake)
endif() endif()


include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/external)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/inc/framework)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc/toolchain)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
add_subdirectory(mindspore/ccsrc) add_subdirectory(mindspore/ccsrc)
add_subdirectory(mindspore/core)

if(DEFINED ENV{ENABLE_CLOUD_AND_LITE})
set(ENABLE_CLOUD_AND_LITE $ENV{ENABLE_CLOUD_AND_LITE})
endif()
if(ENABLE_CLOUD_AND_LITE)
add_subdirectory(mindspore/lite)
endif()

if(ENABLE_TESTCASES OR ENABLE_CPP_ST)
if (ENABLE_TESTCASES)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()

# packaging
file(READ ${CMAKE_SOURCE_DIR}/version.txt VERSION_NUMBER)
string(REPLACE "\n" "" VERSION_NUMBER ${VERSION_NUMBER})
if(${VERSION_NUMBER} MATCHES ".*dev.*")
message("building dev mode")
set(BUILD_DEV_MODE ON)
endif()
if(MODE_ASCEND_ACL)
include(cmake/package_tar.cmake)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
include(cmake/package_win.cmake)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
include(cmake/package_mac.cmake)
else()
include(cmake/package.cmake)
endif()

+ 16
- 35
CONTRIBUTING.md View File

@@ -30,37 +30,23 @@ For individual contributor, please refer to [ICLA online document](https://www.m


Please follow this style to make MindSpore easy to review, maintain and develop. Please follow this style to make MindSpore easy to review, maintain and develop.


- Coding guidelines
* Coding guidelines


The *Python* coding style suggested by [Python PEP 8 Coding Style](https://pep8.org/) and *C++* coding style suggested by [Google C++ Coding Guidelines](http://google.github.io/styleguide/cppguide.html) are used in MindSpore community. The [CppLint](https://github.com/cpplint/cpplint), [CppCheck](http://cppcheck.sourceforge.net), [CMakeLint](https://github.com/cmake-lint/cmake-lint), [CodeSpell](https://github.com/codespell-project/codespell), [Lizard](http://www.lizard.ws), [ShellCheck](https://github.com/koalaman/shellcheck) and [PyLint](https://pylint.org) are used to check the format of codes, installing these plugins in your IDE is recommended.
The *Python* coding style suggested by [Python PEP 8 Coding Style](https://pep8.org/) and *C++* coding style suggested by [Google C++ Coding Guidelines](http://google.github.io/styleguide/cppguide.html) are used in MindSpore community.


- Unittest guidelines
* Unittest guidelines


The *Python* unittest style suggested by [pytest](http://www.pytest.org/en/latest/) and *C++* unittest style suggested by [Googletest Primer](https://github.com/google/googletest/blob/master/docs/primer.md) are used in MindSpore community. The design intent of a testcase should be reflected by its name of comment.

- Refactoring guidelines

We encourage developers to refactor our code to eliminate the [code smell](https://en.wikipedia.org/wiki/Code_smell). All codes should conform to needs to the coding style and testing style, and refactoring codes are no exception. [Lizard](http://www.lizard.ws) threshold for nloc (lines of code without comments) is 100 and for cnc (cyclomatic complexity number) is 20, when you receive a *Lizard* warning, you have to refactor the code you want to merge.

- Document guidelines

We use *MarkdownLint* to check the format of markdown documents. MindSpore CI modifies the following rules based on the default configuration.
- MD007 (unordered list indentation): The **indent** parameter is set to **4**, indicating that all content in the unordered list needs to be indented using four spaces.
- MD009 (spaces at the line end): The **br_spaces** parameter is set to **2**, indicating that there can be 0 or 2 spaces at the end of a line.
- MD029 (sequence numbers of an ordered list): The **style** parameter is set to **ordered**, indicating that the sequence numbers of the ordered list are in ascending order.

For details, please refer to [RULES](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md).
The *Python* unittest style suggested by [pytest](http://www.pytest.org/en/latest/) and *C++* unittest style suggested by [Googletest Primer](https://github.com/google/googletest/blob/master/googletest/docs/primer.md) are used in MindSpore community.


### Fork-Pull development model ### Fork-Pull development model


- Fork MindSpore repository
* Fork MindSpore repository


Before submitting code to MindSpore project, please make sure that this project have been forked to your own repository. It means that there will be parallel development between MindSpore repository and your own repository, so be careful to avoid the inconsistency between them. Before submitting code to MindSpore project, please make sure that this project have been forked to your own repository. It means that there will be parallel development between MindSpore repository and your own repository, so be careful to avoid the inconsistency between them.


- Clone the remote repository
* Clone the remote repository


If you want to download the code to the local machine, `git` is the best way: If you want to download the code to the local machine, `git` is the best way:

```shell ```shell
# For GitHub # For GitHub
git clone https://github.com/{insert_your_forked_repo}/mindspore.git git clone https://github.com/{insert_your_forked_repo}/mindspore.git
@@ -70,21 +56,18 @@ Please follow this style to make MindSpore easy to review, maintain and develop.
git remote add upstream https://gitee.com/mindspore/mindspore.git git remote add upstream https://gitee.com/mindspore/mindspore.git
``` ```


- Develop code locally
* Develop code locally


To avoid inconsistency between multiple branches, checking out to a new branch is `SUGGESTED`: To avoid inconsistency between multiple branches, checking out to a new branch is `SUGGESTED`:

```shell ```shell
git checkout -b {new_branch_name} origin/master git checkout -b {new_branch_name} origin/master
``` ```


Taking the master branch as an example, MindSpore may create version branches and downstream development branches as needed, please fix bugs upstream first.
Then you can change the code arbitrarily. Then you can change the code arbitrarily.


- Push the code to the remote repository
* Push the code to the remote repository


After updating the code, you should push the update in the formal way: After updating the code, you should push the update in the formal way:

```shell ```shell
git add . git add .
git status # Check the update status git status # Check the update status
@@ -93,9 +76,9 @@ Please follow this style to make MindSpore easy to review, maintain and develop.
git push origin {new_branch_name} git push origin {new_branch_name}
``` ```


- Pull a request to MindSpore repository
* Pull a request to MindSpore repository


In the last step, your need to pull a compare request between your new branch and MindSpore `master` branch. After finishing the pull request, the Jenkins CI will be automatically set up for building test. Your pull request should be merged into the upstream master branch as soon as possible to reduce the risk of merging.
In the last step, your need to pull a compare request between your new branch and MindSpore `master` branch. After finishing the pull request, the Jekins CI will be automatically set up for building test.


### Report issues ### Report issues


@@ -105,7 +88,6 @@ When reporting issues, refer to this format:


- What version of env (mindspore, os, python etc) are you using? - What version of env (mindspore, os, python etc) are you using?
- Is this a BUG REPORT or FEATURE REQUEST? - Is this a BUG REPORT or FEATURE REQUEST?
- What kind of issue is, add the labels to highlight it on the issue dashboard.
- What happened? - What happened?
- What you expected to happen? - What you expected to happen?
- How to reproduce it?(as minimally and precisely as possible) - How to reproduce it?(as minimally and precisely as possible)
@@ -116,19 +98,18 @@ When reporting issues, refer to this format:
- **If you find an unclosed issue, which is exactly what you are going to solve,** please put some comments on that issue to tell others you would be in charge of it. - **If you find an unclosed issue, which is exactly what you are going to solve,** please put some comments on that issue to tell others you would be in charge of it.
- **If an issue is opened for a while,** it's recommended for contributors to precheck before working on solving that issue. - **If an issue is opened for a while,** it's recommended for contributors to precheck before working on solving that issue.
- **If you resolve an issue which is reported by yourself,** it's also required to let others know before closing that issue. - **If you resolve an issue which is reported by yourself,** it's also required to let others know before closing that issue.
- **If you want the issue to be responded as quickly as possible,** please try to label it, you can find kinds of labels on [Label List](https://gitee.com/mindspore/community/blob/master/sigs/dx/docs/labels.md)


### Propose PRs ### Propose PRs


- Raise your idea as an *issue* on [GitHub](https://github.com/mindspore-ai/mindspore/issues) or [Gitee](https://gitee.com/mindspore/mindspore/issues)
- If it is a new feature that needs lots of design details, a design proposal should also be submitted.
- After reaching consensus in the issue discussions and design proposal reviews, complete the development on the forked repo and submit a PR.
- None of PRs is not permitted until it receives **2+ LGTM** from approvers. Please NOTICE that approver is NOT allowed to add *LGTM* on his own PR.
- After PR is sufficiently discussed, it will get merged, abandoned or rejected depending on the outcome of the discussion.
* Raise your idea as an *issue* on [GitHub](https://github.com/mindspore-ai/mindspore/issues) or [Gitee](https://gitee.com/mindspore/mindspore/issues)
* If it is a new feature that needs lots of design details, a design proposal should also be submitted.
* After reaching consensus in the issue discussions and design proposal reviews, complete the development on the forked repo and submit a PR.
* None of PRs is not permitted until it receives **2+ LGTM** from approvers. Please NOTICE that approver is NOT allowed to add *LGTM* on his own PR.
* After PR is sufficiently discussed, it will get merged, abondoned or rejected depending on the outcome of the discussion.


**PRs advisory:** **PRs advisory:**


- Any irrelevant changes should be avoided. - Any irrelevant changes should be avoided.
- Make sure your commit history being ordered. - Make sure your commit history being ordered.
- Always keep your branch up with the master branch. - Always keep your branch up with the master branch.
- For bug-fix PRs, make sure all related issues being linked.
- For bug-fix PRs, make sure all related issues being linked.

+ 0
- 28
OWNERS View File

@@ -1,28 +0,0 @@
approvers:
- kingxian
- guoqi1024
- baochong
- zhaizhiqiang
- stsuteng
- kisnwang

files:
"akg":
approvers:
- gaoxiong1
- ckey_dou
- anyrenwei

"graphengine":
approvers:
- zhoufeng54
- jjfeing
- guoqi1024
- baochong

"version.txt":
approvers:
- zhoufeng54
- jjfeing
- guoqi1024
- baochong

+ 33
- 213
README.md View File

@@ -1,37 +1,21 @@
![MindSpore Logo](https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-logo.png "MindSpore logo")
![MindSpore Logo](docs/MindSpore-logo.png "MindSpore logo")
============================================================


[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mindspore.svg)](https://pypi.org/project/mindspore)
[![PyPI](https://badge.fury.io/py/mindspore.svg)](https://badge.fury.io/py/mindspore)
[![Downloads](https://pepy.tech/badge/mindspore)](https://pepy.tech/project/mindspore)
[![DockerHub](https://img.shields.io/docker/pulls/mindspore/mindspore-cpu.svg)](https://hub.docker.com/r/mindspore/mindspore-cpu)
[![LICENSE](https://img.shields.io/github/license/mindspore-ai/mindspore.svg?style=flat-square)](https://github.com/mindspore-ai/mindspore/blob/master/LICENSE)
[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gitee.com/mindspore/mindspore/pulls)

[查看中文](./README_CN.md)

<!-- TOC -->

- [What Is MindSpore](#what-is-mindspore)
- [What is MindSpore?](#what-is-MindSpore)
- [Automatic Differentiation](#automatic-differentiation) - [Automatic Differentiation](#automatic-differentiation)
- [Automatic Parallel](#automatic-parallel) - [Automatic Parallel](#automatic-parallel)
- [Installation](#installation) - [Installation](#installation)
- [Pip mode method installation](#pip-mode-method-installation)
- [Source code compilation installation](#source-code-compilation-installation)
- [Docker Image](#docker-image)
- [Binaries](#binaries)
- [From Source](#from-source)
- [Quickstart](#quickstart) - [Quickstart](#quickstart)
- [Docs](#docs) - [Docs](#docs)
- [Community](#community) - [Community](#community)
- [Governance](#governance) - [Governance](#governance)
- [Communication](#communication) - [Communication](#communication)
- [Contributing](#contributing) - [Contributing](#contributing)
- [Maintenance phases](#maintenance-phases)
- [Maintenance status](#maintenance-status)
- [Release Notes](#release-notes) - [Release Notes](#release-notes)
- [License](#license) - [License](#license)


<!-- /TOC -->

## What Is MindSpore ## What Is MindSpore


MindSpore is a new open source deep learning training/inference framework that MindSpore is a new open source deep learning training/inference framework that
@@ -42,22 +26,23 @@ processor, and software hardware co-optimization. At the meantime MindSpore as
a global AI open source community, aims to further advance the development and a global AI open source community, aims to further advance the development and
enrichment of the AI software/hardware application ecosystem. enrichment of the AI software/hardware application ecosystem.


<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-architecture.png" alt="MindSpore Architecture"/>
<img src="docs/MindSpore-architecture.png" alt="MindSpore Architecture" width="600"/>


For more details please check out our [Architecture Guide](https://www.mindspore.cn/docs/programming_guide/en/master/architecture.html).
For more details please check out our [Architecture Guide](https://www.mindspore.cn/docs/en/0.1.0-alpha/architecture.html).


### Automatic Differentiation ### Automatic Differentiation


Currently, there are two automatic differentiation techniques in mainstream deep learning frameworks:
There are currently three automatic differentiation techniques in mainstream deep learning frameworks:


- **Operator Overloading (OO)**: Overloading the basic operators of the programming language to encapsulate their gradient rules. Record the operation trajectory of the network during forward execution in an operator overloaded manner, then apply the chain rule to the dynamically generated data flow graph to implement automatic differentiation.
- **Source Transformation (ST)**: This technology is evolving from the functional programming framework and performs automatic differential transformation on the intermediate expression (the expression form of the program during the compilation process) in the form of just-in-time compilation (JIT), supporting complex control flow scenarios, higher-order functions and closures.
- **Conversion based on static compute graph**: Convert the network into a static data flow graph at compile time, then turn the chain rule into a data flow graph to implement automatic differentiation.
- **Conversion based on dynamic compute graph**: Record the operation trajectory of the network during forward execution in an operator overloaded manner, then apply the chain rule to the dynamically generated data flow graph to implement automatic differentiation.
- **Conversion based on source code**: This technology is evolving from the functional programming framework and performs automatic differential transformation on the intermediate expression (the expression form of the program during the compilation process) in the form of just-in-time compilation (JIT), supporting complex control flow scenarios, higher-order functions and closures.


PyTorch used OO. Compared to ST, OO generates gradient graph in runtime, so it does not need to take function call and control flow into consideration, which makes it easier to develop. However, OO can not perform gradient graph optimization in compilation time and the control flow has to be unfolded in runtime, so it is difficult to achieve extreme optimization in performance.
TensorFlow adopted static calculation diagrams in the early days, whereas PyTorch used dynamic calculation diagrams. Static maps can utilize static compilation technology to optimize network performance, however, building a network or debugging it is very complicated. The use of dynamic graphics is very convenient, but it is difficult to achieve extreme optimization in performance.


MindSpore implemented automatic differentiation based on ST. On the one hand, it supports automatic differentiation of automatic control flow, so it is quite convenient to build models like PyTorch. On the other hand, MindSpore can perform static compilation optimization on neural networks to achieve great performance.
But MindSpore finds another way, automatic differentiation based on source code conversion. On the one hand, it supports automatic differentiation of automatic control flow, so it is quite convenient to build models like PyTorch. On the other hand, MindSpore can perform static compilation optimization on neural networks to achieve great performance.


<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>
<img src="docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>


The implementation of MindSpore automatic differentiation can be understood as the symbolic differentiation of the program itself. Because MindSpore IR is a functional intermediate expression, it has an intuitive correspondence with the composite function in basic algebra. The derivation formula of the composite function composed of arbitrary basic functions can be derived. Each primitive operation in MindSpore IR can correspond to the basic functions in basic algebra, which can build more complex flow control. The implementation of MindSpore automatic differentiation can be understood as the symbolic differentiation of the program itself. Because MindSpore IR is a functional intermediate expression, it has an intuitive correspondence with the composite function in basic algebra. The derivation formula of the composite function composed of arbitrary basic functions can be derived. Each primitive operation in MindSpore IR can correspond to the basic functions in basic algebra, which can build more complex flow control.


@@ -65,181 +50,46 @@ The implementation of MindSpore automatic differentiation can be understood as t


The goal of MindSpore automatic parallel is to build a training method that combines data parallelism, model parallelism, and hybrid parallelism. It can automatically select a least cost model splitting strategy to achieve automatic distributed parallel training. The goal of MindSpore automatic parallel is to build a training method that combines data parallelism, model parallelism, and hybrid parallelism. It can automatically select a least cost model splitting strategy to achieve automatic distributed parallel training.


<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>
<img src="docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>


At present, MindSpore uses a fine-grained parallel strategy of splitting operators, that is, each operator in the figure is split into a cluster to complete parallel operations. The splitting strategy during this period may be very complicated, but as a developer advocating Pythonic, you don't need to care about the underlying implementation, as long as the top-level API compute is efficient.
At present, MindSpore uses a fine-grained parallel strategy of splitting operators, that is, each operator in the figure is splited into a cluster to complete parallel operations. The splitting strategy during this period may be very complicated, but as a developer advocating Pythonic, you don't need to care about the underlying implementation, as long as the top-level API compute is efficient.


## Installation ## Installation


### Pip mode method installation
### Binaries


MindSpore offers build options across multiple backends: MindSpore offers build options across multiple backends:


| Hardware Platform | Operating System | Status | | Hardware Platform | Operating System | Status |
| :---------------- | :--------------- | :----- | | :---------------- | :--------------- | :----- |
| Ascend910 | Ubuntu-x86 | ✔️ | | Ascend910 | Ubuntu-x86 | ✔️ |
| | Ubuntu-aarch64 | ✔️ |
| | EulerOS-x86 | ✔️ |
| | EulerOS-aarch64 | ✔️ | | | EulerOS-aarch64 | ✔️ |
| | CentOS-x86 | ✔️ |
| | CentOS-aarch64 | ✔️ |
| GPU CUDA 9.2 | Ubuntu-x86 | ✔️ |
| GPU CUDA 10.1 | Ubuntu-x86 | ✔️ | | GPU CUDA 10.1 | Ubuntu-x86 | ✔️ |
| CPU | Ubuntu-x86 | ✔️ | | CPU | Ubuntu-x86 | ✔️ |
| | Ubuntu-aarch64 | ✔️ |
| | Windows-x86 | ✔️ |

For installation using `pip`, take `CPU` and `Ubuntu-x86` build version as an example:

1. Download whl from [MindSpore download page](https://www.mindspore.cn/versions/en), and install the package.

```bash
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindSpore/cpu/ubuntu_x86/mindspore-1.2.0rc1-cp37-cp37m-linux_x86_64.whl
```

2. Run the following command to verify the install.

```python
import numpy as np
import mindspore.context as context
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.ops import operations as P

context.set_context(mode=context.GRAPH_MODE, device_target="CPU")

class Mul(nn.Cell):
def __init__(self):
super(Mul, self).__init__()
self.mul = P.Mul()

def construct(self, x, y):
return self.mul(x, y)

x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))

mul = Mul()
print(mul(x, y))
```

```text
[ 4. 10. 18.]
```

Use pip mode method to install MindSpore in different environments. Refer to the following documents.

- [Using pip mode method to install MindSpore in Ascend environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_pip_en.md)
- [Using pip mode method to install MindSpore in GPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_pip_en.md)
- [Using pip mode method to install MindSpore in CPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_pip_en.md)

### Source code compilation installation

Use the source code compilation method to install MindSpore in different environments. Refer to the following documents.


- [Using the source code compilation method to install MindSpore in Ascend environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_source_en.md)
- [Using the source code compilation method to install MindSpore in GPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_source_en.md)
- [Using the source code compilation method to install MindSpore in CPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_source_en.md)
For installation using pip, take `Ubuntu-x86` and `CPU` build version as an example:


### Docker Image
1. Download whl from [MindSpore website](https://www.mindspore.cn/), and install the package.


MindSpore docker image is hosted on [Docker Hub](https://hub.docker.com/r/mindspore),
currently the containerized build options are supported as follows:

| Hardware Platform | Docker Image Repository | Tag | Description |
| :---------------- | :---------------------- | :-- | :---------- |
| CPU | `mindspore/mindspore-cpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` CPU release. |
| | | `devel` | Development environment provided to build MindSpore (with `CPU` backend) from the source, refer to <https://www.mindspore.cn/install/en> for installation details. |
| | | `runtime` | Runtime environment provided to install MindSpore binary package with `CPU` backend. |
| GPU | `mindspore/mindspore-gpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` GPU release. |
| | | `devel` | Development environment provided to build MindSpore (with `GPU CUDA10.1` backend) from the source, refer to <https://www.mindspore.cn/install/en> for installation details. |
| | | `runtime` | Runtime environment provided to install MindSpore binary package with `GPU CUDA10.1` backend. |

> **NOTICE:** For GPU `devel` docker image, it's NOT suggested to directly install the whl package after building from the source, instead we strongly RECOMMEND you transfer and install the whl package inside GPU `runtime` docker image.

- CPU

For `CPU` backend, you can directly pull and run the latest stable image using the below command:

```bash
docker pull mindspore/mindspore-cpu:1.1.0
docker run -it mindspore/mindspore-cpu:1.1.0 /bin/bash
```

- GPU

For `GPU` backend, please make sure the `nvidia-container-toolkit` has been installed in advance, here are some install guidelines for `Ubuntu` users:

```bash
DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list

sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
sudo systemctl restart docker
``` ```

Then edit the file daemon.json:

```bash
$ vim /etc/docker/daemon.json
{
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/0.1.0-alpha/MindSpore/cpu/ubuntu-x86/mindspore-0.1.0-cp37-cp37m-linux_x86_64.whl
``` ```


Restart docker again:

```bash
sudo systemctl daemon-reload
sudo systemctl restart docker
```

Then you can pull and run the latest stable image using the below command:
2. Run the following command to verify the install.


```bash
docker pull mindspore/mindspore-gpu:1.1.0
docker run -it -v /dev/shm:/dev/shm --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.1.0 /bin/bash
``` ```

To test if the docker image works, please execute the python code below and check the output:

```python
import numpy as np
import mindspore.context as context
from mindspore import Tensor
from mindspore.ops import functional as F

context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")

x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
print(F.tensor_add(x, y))
python -c 'import mindspore'
``` ```


```text
[[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]],

[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]],
### From Source


[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]]]
```

If you want to learn more about the building process of MindSpore docker images,
please check out [docker](https://gitee.com/mindspore/mindspore/blob/master/scripts/docker/README.md) repo for the details.
[Install MindSpore](https://www.mindspore.cn/install/en).


## Quickstart ## Quickstart


See the [Quick Start](https://www.mindspore.cn/tutorials/en/master/beginner/quick_start.html)
See the [Quick Start](https://www.mindspore.cn/tutorial/en/0.1.0-alpha/quick_start/quick_start.html)
to implement the image classification. to implement the image classification.


## Docs ## Docs
@@ -255,50 +105,20 @@ Check out how MindSpore Open Governance [works](https://gitee.com/mindspore/comm


### Communication ### Communication


- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) - Communication platform for developers.
- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/enQtOTcwMTIxMDI3NjM0LTNkMWM2MzI5NjIyZWU5ZWQ5M2EwMTQ5MWNiYzMxOGM4OWFhZjI4M2E5OGI2YTg3ODU1ODE2Njg1MThiNWI3YmQ) - Communication platform for developers.
- IRC channel at `#mindspore` (only for meeting minutes logging purpose) - IRC channel at `#mindspore` (only for meeting minutes logging purpose)
- Video Conferencing: TBD
- Mailing-list: <https://mailweb.mindspore.cn/postorius/lists>
- Video Conferencing: meet.jit.si
- Mailing-list: https://mailweb.mindspore.cn/postorius/lists


## Contributing ## Contributing


Welcome contributions. See our [Contributor Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md) for
Welcome contributions. See our [Contributor Wiki](CONTRIBUTING.md) for
more details. more details.


## Maintenance phases

Project stable branches will be in one of the following states:

| **State** | **Time frame** | **Summary** |
|-------------|---------------|--------------------------------------------------|
| Planning | 1 - 3 months | Features are under planning. |
| Development | 3 months | Features are under development. |
| Maintained | 6 - 12 months | All bugfixes are appropriate. Releases produced. |
| Unmaintained| 0 - 3 months | All bugfixes are appropriate. No Maintainers and No Releases produced. |
| End Of Life (EOL) | N/A | Branch no longer accepting changes. |

## Maintenance status

| **Branch** | **Status** | **Initial Release Date** | **Next Phase** | **EOL Date**|
|------------|--------------|--------------------------|----------------------------------------|-------------|
| **r1.6** | Maintained | 2022-01-29 | Unmaintained <br> 2023-01-29 estimated | |
| **r1.5** | Maintained | 2021-10-15 | Unmaintained <br> 2022-10-15 estimated | |
| **r1.4** | Maintained | 2021-08-15 | Unmaintained <br> 2022-08-15 estimated | |
| **r1.3** | Maintained | 2021-07-15 | Unmaintained <br> 2022-07-15 estimated | |
| **r1.2** | Unmaintained | 2021-04-15 | End Of Life <br> 2022-04-15 estimated | |
| **r1.1** | End Of Life | 2020-12-31 | | 2021-09-30 |
| **r1.0** | End Of Life | 2020-09-24 | | 2021-07-30 |
| **r0.7** | End Of Life | 2020-08-31 | | 2021-02-28 |
| **r0.6** | End Of Life | 2020-07-31 | | 2020-12-30 |
| **r0.5** | End Of Life | 2020-06-30 | | 2021-06-30 |
| **r0.3** | End Of Life | 2020-05-31 | | 2020-09-30 |
| **r0.2** | End Of Life | 2020-04-30 | | 2020-08-31 |
| **r0.1** | End Of Life | 2020-03-28 | | 2020-06-30 |

## Release Notes ## Release Notes


The release notes, see our [RELEASE](https://gitee.com/mindspore/mindspore/blob/master/RELEASE.md).
The release notes, see our [RELEASE](RELEASE.md).


## License ## License


[Apache License 2.0](https://gitee.com/mindspore/mindspore#/mindspore/mindspore/blob/master/LICENSE)
[Apache License 2.0](LICENSE)

+ 0
- 297
README_CN.md View File

@@ -1,297 +0,0 @@
![MindSpore标志](https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-logo.png "MindSpore logo")

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mindspore.svg)](https://pypi.org/project/mindspore)
[![PyPI](https://badge.fury.io/py/mindspore.svg)](https://badge.fury.io/py/mindspore)
[![Downloads](https://pepy.tech/badge/mindspore)](https://pepy.tech/project/mindspore)
[![DockerHub](https://img.shields.io/docker/pulls/mindspore/mindspore-cpu.svg)](https://hub.docker.com/r/mindspore/mindspore-cpu)
[![LICENSE](https://img.shields.io/github/license/mindspore-ai/mindspore.svg?style=flat-square)](https://github.com/mindspore-ai/mindspore/blob/master/LICENSE)
[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gitee.com/mindspore/mindspore/pulls)

[View English](./README.md)

<!-- TOC -->

- [MindSpore介绍](#mindspore介绍)
- [自动微分](#自动微分)
- [自动并行](#自动并行)
- [安装](#安装)
- [pip方式安装](#pip方式安装)
- [源码编译方式安装](#源码编译方式安装)
- [Docker镜像](#docker镜像)
- [快速入门](#快速入门)
- [文档](#文档)
- [社区](#社区)
- [治理](#治理)
- [交流](#交流)
- [贡献](#贡献)
- [分支维护策略](#分支维护策略)
- [现有分支维护状态](#现有分支维护状态)
- [版本说明](#版本说明)
- [许可证](#许可证)

<!-- /TOC -->

## MindSpore介绍

MindSpore是一种适用于端边云场景的新型开源深度学习训练/推理框架。
MindSpore提供了友好的设计和高效的执行,旨在提升数据科学家和算法工程师的开发体验,并为Ascend AI处理器提供原生支持,以及软硬件协同优化。

同时,MindSpore作为全球AI开源社区,致力于进一步开发和丰富AI软硬件应用生态。

<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-architecture-zh.png" alt="MindSpore Architecture"/>

欲了解更多详情,请查看我们的[总体架构](https://www.mindspore.cn/docs/programming_guide/zh-CN/master/architecture.html)。

### 自动微分

当前主流深度学习框架中有两种自动微分技术:

- **操作符重载法**: 通过操作符重载对编程语言中的基本操作语义进行重定义,封装其微分规则。 在程序运行时记录算子过载正向执行时网络的运行轨迹,对动态生成的数据流图应用链式法则,实现自动微分。
- **代码变换法**: 该技术是从功能编程框架演进而来,以即时编译(Just-in-time Compilation,JIT)的形式对中间表达式(程序在编译过程中的表达式)进行自动差分转换,支持复杂的控制流场景、高阶函数和闭包。

PyTorch采用的是操作符重载法。相较于代码变换法,操作符重载法是在运行时生成微分计算图的, 无需考虑函数调用与控制流等情况, 开发更为简单。 但该方法不能在编译时刻做微分图的优化, 控制流也需要根据运行时的信息来展开, 很难实现性能的极限优化。

MindSpore则采用的是代码变换法。一方面,它支持自动控制流的自动微分,因此像PyTorch这样的模型构建非常方便。另一方面,MindSpore可以对神经网络进行静态编译优化,以获得更好的性能。

<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>

MindSpore自动微分的实现可以理解为程序本身的符号微分。MindSpore IR是一个函数中间表达式,它与基础代数中的复合函数具有直观的对应关系。复合函数的公式由任意可推导的基础函数组成。MindSpore IR中的每个原语操作都可以对应基础代数中的基本功能,从而可以建立更复杂的流控制。

### 自动并行

MindSpore自动并行的目的是构建数据并行、模型并行和混合并行相结合的训练方法。该方法能够自动选择开销最小的模型切分策略,实现自动分布并行训练。

<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>

目前MindSpore采用的是算子切分的细粒度并行策略,即图中的每个算子被切分为一个集群,完成并行操作。在此期间的切分策略可能非常复杂,但是作为一名Python开发者,您无需关注底层实现,只要顶层API计算是有效的即可。

## 安装

### pip方式安装

MindSpore提供跨多个后端的构建选项:

| 硬件平台 | 操作系统 | 状态 |
| :------------ | :-------------- | :--- |
| Ascend 910 | Ubuntu-x86 | ✔️ |
| | Ubuntu-aarch64 | ✔️ |
| | EulerOS-aarch64 | ✔️ |
| | CentOS-x86 | ✔️ |
| | CentOS-aarch64 | ✔️ |
| GPU CUDA 10.1 | Ubuntu-x86 | ✔️ |
| CPU | Ubuntu-x86 | ✔️ |
| | Ubuntu-aarch64 | ✔️ |
| | Windows-x86 | ✔️ |

使用`pip`命令安装,以`CPU`和`Ubuntu-x86`build版本为例:

1. 请从[MindSpore下载页面](https://www.mindspore.cn/versions)下载并安装whl包。

```bash
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindSpore/cpu/ubuntu_x86/mindspore-1.2.0rc1-cp37-cp37m-linux_x86_64.whl
```

2. 执行以下命令,验证安装结果。

```python
import numpy as np
import mindspore.context as context
import mindspore.nn as nn
from mindspore import Tensor
from mindspore.ops import operations as P

context.set_context(mode=context.GRAPH_MODE, device_target="CPU")

class Mul(nn.Cell):
def __init__(self):
super(Mul, self).__init__()
self.mul = P.Mul()

def construct(self, x, y):
return self.mul(x, y)

x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))

mul = Mul()
print(mul(x, y))
```

```text
[ 4. 10. 18.]
```

使用pip方式,在不同的环境安装MindSpore,可参考以下文档。

- [Ascend环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_pip.md)
- [GPU环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_pip.md)
- [CPU环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_pip.md)

### 源码编译方式安装

使用源码编译方式,在不同的环境安装MindSpore,可参考以下文档。

- [Ascend环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_source.md)
- [GPU环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_source.md)
- [CPU环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_source.md)

### Docker镜像

MindSpore的Docker镜像托管在[Docker Hub](https://hub.docker.com/r/mindspore)上。
目前容器化构建选项支持情况如下:

| 硬件平台 | Docker镜像仓库 | 标签 | 说明 |
| :----- | :------------------------ | :----------------------- | :--------------------------------------- |
| CPU | `mindspore/mindspore-cpu` | `x.y.z` | 已经预安装MindSpore `x.y.z` CPU版本的生产环境。 |
| | | `devel` | 提供开发环境从源头构建MindSpore(`CPU`后端)。安装详情请参考<https://www.mindspore.cn/install> 。 |
| | | `runtime` | 提供运行时环境安装MindSpore二进制包(`CPU`后端)。 |
| GPU | `mindspore/mindspore-gpu` | `x.y.z` | 已经预安装MindSpore `x.y.z` GPU版本的生产环境。 |
| | | `devel` | 提供开发环境从源头构建MindSpore(`GPU CUDA10.1`后端)。安装详情请参考<https://www.mindspore.cn/install> 。 |
| | | `runtime` | 提供运行时环境安装MindSpore二进制包(`GPU CUDA10.1`后端)。 |

> **注意:** 不建议从源头构建GPU `devel` Docker镜像后直接安装whl包。我们强烈建议您在GPU `runtime` Docker镜像中传输并安装whl包。

- CPU

对于`CPU`后端,可以直接使用以下命令获取并运行最新的稳定镜像:

```bash
docker pull mindspore/mindspore-cpu:1.1.0
docker run -it mindspore/mindspore-cpu:1.1.0 /bin/bash
```

- GPU

对于`GPU`后端,请确保`nvidia-container-toolkit`已经提前安装,以下是`Ubuntu`用户安装指南:

```bash
DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list

sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
sudo systemctl restart docker
```

编辑文件 daemon.json:

```bash
$ vim /etc/docker/daemon.json
{
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
```

再次重启docker:

```bash
sudo systemctl daemon-reload
sudo systemctl restart docker
```

使用以下命令获取并运行最新的稳定镜像:

```bash
docker pull mindspore/mindspore-gpu:1.1.0
docker run -it -v /dev/shm:/dev/shm --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.1.0 /bin/bash
```

要测试Docker是否正常工作,请运行下面的Python代码并检查输出:

```python
import numpy as np
import mindspore.context as context
from mindspore import Tensor
from mindspore.ops import functional as F

context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")

x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
print(F.tensor_add(x, y))
```

```text
[[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]],

[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]],

[[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.],
[ 2. 2. 2. 2.]]]
```

如果您想了解更多关于MindSpore Docker镜像的构建过程,请查看[docker](https://gitee.com/mindspore/mindspore/blob/master/scripts/docker/README.md) repo了解详细信息。

## 快速入门

参考[快速入门](https://www.mindspore.cn/tutorials/zh-CN/master/beginner/quick_start.html)实现图片分类。

## 文档

有关安装指南、教程和API的更多详细信息,请参阅[用户文档](https://gitee.com/mindspore/docs)。

## 社区

### 治理

查看MindSpore如何进行[开放治理](https://gitee.com/mindspore/community/blob/master/governance.md)。

### 交流

- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) 开发者交流平台。
- `#mindspore`IRC频道(仅用于会议记录)
- 视频会议:待定
- 邮件列表:<https://mailweb.mindspore.cn/postorius/lists>

## 贡献

欢迎参与贡献。更多详情,请参阅我们的[贡献者Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md)。

## 分支维护策略

MindSpore的版本分支有以下几种维护阶段:

| **状态** | **持续时间** | **说明** |
|-------------|---------------|--------------------------------------------------|
| Planning | 1 - 3 months | 特性规划。 |
| Development | 3 months | 特性开发。 |
| Maintained | 6 - 12 months | 允许所有问题修复的合入,并发布版本。 |
| Unmaintained| 0 - 3 months | 允许所有问题修复的合入,无专人维护,不再发布版本。 |
| End Of Life (EOL) | N/A | 不再接受修改合入该分支。 |

## 现有分支维护状态

| **分支名** | **当前状态** | **上线时间** | **后续状态** | **EOL 日期**|
|------------|--------------|----------------------|----------------------------------------|------------|
| **r1.6** | Maintained | 2022-01-29 | Unmaintained <br> 2023-01-29 estimated | |
| **r1.5** | Maintained | 2021-10-15 | Unmaintained <br> 2022-10-15 estimated | |
| **r1.4** | Maintained | 2021-08-15 | Unmaintained <br> 2022-08-15 estimated | |
| **r1.3** | Maintained | 2021-07-15 | Unmaintained <br> 2022-07-15 estimated | |
| **r1.2** | Unmaintained | 2021-04-15 | End Of Life <br> 2022-04-15 estimated | |
| **r1.1** | End Of Life | 2020-12-31 | | 2021-09-30 |
| **r1.0** | End Of Life | 2020-09-24 | | 2021-07-30 |
| **r0.7** | End Of Life | 2020-08-31 | | 2021-02-28 |
| **r0.6** | End Of Life | 2020-07-31 | | 2020-12-30 |
| **r0.5** | End Of Life | 2020-06-30 | | 2021-06-30 |
| **r0.3** | End Of Life | 2020-05-31 | | 2020-09-30 |
| **r0.2** | End Of Life | 2020-04-30 | | 2020-08-31 |
| **r0.1** | End Of Life | 2020-03-28 | | 2020-06-30 |

## 版本说明

版本说明请参阅[RELEASE](https://gitee.com/mindspore/mindspore/blob/master/RELEASE.md)。

## 许可证

[Apache License 2.0](https://gitee.com/mindspore/mindspore#/mindspore/mindspore/blob/master/LICENSE)

+ 63
- 3289
RELEASE.md
File diff suppressed because it is too large
View File


+ 2
- 15
SECURITY.md View File

@@ -1,27 +1,14 @@
# Security for MindSpore training

## Security Risk Description
# Security Risk Description


1. When MindSpore is used for AI model training, if the user-defined computational graph structure (for example, Python code for generating the MindSpore computational graph) is provided by an untrusted third party, malicious code may exist and will be loaded and executed to attack the system. 1. When MindSpore is used for AI model training, if the user-defined computational graph structure (for example, Python code for generating the MindSpore computational graph) is provided by an untrusted third party, malicious code may exist and will be loaded and executed to attack the system.
2. Model files are stored in binary mode. When MindSpore is used to optimize or infer AI models and the model files are loaded in deserialization mode, once malicious code is written into the model files, the code are loaded and executed, causing attacks on the system. 2. Model files are stored in binary mode. When MindSpore is used to optimize or infer AI models and the model files are loaded in deserialization mode, once malicious code is written into the model files, the code are loaded and executed, causing attacks on the system.
3. MindSpore performs only model training and inference based on the data provided by users. Users need to protect data security to avoid privacy leakage. 3. MindSpore performs only model training and inference based on the data provided by users. Users need to protect data security to avoid privacy leakage.
4. MindSpore is a distributed training platform. When MindSpore is used for distributed training, if an Ascend chip is used for training, a device provides a secure transmission protocol for gradient fusion. If GPUs or other clusters are used for training, identity authentication and secure transmission are not provided. 4. MindSpore is a distributed training platform. When MindSpore is used for distributed training, if an Ascend chip is used for training, a device provides a secure transmission protocol for gradient fusion. If GPUs or other clusters are used for training, identity authentication and secure transmission are not provided.


## Security Usage Suggestions
# Security Usage Suggestions


1. Run MindSpore in the sandbox. 1. Run MindSpore in the sandbox.
2. Run MindSpore as a non-root user. 2. Run MindSpore as a non-root user.
3. Ensure that the source of a computational graph structure is trustworthy. Do not write code irrelevant to model training in the network structure definition. 3. Ensure that the source of a computational graph structure is trustworthy. Do not write code irrelevant to model training in the network structure definition.
4. Ensure that the source of a network model is trustworthy or enter secure network model parameters to prevent model parameters from being tampered with. 4. Ensure that the source of a network model is trustworthy or enter secure network model parameters to prevent model parameters from being tampered with.
5. Ensure that GPU distributed training is performed on an isolated cluster network. 5. Ensure that GPU distributed training is performed on an isolated cluster network.

# Security for MindSpore Lite

## Security Risk Description

When run a model using MindSpore Lite, the value from the model will be read and used as the parameter or input of a operator, if the value read from the model is invalid, it may cause unexpected result. For example, if the invalid value is used as the offset of a vector, it may cause your app run into segmentation fault issue.

## Security Usage Suggestions

1. Make sure your model is well verified and protected.
2. The exception catching mechanism of C++ is an effective method to improve robustness of your app, consider adding code to catch exception when calling the MindSpore Lite API, as exception will be raised in some case such as the example mentioned in the risk description above.

+ 303
- 6500
Third_Party_Open_Source_Software_Notice
File diff suppressed because it is too large
View File


+ 0
- 1
akg

@@ -1 +0,0 @@
Subproject commit 0ddab6d9cad4c4c9faf72585e5a52faf79f55e4d

+ 19
- 0
autogen.sh View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Copyright 2019 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.
# ============================================================================

git submodule update --init --recursive



+ 0
- 84
build.bat View File

@@ -1,84 +0,0 @@
@rem Copyright 2020 Huawei Technologies Co., Ltd
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem ============================================================================
@echo off
@title mindspore_build

SET BASE_PATH=%CD%
SET BUILD_PATH=%BASE_PATH%/build

SET threads=8
SET ENABLE_GITEE=OFF

set VERSION_STR=''
for /f "tokens=1" %%a in (version.txt) do (set VERSION_STR=%%a)

ECHO %2%|FINDSTR "^[0-9][0-9]*$"
IF %errorlevel% == 0 (
SET threads=%2%
)

IF "%FROM_GITEE%" == "1" (
echo "DownLoad from gitee"
SET ENABLE_GITEE=ON
)

IF NOT EXIST "%BUILD_PATH%" (
md "build"
)
cd %BUILD_PATH%
IF NOT EXIST "%BUILD_PATH%/mindspore" (
md "mindspore"
)

cd %BUILD_PATH%/mindspore
IF "%1%" == "lite" (
echo "======Start building MindSpore Lite %VERSION_STR%======"
rd /s /q "%BASE_PATH%\output"
(git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id
IF defined VisualStudioVersion (
cmake -DMSLITE_MINDDATA_IMPLEMENT=off -DMSLITE_ENABLE_TRAIN=off -DVERSION_STR=%VERSION_STR% ^
-DCMAKE_BUILD_TYPE=Release -G "Ninja" "%BASE_PATH%/mindspore/lite"
) ELSE (
cmake -DMSLITE_MINDDATA_IMPLEMENT=off -DMSLITE_ENABLE_TRAIN=off -DVERSION_STR=%VERSION_STR% ^
-DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
)
) ELSE (
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
-G "CodeBlocks - MinGW Makefiles" ../..
)
IF NOT %errorlevel% == 0 (
echo "cmake fail."
call :clean
EXIT /b 1
)

cmake --build . --target package -- -j%threads%
IF NOT %errorlevel% == 0 (
echo "build fail."
call :clean
EXIT /b 1
)

call :clean
EXIT /b 0

:clean
IF EXIST "%BASE_PATH%/output" (
cd %BASE_PATH%/output
if EXIST "%BASE_PATH%/output/_CPack_Packages" (
rd /s /q _CPack_Packages
)
)
cd %BASE_PATH%

+ 421
- 55
build.sh View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Copyright 2019-2021 Huawei Technologies Co., Ltd
# Copyright 2019 Huawei Technologies Co., Ltd
# #
# Licensed under the Apache License, Version 2.0 (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 not use this file except in compliance with the License.
@@ -14,20 +14,48 @@
# limitations under the License. # limitations under the License.
# ============================================================================ # ============================================================================


# MindSpore build script
set -e set -e
BASEPATH=$(cd "$(dirname $0)"; pwd) BASEPATH=$(cd "$(dirname $0)"; pwd)
export CUDA_PATH=""
PROJECT_PATH="${BASEPATH}"
CUDA_PATH=""
CUDNN_PATH=""
export BUILD_PATH="${BASEPATH}/build/" export BUILD_PATH="${BASEPATH}/build/"

source ./scripts/build/usage.sh
source ./scripts/build/default_options.sh
source ./scripts/build/option_proc_debug.sh
source ./scripts/build/option_proc_mindspore.sh
source ./scripts/build/option_proc_lite.sh
source ./scripts/build/process_options.sh
source ./scripts/build/parse_device.sh
source ./scripts/build/build_mindspore.sh
# print usage message
usage()
{
echo "Usage:"
echo "bash build.sh [-d] [-r] [-v] [-c on|off] [-t on|off] [-g on|off] [-h] [-s] [-b ge|cpu] [-m infer|train] \\"
echo " [-a on|off] [-g on|off] [-p on|off] [-i] [-L] [-R] [-D on|off] [-j[n]] [-e gpu|d|cpu] \\"
echo " [-P on|off] [-z] [-M on|off] [-V 9.2|10.1] [-I] [-K]"
echo ""
echo "Options:"
echo " -d Debug mode"
echo " -r Release mode, default mode"
echo " -v Display build command"
echo " -c Enable code coverage switch, default off"
echo " -t Run testcases switch, default on"
echo " -g Use glog to output log, default on"
echo " -h Print usage"
echo " -s Install or setup"
echo " -b Select other backend, available: \\"
echo " ge:graph engine, cpu"
echo " -m Select mode, available: infer, train, default is infer "
echo " -a Enable ASAN, default off"
echo " -p Enable pipeline profile, default off"
echo " -i Enable increment building, default off"
echo " -L Enable load ANF-IR as input of 'infer', default off"
echo " -R Enable the time_line record, default off"
echo " -j[n] Set the threads when building (Default: -j8)"
echo " -e Use gpu, d or cpu"
echo " -P Enable dump anf graph to file in ProtoBuffer format, default on"
echo " -Q Enable dump end to end, default off"
echo " -D Enable dumping of function graph ir, default on"
echo " -z Compile dataset & mindrecord, default off"
echo " -M Enable MPI and NCCL for GPU training, default off"
echo " -V Specify the minimum required cuda version, default CUDA 9.2"
echo " -I Compile predict, default off"
echo " -K Compile with AKG, default off"
}


# check value of input is 'on' or 'off' # check value of input is 'on' or 'off'
# usage: check_on_off arg_value arg_name # usage: check_on_off arg_value arg_name
@@ -40,23 +68,183 @@ check_on_off()
fi fi
} }


# check value of input is 'on' or 'off' or 'debug'
update_submodule()
# check and set options
checkopts()
{ {
git submodule update --init graphengine
cd "${BASEPATH}/graphengine"
git submodule update --init metadef
cd "${BASEPATH}"
if [[ "X$ENABLE_AKG" = "Xon" ]]; then
if [[ "X$ENABLE_D" == "Xon" ]]; then
git submodule update --init akg
else
GIT_LFS_SKIP_SMUDGE=1 git submodule update --init akg
fi
fi
# Init default values of build options
THREAD_NUM=8
DEBUG_MODE="off"
VERBOSE=""
ENABLE_COVERAGE="off"
RUN_TESTCASES="off"
EXECUTE_SETUP="off"
ENABLE_BACKEND=""
TRAIN_MODE="INFER"
ENABLE_ASAN="off"
ENABLE_PROFILE="off"
INC_BUILD="off"
ENABLE_LOAD_IR="off"
ENABLE_TIMELINE="off"
ENABLE_DUMP2PROTO="on"
ENABLE_DUMPE2E="off"
ENABLE_DUMP_IR="on"
COMPILE_MINDDATA="off"
ENABLE_MPI="off"
CUDA_VERSION="9.2"
COMPILE_PREDICT="off"
USE_GLOG="on"
PREDICT_PLATFORM=""
ENABLE_AKG="off"

# Process the options
while getopts 'drvj:c:t:hsb:a:g:p:ie:m:I:LRP:Q:D:zM:V:K' opt
do
OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
case "${opt}" in
d)
DEBUG_MODE="on"
;;
r)
DEBUG_MODE="off"
;;
v)
VERBOSE="VERBOSE=1"
;;
j)
THREAD_NUM=$OPTARG
;;
c)
check_on_off $OPTARG c
ENABLE_COVERAGE="$OPTARG"
;;
t)
check_on_off $OPTARG t
RUN_TESTCASES="$OPTARG"
;;
g)
check_on_off $OPTARG g
USE_GLOG="$OPTARG"
;;
h)
usage
exit 0
;;
s)
EXECUTE_SETUP="on"
;;
b)
if [[ "X$OPTARG" != "Xge" && "X$OPTARG" != "Xcpu" ]]; then
echo "Invalid value ${OPTARG} for option -b"
usage
exit 1
fi
ENABLE_BACKEND=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]')
if [[ "X$ENABLE_BACKEND" == "XGE" ]]; then
ENABLE_GE="on"
fi
if [[ "X$ENABLE_BACKEND" != "XCPU" ]]; then
ENABLE_CPU="on"
fi
;;
a)
check_on_off $OPTARG a
ENABLE_ASAN="$OPTARG"
;;
p)
check_on_off $OPTARG p
ENABLE_PROFILE="$OPTARG"
;;
i)
INC_BUILD="on"
;;
m)
if [[ "X$OPTARG" != "Xinfer" && "X$OPTARG" != "Xtrain" ]]; then
echo "Invalid value ${OPTARG} for option -m"
usage
exit 1
fi
TRAIN_MODE=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]')
;;
L)
ENABLE_LOAD_IR="on"
echo "build with enable load anf ir"
;;
R)
ENABLE_TIMELINE="on"
echo "enable time_line record"
;;
e)
if [[ "X$OPTARG" == "Xgpu" ]]; then
ENABLE_GPU="on"
ENABLE_CPU="on"
elif [[ "X$OPTARG" == "Xd" ]]; then
ENABLE_D="on"
ENABLE_CPU="on"
elif [[ "X$OPTARG" == "Xcpu" ]]; then
ENABLE_CPU="on"
else
echo "Invalid value ${OPTARG} for option -e"
usage
exit 1
fi
;;
M)
check_on_off $OPTARG M
ENABLE_MPI="$OPTARG"
;;
V)
if [[ "X$OPTARG" != "X9.2" && "X$OPTARG" != "X10.1" ]]; then
echo "Invalid value ${OPTARG} for option -V"
usage
exit 1
fi
CUDA_VERSION="$OPTARG"
;;
P)
check_on_off $OPTARG p
ENABLE_DUMP2PROTO="$OPTARG"
echo "enable dump anf graph to proto file"
;;
Q)
check_on_off $OPTARG Q
ENABLE_DUMPE2E="$OPTARG"
echo "enable dump end to end"
;;
D)
check_on_off $OPTARG D
ENABLE_DUMP_IR="$OPTARG"
echo "enable dump function graph ir"
;;
z)
COMPILE_MINDDATA="on"
;;
I)
COMPILE_PREDICT="on"
if [[ "$OPTARG" == "arm64" ]]; then
PREDICT_PLATFORM="arm64"
elif [[ "$OPTARG" == "x86_64" ]]; then
PREDICT_PLATFORM="x86_64"
else
echo "-I parameter must be arm64 or x86_64"
exit 1
fi
;;
K)
ENABLE_AKG="on"
echo "enable compile with akg"
;;
*)
echo "Unknown option ${opt}!"
usage
exit 1
esac
done
} }
checkopts "$@"
echo "---------------- mindspore: build start ----------------"
mkdir -pv "${BUILD_PATH}/package/mindspore/lib"
git submodule update --init graphengine


# check value of input is 'on' or 'off'
build_exit() build_exit()
{ {
echo "$@" >&2 echo "$@" >&2
@@ -64,39 +252,217 @@ build_exit()
exit 1 exit 1
} }


make_clean()
# Create building path
build_mindspore()
{ {
echo "enable make clean"
cd "${BUILD_PATH}/mindspore"
cmake --build . --target clean
echo "start build mindspore project."
mkdir -pv "${BUILD_PATH}/mindspore"
cd "${BUILD_PATH}/mindspore"
CMAKE_ARGS="-DDEBUG_MODE=$DEBUG_MODE -DBUILD_PATH=$BUILD_PATH"
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_LOAD_ANF_IR=$ENABLE_LOAD_IR"
if [[ "X$ENABLE_COVERAGE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_COVERAGE=ON"
fi
if [[ "X$RUN_TESTCASES" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TESTCASES=ON"
fi
if [[ -n "$ENABLE_BACKEND" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${ENABLE_BACKEND}=ON"
fi
if [[ -n "$TRAIN_MODE" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${TRAIN_MODE}=ON"
fi
if [[ "X$ENABLE_ASAN" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ASAN=ON"
fi
if [[ "X$ENABLE_PROFILE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PROFILE=ON"
fi
if [[ "X$ENABLE_TIMELINE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TIMELINE=ON"
fi
if [[ "X$ENABLE_DUMP2PROTO" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_PROTO=ON"
fi
if [[ "X$ENABLE_DUMPE2E" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_E2E=ON"
fi
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_IR=${ENABLE_DUMP_IR^^}"
if [[ "X$ENABLE_MPI" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MPI=ON"
fi
if [[ "X$ENABLE_D" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_D=ON"
fi
if [[ "X$ENABLE_GPU" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GPU=ON -DCUDA_PATH=$CUDA_PATH -DCUDNN_PATH=$CUDNN_PATH -DMS_REQUIRE_CUDA_VERSION=${CUDA_VERSION}"
fi
if [[ "X$ENABLE_CPU" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPU=ON"
fi
if [[ "X$COMPILE_MINDDATA" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MINDDATA=ON"
fi
if [[ "X$USE_GLOG" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DUSE_GLOG=ON"
fi
if [[ "X$ENABLE_AKG" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_AKG=ON"
fi
echo "${CMAKE_ARGS}"
if [[ "X$INC_BUILD" = "Xoff" ]]; then
cmake ${CMAKE_ARGS} ../..
fi
make ${VERBOSE} -j$THREAD_NUM
if [[ "X$EXECUTE_SETUP" = "Xon" ]]; then
make install
fi
echo "success to build mindspore project!"
} }


echo "---------------- MindSpore: build start ----------------"
init_default_options
process_options "$@"
parse_device

if [[ "X$COMPILE_LITE" = "Xon" ]]; then
export COMPILE_MINDDATA_LITE
export ENABLE_VERBOSE
export LITE_PLATFORM
export LITE_ENABLE_AAR
source mindspore/lite/build_lite.sh
else
mkdir -pv "${BUILD_PATH}/package/mindspore/lib"
update_submodule
build_predict()
{
git submodule update --init --recursive third_party/incubator-tvm
echo "start build predict project"


build_mindspore
git submodule update --init --recursive third_party/flatbuffers
git submodule update --init --recursive third_party/googletest
git submodule update --init --recursive third_party/protobuf


if [[ "X$ENABLE_MAKE_CLEAN" = "Xon" ]]; then
make_clean
fi
if [[ "X$ENABLE_ACL" == "Xon" ]] && [[ "X$ENABLE_D" == "Xoff" ]]; then
echo "acl mode, skipping deploy phase"
rm -rf ${BASEPATH}/output/_CPack_Packages/
rm -rf "${BASEPATH}/predict/build"
mkdir -pv "${BASEPATH}/predict/build"
rm -rf "${BASEPATH}/predict/output"
mkdir -pv "${BASEPATH}/predict/output"

if [[ "$PREDICT_PLATFORM" == "arm64" ]]; then
if [ "${ANDROID_NDK}" ]; then
echo -e "\e[31mANDROID_NDK_PATH=$ANDROID_NDK \e[0m"
else
echo -e "\e[31mplease set ANDROID_NDK_PATH in environment variable for example: export ANDROID_NDK=/root/usr/android-ndk-r16b/ \e[0m"
exit 1
fi
fi

#build flatbuf
cd "${BASEPATH}/third_party/flatbuffers"
rm -rf build && mkdir -p build && cd build && cmake .. && make -j$THREAD_NUM
FLATC="${BASEPATH}"/third_party/flatbuffers/build/flatc
cd "${BASEPATH}"/predict/schema && mkdir -p "${BASEPATH}"/predict/schema/inner
find . -name "*.fbs" -print0 | xargs -0 "${FLATC}" -c -b
find . -name "*.fbs" -print0 | xargs -0 "${FLATC}" -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o ${BASEPATH}/predict/schema/inner

# check LLVM_PATH
if [ "${LLVM_PATH}" == "" ]; then
echo "Please set LLVM_PATH in env for example export LLVM_PATH=/xxxx/bin/llvm-config"
exit
fi

#build tvm
tvm_open_source="${BASEPATH}/third_party/incubator-tvm"
tvm_kernel_build="${BASEPATH}/predict/module/tvm_kernel"
if [ ! -f "${tvm_kernel_build}"/incubator-tvm/build/libtvm.so ]; then
rm -fr "${tvm_kernel_build}"/incubator-tvm
cp -fr "${tvm_open_source}" "${tvm_kernel_build}"
mkdir -p "${tvm_kernel_build}"/incubator-tvm/build
patch -d "${tvm_kernel_build}"/incubator-tvm -p1 < "${BASEPATH}"/third_party/patch/predict/0001-RetBugFix-CustomRuntime_v06.patch
cp "${tvm_kernel_build}"/lite/src/codegen/llvm/lite_rtfunc_reset.cc "${tvm_kernel_build}"/incubator-tvm/src/codegen/llvm/
cp "${tvm_open_source}"/cmake/config.cmake "${tvm_kernel_build}"/incubator-tvm
if [ "${LLVM_PATH}" ]; then
sed -i "s#set(USE_LLVM .*)#set(USE_LLVM \"${LLVM_PATH}\")#g" "${tvm_kernel_build}"/incubator-tvm/config.cmake
else
echo "need set LLVM_PATH in env for example export LLVM_PATH=/xxxx/bin/llvm-config"
fi
cd "${tvm_kernel_build}"/incubator-tvm/build
cmake ..
make -j$THREAD_NUM
else else
cp -rf ${BUILD_PATH}/package/mindspore/lib ${BASEPATH}/mindspore/python/mindspore
cp -rf ${BUILD_PATH}/package/mindspore/*.so ${BASEPATH}/mindspore/python/mindspore
fi
cd "${tvm_kernel_build}"/incubator-tvm/build
make -j$THREAD_NUM
fi

#gen op
predict_tvm_op_lib_path="${BASEPATH}/predict/module/tvm_kernel/build/lib_x86"
predict_platform="x86"
if [[ "$PREDICT_PLATFORM" == "arm64" ]]; then
predict_tvm_op_lib_path="${BASEPATH}/predict/module/tvm_kernel/build/lib_arm64"
predict_platform="arm64"
fi

need_get_libs=true
if [ -d "${predict_tvm_op_lib_path}" ]; then
file_list=$(ls "${predict_tvm_op_lib_path}")
if [ -n "${file_list}" ]; then
libstime=$(stat -c %Y "${predict_tvm_op_lib_path}"/* | sort -u | tail -n1)
pythontime=$(find "${BASEPATH}"/predict/module/tvm_kernel/lite/python/ -name "*.py" -exec stat -c %Y {} \; |
sort -u | tail -n1)
if [ "${libstime}" -ge "${pythontime}" ]; then
need_get_libs=false
else
rm -fr "${predict_tvm_op_lib_path}"
fi
fi
fi

if $need_get_libs; then
PYTHONPATH_OLD=${PYTHONPATH}
export PYTHONPATH="${tvm_kernel_build}/incubator-tvm/python:${tvm_kernel_build}/incubator-tvm/topi/python:${tvm_kernel_build}/incubator-tvm/nnvm/python:${tvm_kernel_build}/lite/python:"
cd "${BASEPATH}"/predict/module/tvm_kernel/lite/python/at_ops
python3 at_gen_strip.py ${predict_platform}
export PYTHONPATH=${PYTHONPATH_OLD}
fi

cd "${BASEPATH}/predict/build"
if [[ "$PREDICT_PLATFORM" == "arm64" ]]; then
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
-DANDROID_NATIVE_API_LEVEL=android-19 -DANDROID_NDK="${ANDROID_NDK}" \
-DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" -DANDROID_STL="c++_shared" \
-DANDROID_ABI="arm64-v8a" -DENABLE_PREDICT_ARM64=ON -DANDROID_ALLOW_UNDEFINED_SYMBOLS=TRUE ..
elif [[ "$PREDICT_PLATFORM" == "x86_64" ]]; then
cmake ..
fi

make ${VERBOSE} -j$THREAD_NUM
if [[ "$PREDICT_PLATFORM" == "x86_64" ]]; then
cd "${BASEPATH}/predict/build/test" && ./run_tests.sh
fi

# copy securec include files
mkdir -p "${BASEPATH}/predict/output/include/securec/include"
cp "${BASEPATH}"/third_party/securec/include/* "${BASEPATH}"/predict/output/include/securec/include

cd "${BASEPATH}/predict/output/"
if [[ "$PREDICT_PLATFORM" == "x86_64" ]]; then
tar -cf MSPredict-0.1.0-linux_x86_64.tar.gz include/ lib/ --warning=no-file-changed
elif [[ "$PREDICT_PLATFORM" == "arm64" ]]; then
tar -cf MSPredict-0.1.0-linux_aarch64.tar.gz include/ lib/ --warning=no-file-changed
fi
echo "success to build predict project!"
}

if [[ "X$COMPILE_PREDICT" = "Xon" ]]; then
build_predict
echo "---------------- mindspore: build end ----------------"
exit
else
build_mindspore
fi

if [[ "X$INC_BUILD" = "Xoff" ]]; then
if [[ "X$ENABLE_GE" = "Xon" ]]; then
bash "${PROJECT_PATH}/package.sh" ge
elif [[ "X$ENABLE_GPU" = "Xon" ]]; then
bash "${PROJECT_PATH}/package.sh" ms gpu
elif [[ "X$ENABLE_D" = "Xon" ]] || [[ "X$ENABLE_CPU" = "Xon" ]]; then
bash "${PROJECT_PATH}/package.sh" ms
else
bash "${PROJECT_PATH}/package.sh" debug
fi
fi

cp -rf ${BUILD_PATH}/package/mindspore/lib ${BUILD_PATH}/../mindspore
cp -rf ${BUILD_PATH}/package/mindspore/*.so ${BUILD_PATH}/../mindspore

if [[ -d "${BUILD_PATH}/package/build" ]]; then
rm -rf "${BUILD_PATH}/package/build"
fi fi
echo "---------------- MindSpore: build end ----------------"
echo "---------------- mindspore: build end ----------------"

+ 0
- 10
cmake/OWNERS View File

@@ -1,10 +0,0 @@
approvers:
- zhoufeng54
- hangangqiang
- jpc_chenjianping
- tiancixiao
reviewers:
- nicholas_yhr
- liubuyu
- chengxb7532
- shenwei41

+ 0
- 54
cmake/change_rpath.cmake View File

@@ -1,54 +0,0 @@
function(changerpath target_so target_name link_sos)
set(depend_so "")
foreach(link_so ${link_sos})
set(some-file "${CMAKE_SOURCE_DIR}/build/${target_name}_${link_so}.txt")
set(some-file1 "${CMAKE_SOURCE_DIR}/build/${target_name}_${link_so}1.txt")
set(some-file2 "${CMAKE_SOURCE_DIR}/build/${target_name}_${link_so}2.txt")
add_custom_command(
OUTPUT
${some-file}
COMMAND
otool -L ${target_so} | tail -n +2 | grep ${link_so} | head -n1 > ${some-file}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build"
VERBATIM
)
add_custom_command(
OUTPUT
${some-file1}
COMMAND
cat ${some-file} | cut -d " " -f 1 | sed -E "s/^.//g" > ${some-file1}
DEPENDS
${some-file}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build"
VERBATIM
)
add_custom_command(
OUTPUT
${some-file2}
COMMAND
awk -F "/" "{print $NF}" ${some-file1} > ${some-file2}
DEPENDS
${some-file1}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build"
VERBATIM
)
add_custom_target(
link_${target_name}_${link_so} ALL
COMMAND install_name_tool -change `cat ${some-file1}` @rpath/`cat ${some-file2}` ${target_so}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build"
DEPENDS ${target_so} ${some-file1} ${some-file2}
COMMENT "install tool name"
)
add_custom_command(
TARGET link_${target_name}_${link_so}
POST_BUILD
COMMAND rm ${some-file} ${some-file1} ${some-file2}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/build"
VERBATIM
)
if(depend_so)
add_dependencies(link_${target_name}_${link_so} link_${target_name}_${depend_so})
endif()
set(depend_so ${link_so})
endforeach()
endfunction()

+ 0
- 141
cmake/check_requirements.cmake View File

@@ -1,141 +0,0 @@
## define customized find functions, print customized error messages
function(find_required_package pkg_name)
find_package(${pkg_name})
if(NOT ${pkg_name}_FOUND)
message(FATAL_ERROR "Required package ${pkg_name} not found, "
"please install the package and try building MindSpore again.")
endif()
endfunction()

function(find_required_program prog_name)
find_program(${prog_name}_EXE ${prog_name})
if(NOT ${prog_name}_EXE)
message(FATAL_ERROR "Required program ${prog_name} not found, "
"please install the package and try building MindSpore again.")
endif()
endfunction()


## find python, quit if the found python is static
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(Python3_FIND_REGISTRY LAST)
set(Python3_FIND_STRATEGY LOCATION)
endif()
set(Python3_USE_STATIC_LIBS FALSE)
set(Python3_FIND_VIRTUALENV ONLY)
find_package(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND)
message("Python3 found, version: ${Python3_VERSION}")
message("Python3 library path: ${Python3_LIBRARY}")
message("Python3 interpreter: ${Python3_EXECUTABLE}")
elseif(Python3_LIBRARY AND Python3_EXECUTABLE AND
${Python3_VERSION} VERSION_GREATER_EQUAL "3.7.0" AND ${Python3_VERSION} VERSION_LESS "3.9.9")
message(WARNING "Maybe python3 environment is broken.")
message("Python3 library path: ${Python3_LIBRARY}")
message("Python3 interpreter: ${Python3_EXECUTABLE}")
else()
message(FATAL_ERROR "Python3 not found, please install Python>=3.7.5, and set --enable-shared "
"if you are building Python locally")
endif()

## packages used both on windows and linux
if(DEFINED ENV{MS_PATCH_PATH})
find_program(Patch_EXECUTABLE patch PATHS $ENV{MS_PATCH_PATH})
set(Patch_FOUND ${Patch_EXECUTABLE})
else()
find_package(Patch)
endif()
if(NOT Patch_FOUND)
message(FATAL_ERROR "Patch not found, "
"please set environment variable MS_PATCH_PATH to path where Patch is located, "
"usually found in GIT_PATH/usr/bin on Windows")
endif()
message(PATCH_EXECUTABLE = ${Patch_EXECUTABLE})

find_required_package(Threads)

# add openmp if the onednn use ms threadpool
if(USE_MS_THREADPOOL_FOR_DNNL)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
else()
message(WARNING "OpenMP not found")
endif()
endif()

## packages used on Linux
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
if(ENABLE_MINDDATA)
find_required_program(tclsh)
endif()

## packages used in GPU mode only
if(ENABLE_GPU)
find_library(gmp_LIB gmp)
find_library(gmpxx_LIB gmpxx)
find_file(gmp_HEADER gmp.h)
if(NOT gmp_LIB OR NOT gmpxx_LIB OR NOT gmp_HEADER)
message(FATAL_ERROR "Required package gmp not found, please install gmp and try building MindSpore again.")
endif()
find_required_program(automake)
find_required_program(autoconf)
find_required_program(libtoolize)
find_required_package(FLEX)
endif()
endif()

# for macos, find appropriate macosx SDK then set SDKROOT and MACOSX_DEPLOYMENT_TARGET
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(NOT DEFINED ENV{SDKROOT})
# arm64: macosx11.x
# x86_64: macosx10.x, macosx11.x
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm64")
set(MACOSX_SDK_REGEX "MacOSX11(\\.\\d+)?")
else()
set(MACOSX_SDK_REGEX "MacOSX1[01](\\.\\d+)?")
endif()
set(MACOSX_XCODE_SDK_PATH "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs")
set(MACOSX_CLT_SDK_PATH "/Library/Developer/CommandLineTools/SDKs")
set(MACOSX_SDK_SEARCH_PATHS "${MACOSX_XCODE_SDK_PATH}/*" "${MACOSX_CLT_SDK_PATH}/*")
file(GLOB ALL_SDK_NAME ${MACOSX_SDK_SEARCH_PATHS})
# get highest SDK version meets the requirements
execute_process(
COMMAND bash -c "echo '${ALL_SDK_NAME}' | grep -Eo '${MACOSX_SDK_REGEX}' | sort -n | tail -1 | tr -d '\\n'"
OUTPUT_VARIABLE MACOSX_FIND_SDK_NAME
)
if(NOT MACOSX_FIND_SDK_NAME)
message(FATAL_ERROR
"can not find appropriate macosx SDK, find in ${ALL_SDK_NAME}, you may set SDKROOT manually"
)
endif()
if(IS_DIRECTORY "${MACOSX_XCODE_SDK_PATH}/${MACOSX_FIND_SDK_NAME}.sdk")
set(ENV{SDKROOT} "${MACOSX_XCODE_SDK_PATH}/${MACOSX_FIND_SDK_NAME}.sdk")
else()
set(ENV{SDKROOT} "${MACOSX_CLT_SDK_PATH}/${MACOSX_FIND_SDK_NAME}.sdk")
endif()
endif()
message("macosx sdkroot: $ENV{SDKROOT}")
# set macosx deployment target based on SDK
if(NOT DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
execute_process(
COMMAND bash -c "cat $ENV{SDKROOT}/SDKSettings.json | \
grep -Eo 'MACOSX_DEPLOYMENT_TARGET\\\":\\\"\\d{2}\\.\\d+' | cut -d '\"' -f 3 | tr -d '\\n'"
OUTPUT_VARIABLE MACOSX_FIND_SDK_VERSION
)
if(NOT MACOSX_FIND_SDK_VERSION)
message(FATAL_ERROR "can not find MACOSX_DEPLOYMENT_TARGET in SDKROOT, \
please check whether it's a valid SDK path")
endif()

if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
elseif(${MACOSX_FIND_SDK_VERSION} VERSION_LESS "10.15")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${MACOSX_FIND_SDK_VERSION} CACHE STRING
"minimum macosx deployment target version" FORCE)
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
endif()
endif()
message("macosx deployment target version: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()

+ 64
- 42
cmake/dependency_graphengine.cmake View File

@@ -1,48 +1,70 @@
message(STATUS "Compiling GraphEngine")
if(NOT(BUILD_LITE))
set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/graphengine)
else()
set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../graphengine)
endif()

message(STATUS "[ME] build_path: ${BUILD_PATH}")

function(find_submodule_lib module name path)
find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path}
PATH_SUFFIXES lib
)
if("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND")
message(FATAL_ERROR "${name} not found in any of following paths: ${path}")
endif()
add_library(${module} SHARED IMPORTED)
set_target_properties(${module} PROPERTIES
IMPORTED_LOCATION ${${module}_LIBRARY_DIR}
)
endfunction()
message(STATUS "ENABLE_GE set to FALSE, compiling GraphEngine")
set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/graphengine)


function(ge_protobuf_generate c_var h_var)
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto/ge/proto ${c_var} ${h_var} ${ARGN})
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
endfunction()
message(STATUS "ge dir: ${GE_SOURCE_DIR}")
# download json headers, rather than whole repository
include(${GE_SOURCE_DIR}/cmake/ge_utils.cmake)
include(${GE_SOURCE_DIR}/cmake/external_libs/json.cmake)
include(${GE_SOURCE_DIR}/cmake/external_libs/eigen.cmake)
include(${GE_SOURCE_DIR}/cmake/external_libs/gtest.cmake)
include(${GE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake)
include(${GE_SOURCE_DIR}/cmake/external_libs/onnx.cmake)


if(ENABLE_TESTCASES OR MODE_ASCEND_ALL OR MODE_ASCEND_ACL)
if(NOT(BUILD_LITE))
file(GLOB_RECURSE GE_PROTO_FILE RELATIVE ${CMAKE_SOURCE_DIR} "graphengine/metadef/proto/*.proto")
# for CPU/GPU mode, find c_sec and slog from local prebuild
if (NOT ENABLE_D)
set(GE_PREBUILD_PATH ${GE_SOURCE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR})
find_library(c_sec libc_sec.so ${GE_PREBUILD_PATH})
find_library(slog libslog.so ${GE_PREBUILD_PATH})
elseif (DEFINED ENV{D_LINK_PATH})
set(GE_LIB_PATH $ENV{D_LINK_PATH})
set(GE_SYS_ARCH "")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
# x86 ubuntu
set(GE_SYS_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
# arm euleros
set(GE_SYS_ARCH "aarch64")
else() else()
file(GLOB_RECURSE GE_PROTO_FILE ${TOP_DIR}/graphengine/metadef/proto/*.proto)
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated")
endif() endif()
set(TMP_FILE_NAME_LIST)
foreach(file ${GE_PROTO_FILE})
get_filename_component(file_name ${file} NAME_WE)
list(FIND TMP_FILE_NAME_LIST ${file_name} OUT_VAR)
if(NOT ${OUT_VAR} EQUAL "-1")
list(REMOVE_ITEM GE_PROTO_FILE ${file})
endif()
list(APPEND TMP_FILE_NAME_LIST ${file_name})
endforeach()
ge_protobuf_generate(GE_PROTO_SRCS GE_PROTO_HDRS ${GE_PROTO_FILE})
add_library(graph SHARED ${GE_PROTO_SRCS})
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH})
find_library(c_sec libc_sec.so ${GE_LIB_PATH})
find_library(slog libslog.so ${GE_LIB_PATH})
find_library(mmpa libmmpa.so ${GE_LIB_PATH})
find_library(runtime libruntime.so ${GE_LIB_PATH})
find_library(msprof libmsprof.so ${GE_LIB_PATH})
find_library(register libregister.so ${GE_LIB_PATH})
find_library(hccl libhccl.so ${GE_LIB_PATH})
find_library(cce libcce.so ${GE_LIB_PATH})
find_library(resource libresource.so ${GE_LIB_PATH})
else() else()
message(FATAL_ERROR "No compile option defined for GraphEngine, exiting")
set(HIAI_INSTALLED_DIR /usr/local/HiAI)
set(HIAI_DRIVER_DIR ${HIAI_INSTALLED_DIR}/driver/lib64)
set(HIAI_RUNTIME_DIR ${HIAI_INSTALLED_DIR}/runtime/lib64)
find_library(c_sec libc_sec.so ${HIAI_DRIVER_DIR})
find_library(slog libslog.so ${HIAI_DRIVER_DIR})
find_library(mmpa libmmpa.so ${HIAI_DRIVER_DIR})

find_library(cce libcce.so ${HIAI_RUNTIME_DIR})
find_library(hccl libhccl.so ${HIAI_RUNTIME_DIR})
find_library(runtime libruntime.so ${HIAI_RUNTIME_DIR})
find_library(msprof libmsprof.so ${HIAI_RUNTIME_DIR})
find_library(register libregister.so ${HIAI_RUNTIME_DIR})
find_library(resource libresource.so ${HIAI_RUNTIME_DIR})
endif() endif()

# compile libraries from following directories
# this cmake file is called only when NOT ENABLE_GE is set
set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# force __FILE__ to show relative path of file, from source directory
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"' -Wno-builtin-macro-redefined")
add_subdirectory(${GE_SOURCE_DIR}/src/common/graph)
if(ENABLE_D)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/common)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime)
endif()

set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS})

+ 2
- 3
cmake/dependency_gtest.cmake View File

@@ -4,7 +4,7 @@
# GTest_LIBRARY # GTest_LIBRARY
# #


if(NOT TARGET gtest)
if (NOT TARGET gtest)
set(BUILD_TESTING OFF CACHE BOOL "Disable glog test") set(BUILD_TESTING OFF CACHE BOOL "Disable glog test")


set(_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE}) set(_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
@@ -17,8 +17,7 @@ if(NOT TARGET gtest)
set(CMAKE_MACOSX_RPATH TRUE) set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_CXX_FLAGS "${SECURE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${SECURE_CXX_FLAGS}")


if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0"
AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" AND SYSTEM_TYPE MATCHES "euleros")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0" AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" AND SYSTEM_TYPE MATCHES "euleros")
# -D_GLIBCXX_USE_CXX11_ABI=0 added for the ABI incompatible for libtsdclient.so # -D_GLIBCXX_USE_CXX11_ABI=0 added for the ABI incompatible for libtsdclient.so
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()


+ 6
- 8
cmake/dependency_protobuf.cmake View File

@@ -3,7 +3,7 @@
# #
# PROTOBUF_LIBRARY - Link this to use protobuf # PROTOBUF_LIBRARY - Link this to use protobuf
# #
if(NOT TARGET protobuf::libprotobuf)
if (NOT TARGET protobuf::libprotobuf)
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf test") set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf test")
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Gen shared library") set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Gen shared library")
set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
@@ -14,7 +14,7 @@ if(NOT TARGET protobuf::libprotobuf)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/cmake ${CMAKE_BINARY_DIR}/protobuf) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/cmake ${CMAKE_BINARY_DIR}/protobuf)


set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
endif()
endif ()


include_directories(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/src) include_directories(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/src)


@@ -47,7 +47,7 @@ function(ms_protobuf_generate c_var h_var)
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/${rel_path}" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/${rel_path}"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file} COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
DEPENDS protobuf::protoc ${abs_file} DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM )
endforeach() endforeach()


set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE)
@@ -86,12 +86,10 @@ function(ms_protobuf_generate_py c_var h_var py_var)
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file} COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file} COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file} COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/"
"${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py"
COMMAND cp "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/" "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py"
COMMAND cp "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py" "${PROJECT_SOURCE_DIR}/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file} DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM )
endforeach() endforeach()


set_source_files_properties(${${c_var}} ${${h_var}} ${${py_var}} PROPERTIES GENERATED TRUE) set_source_files_properties(${${c_var}} ${${h_var}} ${${py_var}} PROPERTIES GENERATED TRUE)


+ 2
- 9
cmake/dependency_securec.cmake View File

@@ -4,18 +4,11 @@
# SECUREC_LIBRARY # SECUREC_LIBRARY
# #


if(NOT TARGET securec)
if (NOT TARGET securec)
set(_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE}) set(_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(_ms_tmp_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) set(_ms_tmp_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})


if(TARGET_OHOS_LITE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SECURE_CXX_FLAGS}")
else()
set(CMAKE_C_FLAGS "${SECURE_CXX_FLAGS}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_compile_definitions(SECUREC_ONLY_DECLARE_MEMSET)
endif()
set(CMAKE_C_FLAGS "${SECURE_CXX_FLAGS}")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/securec ${CMAKE_BINARY_DIR}/securec) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/securec ${CMAKE_BINARY_DIR}/securec)
set(CMAKE_POSITION_INDEPENDENT_CODE ${_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE}) set(CMAKE_POSITION_INDEPENDENT_CODE ${_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_C_FLAGS ${_ms_tmp_CMAKE_C_FLAGS}) set(CMAKE_C_FLAGS ${_ms_tmp_CMAKE_C_FLAGS})


+ 0
- 47
cmake/dependency_securec_arm.cmake View File

@@ -1,47 +0,0 @@
# securec arm library
#
#
# SECUREC_ARM_LIBRARY
#

if(NOT TARGET securec_arm)
set(_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(_ms_tmp_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})

if(TARGET_OHOS_LITE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SECURE_CXX_FLAGS}")
else()
set(CMAKE_C_FLAGS "${SECURE_CXX_FLAGS}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_compile_definitions(SECUREC_ONLY_DECLARE_MEMSET)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ${_ms_tmp_CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_C_FLAGS ${_ms_tmp_CMAKE_C_FLAGS})
endif()

if(NOT MSVC)
SET(CMAKE_BUILD_TYPE "Debug")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb \
-fno-inline-functions -fno-omit-frame-pointer -fstack-protector-all")
else()
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -Wno-nullability-completeness -fPIC -O0 -Wall \
-Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer \
-fstack-protector-all -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='")
endif()
SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarations -fstack-protector-all")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

#add flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror")
endif()

include_directories(${PROJECT_SOURCE_DIR}/third_party/securec/include)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
list(APPEND SECUREC_ARM_LIBRARY "memset_s.c")
else()
aux_source_directory(${PROJECT_SOURCE_DIR}/third_party/securec/src SECUREC_ARM_LIBRARY)
endif()
add_library(securec_arm STATIC ${SECUREC_ARM_LIBRARY})
set(SECUREC_ARM_LIBRARY securec_arm)

+ 3
- 4
cmake/dependency_utils.cmake View File

@@ -3,7 +3,7 @@


function(find_python_package out_inc out_lib) function(find_python_package out_inc out_lib)
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python # Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
if("${PYTHON_EXECUTABLE}" STREQUAL "")
if ("${PYTHON_EXECUTABLE}" STREQUAL "")
set(PYTHON_EXECUTABLE "python3") set(PYTHON_EXECUTABLE "python3")
else() else()
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
@@ -15,10 +15,9 @@ function(find_python_package out_inc out_lib)
OUTPUT_VARIABLE inc) OUTPUT_VARIABLE inc)
string(STRIP "${inc}" inc) string(STRIP "${inc}" inc)
set(${out_inc} ${inc} PARENT_SCOPE) set(${out_inc} ${inc} PARENT_SCOPE)
execute_process( execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import distutils.sysconfig as sysconfig; import os; \
print(os.path.join(sysconfig.get_config_var('LIBDIR'), sysconfig.get_config_var('LDLIBRARY')))"
COMMAND "${PYTHON_EXECUTABLE}" -c "import distutils.sysconfig as sysconfig; import os; print(os.path.join(sysconfig.get_config_var('LIBDIR'), sysconfig.get_config_var('LDLIBRARY')))"
RESULT_VARIABLE result RESULT_VARIABLE result
OUTPUT_VARIABLE lib) OUTPUT_VARIABLE lib)
string(STRIP "${lib}" lib) string(STRIP "${lib}" lib)


+ 0
- 39
cmake/external_libs/absl.cmake View File

@@ -1,39 +0,0 @@
if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/abseil-cpp.git")
set(GIT_TAG "openEuler-22.03-LTS")
set(MD5 "06c9554d9f9776bb1a4b848ca206c0af")
set(ABSL_SRC "${TOP_DIR}/build/mindspore/_deps/absl-src")
__download_pkg_with_git(absl ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
execute_process(COMMAND tar -xf ${ABSL_SRC}/abseil-cpp-20210324.2.tar.gz --strip-components 1 -C ${ABSL_SRC})
else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/abseil-cpp/repository/archive/20210324.2.tar.gz")
set(MD5 "e0b585398b89ee92a10d8c68ef7eed48")
else()
set(REQ_URL "https://github.com/abseil/abseil-cpp/archive/20210324.2.tar.gz")
set(MD5 "e0b585398b89ee92a10d8c68ef7eed48")
endif()
endif()

if(NOT ENABLE_GLIBCXX)
set(absl_CXXFLAGS "${absl_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()

mindspore_add_pkg(absl
VER 20210324.2
LIBS absl_strings absl_throw_delegate absl_raw_logging_internal absl_int128 absl_bad_optional_access
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE
-DCMAKE_CXX_STANDARD=11
)

include_directories(${absl_INC})

add_library(mindspore::absl_strings ALIAS absl::absl_strings)
add_library(mindspore::absl_throw_delegate ALIAS absl::absl_throw_delegate)
add_library(mindspore::absl_raw_logging_internal ALIAS absl::absl_raw_logging_internal)
add_library(mindspore::absl_int128 ALIAS absl::absl_int128)
add_library(mindspore::absl_bad_optional_access ALIAS absl::absl_bad_optional_access)

+ 0
- 22
cmake/external_libs/c-ares.cmake View File

@@ -1,22 +0,0 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/c-ares/repository/archive/cares-1_15_0.tar.gz")
set(MD5 "459876e53724a2c87ed2876312b96aed")
else()
set(REQ_URL "https://github.com/c-ares/c-ares/releases/download/cares-1_15_0/c-ares-1.15.0.tar.gz")
set(MD5 "d2391da274653f7643270623e822dff7")
endif()

mindspore_add_pkg(c-ares
VER 1.15.0
LIBS cares
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release
-DCARES_SHARED:BOOL=OFF
-DCARES_STATIC:BOOL=ON
-DCARES_STATIC_PIC:BOOL=ON
-DHAVE_LIBNSL:BOOL=OFF
PATCHES ${TOP_DIR}/third_party/patch/c-ares/CVE-2021-3672.patch)

include_directories(${c-ares_INC})
add_library(mindspore::cares ALIAS c-ares::cares)

+ 0
- 37
cmake/external_libs/cmsis.cmake View File

@@ -1,37 +0,0 @@
set(cmsis_pkg_name cmsis)

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/CMSIS_5/repository/archive/5.7.0.tar.gz")
set(MD5 "0eaa594b0c62dd72e41ec181c4689842")
else()
set(REQ_URL "https://github.com/ARM-software/CMSIS_5/archive/5.7.0.tar.gz")
set(MD5 "0eaa594b0c62dd72e41ec181c4689842")
endif()

set(INCLUDE "./")

mindspore_add_pkg(${cmsis_pkg_name}
VER 5.7.0
HEAD_ONLY ${INCLUDE}
URL ${REQ_URL}
MD5 ${MD5})

message("micro get ${cmsis_pkg_name} config hash: ${${cmsis_pkg_name}_CONFIG_HASH}")

file(GLOB cmsic_children RELATIVE ${_MS_LIB_CACHE} ${_MS_LIB_CACHE}/*)

foreach(child ${cmsic_children})
string(FIND "${child}" "${cmsis_pkg_name}" position)
if(NOT "${position}" EQUAL "-1")
file(STRINGS ${_MS_LIB_CACHE}/${child}/options.txt cmsis_configs)
foreach(cmsis_config ${cmsis_configs})
string(FIND "${cmsis_config}" "${MD5}" position_md5)
if(NOT "${position_md5}" EQUAL "-1")
if(NOT IS_DIRECTORY ${CMAKE_BINARY_DIR}/${cmsis_pkg_name})
MESSAGE("copy cmsis libaray: ${child} to ${CMAKE_BINARY_DIR}")
file(COPY ${_MS_LIB_CACHE}/${child}/CMSIS DESTINATION ${CMAKE_BINARY_DIR}/${cmsis_pkg_name})
endif()
endif()
endforeach()
endif()
endforeach()

+ 0
- 21
cmake/external_libs/cppjieba.cmake View File

@@ -1,21 +0,0 @@
set(cppjieba_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(cppjieba_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/cppjieba/repository/archive/v5.0.3.tar.gz")
set(MD5 "06fcc22b4db6c332dc1b0bd353bdf6f2")
else()
set(REQ_URL "https://github.com/yanyiwu/cppjieba/archive/v5.0.3.tar.gz")
set(MD5 "b8b3f7a73032c9ce9daafa4f67196c8c")
endif()

mindspore_add_pkg(cppjieba
VER 5.0.3
HEAD_ONLY ./
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/cppjieba/cppjieba.patch001)
include_directories(${cppjieba_INC}include)
include_directories(${cppjieba_INC}deps)
add_library(mindspore::cppjieba ALIAS cppjieba)


+ 5
- 0
cmake/external_libs/dlpack.cmake View File

@@ -0,0 +1,5 @@
mindspore_add_pkg(dlpack
VER 0.2
HEAD_ONLY ./
URL https://github.com/dmlc/dlpack/archive/0acb731e0e43d15deee27b66f10e4c5b4e667913.zip
MD5 6b8093f17ad4e830d3c63eb3171c4b45)

+ 5
- 0
cmake/external_libs/dmlc_core.cmake View File

@@ -0,0 +1,5 @@
mindspore_add_pkg(dmlc_core
VER 0.3
HEAD_ONLY ./
URL https://github.com/dmlc/dmlc-core/archive/808f485387f9a03f78fa9f1159f387d0d91b7a28.zip
MD5 ea36f94c57752bf40fb02dfc362f1ed9)

+ 4
- 10
cmake/external_libs/eigen.cmake View File

@@ -1,17 +1,11 @@
set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")


set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz")
set(MD5 "609286804b0f79be622ccf7f9ff2b660")


mindspore_add_pkg(Eigen3 mindspore_add_pkg(Eigen3
VER 3.3.9
URL ${REQ_URL}
MD5 ${MD5}
VER 3.3.7
URL https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz
MD5 9e30f67e8531477de4117506fe44669b
CMAKE_OPTION -DBUILD_TESTING=OFF) CMAKE_OPTION -DBUILD_TESTING=OFF)
find_package(Eigen3 3.3.9 REQUIRED ${MS_FIND_NO_DEFAULT_PATH})
find_package(Eigen3 3.3.7 REQUIRED ${MS_FIND_NO_DEFAULT_PATH})
include_directories(${Eigen3_INC}) include_directories(${Eigen3_INC})
include_directories(${EIGEN3_INCLUDE_DIR}) include_directories(${EIGEN3_INCLUDE_DIR})
set_property(TARGET Eigen3::Eigen PROPERTY IMPORTED_GLOBAL TRUE) set_property(TARGET Eigen3::Eigen PROPERTY IMPORTED_GLOBAL TRUE)


+ 14
- 113
cmake/external_libs/flatbuffers.cmake View File

@@ -1,66 +1,16 @@
if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(flatbuffers_CXXFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
set(flatbuffers_CFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
endif()
set(flatbuffers_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(flatbuffers_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(flatbuffers
VER 1.11.0
LIBS flatbuffers
EXE flatc
URL https://github.com/google/flatbuffers/archive/v1.11.0.tar.gz
MD5 02c64880acb89dbd57eebacfd67200d8
CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF )


if(WIN32)
set(flatbuffers_USE_STATIC_LIBS ON)
endif()
if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/flatbuffers.git")
set(GIT_TAG "openEuler-22.03-LTS")
set(MD5 "f1c724296be49a29ded69278a9a770c7")
set(FLATBUFFER_SRC "${TOP_DIR}/mindspore/lite/build/_deps/flatbuffers-src")
set(FLATBUFFER_DIR "${FLATBUFFER_SRC}/flatbuffers-2.0.0")
__download_pkg_with_git(flatbuffers ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
execute_process(COMMAND tar -xf ${FLATBUFFER_SRC}/v2.0.0.tar.gz WORKING_DIRECTORY ${FLATBUFFER_SRC})

foreach(_SUBMODULE_FILE ${PKG_SUBMODULES})
STRING(REGEX REPLACE "(.+)_(.+)" "\\1" _SUBMODEPATH ${_SUBMODULE_FILE})
STRING(REGEX REPLACE "(.+)/(.+)" "\\2" _SUBMODENAME ${_SUBMODEPATH})
file(GLOB ${pkg_name}_INSTALL_SUBMODULE ${_SUBMODULE_FILE}/*)
file(COPY ${${pkg_name}_INSTALL_SUBMODULE} DESTINATION ${${pkg_name}_SOURCE_DIR}/3rdparty/${_SUBMODENAME})
endforeach()
else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/flatbuffers/repository/archive/v2.0.0.tar.gz")
set(MD5 "5c23d17c0486b81d4c11907e8f7bf36b")
else()
set(REQ_URL "https://github.com/google/flatbuffers/archive/v2.0.0.tar.gz")
set(MD5 "a27992324c3cbf86dd888268a23d17bd")
endif()
endif()

if(APPLE)
set(flatbuffers_CXXFLAGS "${flatbuffers_CXXFLAGS} -Wno-deprecated")
endif()
if(APPLE)
mindspore_add_pkg(flatbuffers
VER 2.0.0
LIBS flatbuffers
EXE flatc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
else()
mindspore_add_pkg(flatbuffers
VER 2.0.0
LIBS flatbuffers
EXE flatc
URL ${REQ_URL}
MD5 ${MD5}
DIR ${FLATBUFFER_DIR}
CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER}
-DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release)
endif()

include_directories(${flatbuffers_INC})
add_library(mindspore::flatbuffers ALIAS flatbuffers::flatbuffers) add_library(mindspore::flatbuffers ALIAS flatbuffers::flatbuffers)
add_executable(mindspore::flatc ALIAS flatbuffers::flatc) add_executable(mindspore::flatc ALIAS flatbuffers::flatc)
include_directories(${flatbuffers_INC})
function(ms_build_flatbuffers source_schema_files function(ms_build_flatbuffers source_schema_files
source_schema_dirs source_schema_dirs
custom_target_name custom_target_name
@@ -69,13 +19,13 @@ function(ms_build_flatbuffers source_schema_files
set(total_schema_dirs "") set(total_schema_dirs "")
set(total_generated_files "") set(total_generated_files "")
set(FLATC mindspore::flatc) set(FLATC mindspore::flatc)
foreach(schema_dir ${source_schema_dirs})
foreach (schema_dir ${source_schema_dirs})
set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs}) set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
endforeach() endforeach()


foreach(schema IN LISTS ${source_schema_files})
foreach(schema ${source_schema_files})
get_filename_component(filename ${schema} NAME_WE) get_filename_component(filename ${schema} NAME_WE)
if(NOT ${generated_output_dir} STREQUAL "")
if (NOT ${generated_output_dir} STREQUAL "")
set(generated_file ${generated_output_dir}/${filename}_generated.h) set(generated_file ${generated_output_dir}/${filename}_generated.h)
add_custom_command( add_custom_command(
OUTPUT ${generated_file} OUTPUT ${generated_file}
@@ -93,56 +43,7 @@ function(ms_build_flatbuffers source_schema_files
add_custom_target(${custom_target_name} ALL add_custom_target(${custom_target_name} ALL
DEPENDS ${total_generated_files}) DEPENDS ${total_generated_files})


if(NOT ${generated_output_dir} STREQUAL "")
include_directories(${generated_output_dir})
set_property(TARGET ${custom_target_name}
PROPERTY GENERATED_OUTPUT_DIR
${generated_output_dir})
endif()
endfunction()

function(ms_build_flatbuffers_lite
source_schema_files source_schema_dirs custom_target_name generated_output_dir if_inner)

set(total_schema_dirs "")
set(total_generated_files "")
set(FLATC mindspore::flatc)
foreach(schema_dir ${source_schema_dirs})
set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
endforeach()

foreach(schema IN LISTS ${source_schema_files})
get_filename_component(filename ${schema} NAME_WE)
if(NOT ${generated_output_dir} STREQUAL "")
set(generated_file ${generated_output_dir}/${filename}_generated.h)
if(if_inner MATCHES "inner")
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} --gen-mutable
--reflect-names --gen-object-api -o ${generated_output_dir}
${total_schema_dirs}
-c -b --reflect-types ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}" VERBATIM)
else()
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} -o ${generated_output_dir}
${total_schema_dirs}
-c -b ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}" VERBATIM)
endif()
list(APPEND total_generated_files ${generated_file})
endif()
endforeach()

add_custom_target(${custom_target_name} ALL
DEPENDS ${total_generated_files})

if(NOT ${generated_output_dir} STREQUAL "")
if (NOT ${generated_output_dir} STREQUAL "")
include_directories(${generated_output_dir}) include_directories(${generated_output_dir})
set_property(TARGET ${custom_target_name} set_property(TARGET ${custom_target_name}
PROPERTY GENERATED_OUTPUT_DIR PROPERTY GENERATED_OUTPUT_DIR


+ 7
- 49
cmake/external_libs/glog.cmake View File

@@ -1,52 +1,10 @@
if(BUILD_LITE)
if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_C_FLAGS}")
set(glog_LDFLAGS "${SECURE_SHARED_LINKER_FLAGS}")
endif()
set(glog_patch "")
set(glog_lib glog)
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(glog_patch ${CMAKE_SOURCE_DIR}/third_party/patch/glog/glog.patch001)
set(glog_lib mindspore_glog)
endif()

if(NOT ENABLE_GLIBCXX)
set(glog_CXXFLAGS "${glog_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/glog/repository/archive/v0.4.0.tar.gz")
set(MD5 "9a7598a00c569a11ff1a419076de4ed7")
else()
set(REQ_URL "https://github.com/google/glog/archive/v0.4.0.tar.gz")
set(MD5 "0daea8785e6df922d7887755c3d100d0")
endif()

set(glog_option -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_GFLAGS=OFF
-DCMAKE_BUILD_TYPE=Release)

if(WIN32 AND NOT MSVC)
execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
OUTPUT_VARIABLE i686_or_x86_64
)
if(i686_or_x86_64 MATCHES "^i686-")
set(glog_option ${glog_option} -DHAVE_DBGHELP=ON)
endif()
endif()

set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS}")
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(glog mindspore_add_pkg(glog
VER 0.4.0 VER 0.4.0
LIBS ${glog_lib}
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${glog_patch}
CMAKE_OPTION ${glog_option})
LIBS glog
URL https://github.com/google/glog/archive/v0.4.0.tar.gz
MD5 0daea8785e6df922d7887755c3d100d0
CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON)
include_directories(${glog_INC}) include_directories(${glog_INC})
add_library(mindspore::glog ALIAS glog::${glog_lib})
add_library(mindspore::glog ALIAS glog::glog)

+ 0
- 129
cmake/external_libs/grpc.cmake View File

@@ -1,129 +0,0 @@
set(grpc_USE_STATIC_LIBS OFF)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 -O2 \
-Dgrpc=mindspore_grpc -Dgrpc_impl=mindspore_grpc_impl -Dgrpc_core=mindspore_grpc_core")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
else()
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2 \
-Dgrpc=mindspore_grpc -Dgrpc_impl=mindspore_grpc_impl -Dgrpc_core=mindspore_grpc_core")
if(NOT ENABLE_GLIBCXX)
set(grpc_CXXFLAGS "${grpc_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif()

if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(grpc_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()

if(EXISTS ${protobuf_ROOT}/lib64)
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib64/cmake/protobuf")
else()
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib/cmake/protobuf")
endif()
message("grpc using Protobuf_DIR : " ${_FINDPACKAGE_PROTOBUF_CONFIG_DIR})

if(EXISTS ${absl_ROOT}/lib64)
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib64/cmake/absl")
else()
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib/cmake/absl")
endif()
message("grpc using absl_DIR : " ${_FINDPACKAGE_ABSL_CONFIG_DIR})

if(EXISTS ${re2_ROOT}/lib64)
set(_FINDPACKAGE_RE2_CONFIG_DIR "${re2_ROOT}/lib64/cmake/re2")
else()
set(_FINDPACKAGE_RE2_CONFIG_DIR "${re2_ROOT}/lib/cmake/re2")
endif()
message("grpc using re2_DIR : " ${_FINDPACKAGE_RE2_CONFIG_DIR})

if(EXISTS ${openssl_ROOT})
set(_CMAKE_ARGS_OPENSSL_ROOT_DIR "-DOPENSSL_ROOT_DIR:PATH=${openssl_ROOT}")
endif()

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/grpc/repository/archive/v1.36.1.tar.gz")
set(MD5 "71252ebcd8e9e32a818a907dfd4b63cc")
else()
set(REQ_URL "https://github.com/grpc/grpc/archive/v1.36.1.tar.gz")
set(MD5 "90c93203e95e89af5f46738588217057")
endif()

mindspore_add_pkg(grpc
VER 1.36.1
LIBS mindspore_grpc++ mindspore_grpc mindspore_gpr mindspore_upb mindspore_address_sorting
EXE grpc_cpp_plugin
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/grpc/grpc.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release
-DBUILD_SHARED_LIBS=ON
-DgRPC_INSTALL:BOOL=ON
-DgRPC_BUILD_TESTS:BOOL=OFF
-DgRPC_PROTOBUF_PROVIDER:STRING=package
-DgRPC_PROTOBUF_PACKAGE_TYPE:STRING=CONFIG
-DProtobuf_DIR:PATH=${_FINDPACKAGE_PROTOBUF_CONFIG_DIR}
-DgRPC_ZLIB_PROVIDER:STRING=package
-DZLIB_ROOT:PATH=${zlib_ROOT}
-DgRPC_ABSL_PROVIDER:STRING=package
-Dabsl_DIR:PATH=${_FINDPACKAGE_ABSL_CONFIG_DIR}
-DgRPC_CARES_PROVIDER:STRING=package
-Dc-ares_DIR:PATH=${c-ares_ROOT}/lib/cmake/c-ares
-DgRPC_SSL_PROVIDER:STRING=package
${_CMAKE_ARGS_OPENSSL_ROOT_DIR}
-DgRPC_RE2_PROVIDER:STRING=package
-Dre2_DIR:PATH=${_FINDPACKAGE_RE2_CONFIG_DIR}
)

include_directories(${grpc_INC})

add_library(mindspore::grpc++ ALIAS grpc::mindspore_grpc++)

# link other grpc libs
target_link_libraries(grpc::mindspore_grpc++ INTERFACE grpc::mindspore_grpc grpc::mindspore_gpr grpc::mindspore_upb
grpc::mindspore_address_sorting)

# modify mindspore macro define
add_compile_definitions(grpc=mindspore_grpc)
add_compile_definitions(grpc_impl=mindspore_grpc_impl)
add_compile_definitions(grpc_core=mindspore_grpc_core)

function(ms_grpc_generate c_var h_var)
if(NOT ARGN)
message(SEND_ERROR "Error: ms_grpc_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)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})

list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h")
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h")

add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc --version
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto
--grpc_out=${CMAKE_BINARY_DIR}/proto
--plugin=protoc-gen-grpc=$<TARGET_FILE:grpc::grpc_cpp_plugin> ${abs_file}
DEPENDS protobuf::protoc grpc::grpc_cpp_plugin ${abs_file}
COMMENT "Running C++ gRPC 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()

+ 8
- 62
cmake/external_libs/gtest.cmake View File

@@ -1,67 +1,13 @@
set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")

set(CMAKE_OPTION
-DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON
-DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON)
if(BUILD_LITE)
if(PLATFORM_ARM64)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=${ANDROID_STL}
${CMAKE_OPTION})
endif()
if(PLATFORM_ARM32)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=armeabi-v7a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=${ANDROID_STL}
${CMAKE_OPTION})
endif()
endif()

if(NOT ENABLE_GLIBCXX)
set(gtest_CXXFLAGS "${gtest_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.1.tar.gz")
set(MD5 "2e6fbeb6a91310a16efe181886c59596")
else()
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz")
set(MD5 "2e6fbeb6a91310a16efe181886c59596")
endif()

mindspore_add_pkg(gtest mindspore_add_pkg(gtest
VER 1.8.1
LIBS gtest gmock
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION})
VER 1.8.0
LIBS gtest
URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz
MD5 16877098823401d1bf2ed7891d7dce36
CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON
-DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON)
include_directories(${gtest_INC}) include_directories(${gtest_INC})
add_library(mindspore::gtest ALIAS gtest::gtest) add_library(mindspore::gtest ALIAS gtest::gtest)
add_library(mindspore::gmock ALIAS gtest::gmock)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
file(COPY ${gtest_DIRPATH}/bin/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_DIRPATH}/bin/libgtest_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_DIRPATH}/bin/libgmock_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_DIRPATH}/bin/libgmock${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
else()
file(COPY ${gtest_LIBPATH}/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgtest_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgmock${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgmock_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
endif()
file(COPY ${gtest_LIBPATH}/libgtest.so DESTINATION ${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgtest_main.so DESTINATION ${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)

+ 0
- 69
cmake/external_libs/icu4c.cmake View File

@@ -1,69 +0,0 @@
set(LIB_ICU_COMMON icuuc)
set(LIB_ICU_DATA icudata)
set(LIB_ICU_I18N icui18n)

if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/icu.git")
set(GIT_TAG "openEuler-22.03-LTS")
set(MD5 "fa4070da839ce75469a8de962f2a0c2a")
set(ICU4C_SRC "${TOP_DIR}/build/mindspore/_deps/icu4c-src/icu4c")
set(ICU4C_TAR_SRC "${TOP_DIR}/build/mindspore/_deps/icu4c-src")
__download_pkg_with_git(icu4c ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
execute_process(COMMAND mkdir ${ICU4C_SRC})
execute_process(COMMAND tar -xf ${ICU4C_TAR_SRC}/icu4c-69_1-src.tgz --strip-components 1 -C ${ICU4C_SRC})
else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/icu/repository/archive/release-69-1.tar.gz")
set(MD5 "9f218f0eee9d49831e7e48fd136e689c")
else()
set(REQ_URL "https://github.com/unicode-org/icu/archive/release-69-1.tar.gz")
set(MD5 "135125f633864285d637db5c01e0388b")
endif()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
message("icu4c thirdparty do not support windows currently.")
else()
set(JSON_FILE "{ \n\
\"strategy\": \"additive\",\n\
\"featureFilters\": {\n\
\"normalization\": \"include\"\n\
}\n\
}\
")
file(WRITE ${CMAKE_BINARY_DIR}/icu4c_filter.json ${JSON_FILE})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
mindspore_add_pkg(icu4c
VER 69.1
LIBS ${LIB_ICU_COMMON} ${LIB_ICU_DATA} ${LIB_ICU_I18N}
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/icu4c/icu4c.patch01
CONFIGURE_COMMAND ./icu4c/source/runConfigureICU MacOSX --disable-tests
--disable-samples --disable-icuio --disable-extras
ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json
)
else()
mindspore_add_pkg(icu4c
VER 69.1
LIBS ${LIB_ICU_COMMON} ${LIB_ICU_DATA} ${LIB_ICU_I18N}
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/icu4c/icu4c.patch01
CONFIGURE_COMMAND ./icu4c/source/runConfigureICU Linux --enable-rpath --disable-tests --disable-samples
--disable-icuio --disable-extras
ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json
)
endif()
include_directories(${icu4c_INC})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
include(${CMAKE_SOURCE_DIR}/cmake/change_rpath.cmake)
changerpath($<TARGET_FILE:icu4c::${LIB_ICU_COMMON}> ${LIB_ICU_COMMON} "libicuuc;libicudata")
changerpath($<TARGET_FILE:icu4c::${LIB_ICU_DATA}> ${LIB_ICU_DATA} "libicudata")
changerpath($<TARGET_FILE:icu4c::${LIB_ICU_I18N}> ${LIB_ICU_I18N} "libicuuc;libicudata;libicui18n")
endif()
add_library(mindspore::icuuc ALIAS icu4c::${LIB_ICU_COMMON})
add_library(mindspore::icudata ALIAS icu4c::${LIB_ICU_DATA})
add_library(mindspore::icui18n ALIAS icu4c::${LIB_ICU_I18N})
add_definitions(-D ENABLE_ICU4C)
endif()

+ 6
- 49
cmake/external_libs/jpeg_turbo.cmake View File

@@ -1,56 +1,13 @@


if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/libjpeg-turbo/repository/archive/2.0.4.tar.gz")
set(MD5 "44c43e4a9fb352f47090804529317c88")
else()
set(REQ_URL "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.4.tar.gz")
set(MD5 "44c43e4a9fb352f47090804529317c88")
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
-O2")
else()
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
-D_FORTIFY_SOURCE=2 -O2")
endif()

set(jpeg_turbo_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack,-s")


set(jpeg_turbo_USE_STATIC_LIBS ON) set(jpeg_turbo_USE_STATIC_LIBS ON)
set(JPEG_TURBO_PATCHE ${CMAKE_SOURCE_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001)
set(CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=TRUE -DWITH_SIMD=ON)
if(BUILD_LITE)
set(jpeg_turbo_USE_STATIC_LIBS OFF)
set(JPEG_TURBO_PATCHE ${TOP_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001)
if(PLATFORM_ARM64)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
if(PLATFORM_ARM32)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=armeabi-v7a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()

endif()

set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(jpeg_turbo_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
mindspore_add_pkg(jpeg_turbo mindspore_add_pkg(jpeg_turbo
VER 2.0.4 VER 2.0.4
LIBS jpeg turbojpeg
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION}
PATCHES ${JPEG_TURBO_PATCHE}
LIBS jpeg
URL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.4.tar.gz
MD5 44c43e4a9fb352f47090804529317c88
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=TRUE
) )
include_directories(${jpeg_turbo_INC}) include_directories(${jpeg_turbo_INC})
add_library(mindspore::jpeg_turbo ALIAS jpeg_turbo::jpeg) add_library(mindspore::jpeg_turbo ALIAS jpeg_turbo::jpeg)
add_library(mindspore::turbojpeg ALIAS jpeg_turbo::turbojpeg)

+ 9
- 26
cmake/external_libs/json.cmake View File

@@ -1,26 +1,9 @@
if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(nlohmann_json373_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json373_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
endif()

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.7.3.zip")
set(MD5 "b758acca4f3e133bacf919e31ca302e3")
set(INCLUDE "./include")
else()
set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip")
set(MD5 "fb96f95cdf609143e998db401ca4f324")
set(INCLUDE "./include")
endif()

mindspore_add_pkg(nlohmann_json373
VER 3.7.3
HEAD_ONLY ${INCLUDE}
URL ${REQ_URL}
MD5 ${MD5})
include_directories(${nlohmann_json373_INC})
add_library(mindspore::json ALIAS nlohmann_json373)
set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(nlohmann_json
VER 3.6.1
HEAD_ONLY ./
URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip
MD5 0dc903888211db3a0f170304cd9f3a89)
include_directories(${nlohmann_json_INC})
add_library(mindspore::json ALIAS nlohmann_json)

+ 0
- 30
cmake/external_libs/libevent.cmake View File

@@ -1,30 +0,0 @@
set(libevent_CFLAGS "-fstack-protector-all -D_FORTIFY_SOURCE=2 -O2")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(libevent_LDFLAGS "-Wl,-z,now")
endif()

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/libevent/repository/archive/release-2.1.12-stable.tar.gz")
set(MD5 "0d5a27436bf7ff8253420c8cf09f47ca")
else()
set(REQ_URL
"https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz")
set(MD5 "b5333f021f880fe76490d8a799cd79f4")
endif()

message("libevent using openssl stub dir: " ${openssl_ROOT})

mindspore_add_pkg(libevent
VER 2.1.12
LIBS event event_pthreads event_core event_openssl
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/libevent/libevent.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_TESTING=OFF -DOPENSSL_ROOT_DIR:PATH=${openssl_ROOT})

include_directories(${libevent_INC})

add_library(mindspore::event ALIAS libevent::event)
add_library(mindspore::event_pthreads ALIAS libevent::event_pthreads)
add_library(mindspore::event_core ALIAS libevent::event_core)
add_library(mindspore::event_openssl ALIAS libevent::event_openssl)

+ 7
- 27
cmake/external_libs/libtiff.cmake View File

@@ -1,36 +1,16 @@
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -Wno-unused-result \
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(tiff_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -Wno-unused-result \
set(tiff_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
else()
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(tiff_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(tiff_CFLAGS "${tiff_CFLAGS} -Wno-int-to-pointer-cast -Wno-implicit-fallthrough -Wno-pointer-to-int-cast")
endif()
endif()

set(tiff_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") set(tiff_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")


if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/libtiff/repository/archive/v4.2.0.tar.gz")
set(MD5 "1b8f32e39940ffbdac3638f7081ba9e0")
else()
set(REQ_URL "http://download.osgeo.org/libtiff/tiff-4.2.0.tar.gz")
set(MD5 "2bbf6db1ddc4a59c89d6986b368fc063")
endif()

mindspore_add_pkg(tiff mindspore_add_pkg(tiff
VER 4.2.0
VER 4.1.0
LIBS tiff LIBS tiff
URL ${REQ_URL}
MD5 ${MD5}
URL https://gitlab.com/libtiff/libtiff/-/archive/v4.1.0/libtiff-v4.1.0.tar.gz
MD5 21de8d35c1b21ac82663fa9f56d3350d
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -Djbig=OFF -Dlzma=OFF -Djpeg12=OFF -Dzstd=OFF -Dpixarlog=OFF CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -Djbig=OFF -Dlzma=OFF -Djpeg12=OFF -Dzstd=OFF -Dpixarlog=OFF
-Dold-jpeg=OFF -Dwebp=OFF -DBUILD_SHARED_LIBS=OFF -Dlibdeflate=OFF
PATCHES ${TOP_DIR}/third_party/patch/libtiff/CVE-2022-0561_and_CVE-2022-0562.patch001
PATCHES ${TOP_DIR}/third_party/patch/libtiff/CVE-2022-0908.patch002)
-Dold-jpeg=OFF -Dwebp=OFF -DBUILD_SHARED_LIBS=OFF)
message("tiff include = ${tiff_INC}") message("tiff include = ${tiff_INC}")
message("tiff lib = ${tiff_LIB}") message("tiff lib = ${tiff_LIB}")

+ 10
- 45
cmake/external_libs/mkl_dnn.cmake View File

@@ -1,46 +1,11 @@
set(onednn_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(onednn_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
if(USE_MS_THREADPOOL_FOR_DNNL)
set(USE_MS_THREADPOOL "-DDNNL_CPU_RUNTIME=THREADPOOL")
else()
set(USE_MS_THREADPOOL "")
endif()
if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "git@gitee.com:src-openeuler/onednn.git")
set(GIT_TAG "0d726f1")
set(MD5 "6a062e36ea1bee03ff55bf44ee243e27")
__download_pkg_with_git(ONEDNN ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
set(ONE_DNN_SRC "${TOP_DIR}/mindspore/lite/build/_deps/onednn-src")
execute_process(COMMAND tar -xf ${ONE_DNN_SRC}/v2.2.tar.gz --strip-components 1 -C ${ONE_DNN_SRC})
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
mindspore_add_pkg(onednn
VER 2.2
set(mkl_dnn_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(mkl_dnn_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(mkl_dnn
VER 1.1.1
LIBS dnnl mkldnn LIBS dnnl mkldnn
HEAD_ONLY ./include
RELEASE on
URL http://tools.mindspore.cn/libs/dnnl/dnnl_win_2.2.0_cpu_vcomp.zip
MD5 139fcdbd601a970fb86dd15b30ba5ae3)
else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/MKL-DNN/repository/archive/v2.2.tar.gz")
set(MD5 "49c650e0cc24ef9ae7033d4cb22ebfad")
else()
set(REQ_URL "https://github.com/oneapi-src/oneDNN/archive/v2.2.tar.gz")
set(MD5 "6a062e36ea1bee03ff55bf44ee243e27")
endif()
mindspore_add_pkg(onednn
VER 2.2
LIBS dnnl mkldnn
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0002-fix-pool-nthr-bug.patch
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch
CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF
${USE_MS_THREADPOOL} -DDNNL_ENABLE_CONCURRENT_EXEC=ON)
endif()

include_directories(${onednn_INC})
add_library(mindspore::dnnl ALIAS onednn::dnnl)
add_library(mindspore::mkldnn ALIAS onednn::mkldnn)
URL https://github.com/intel/mkl-dnn/archive/v1.1.1.tar.gz
MD5 d6a422b00459600bdc22242590953f38
CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_CPU_RUNTIME='SEQ' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF)
include_directories(${mkl_dnn_INC})
add_library(mindspore::dnnl ALIAS mkl_dnn::dnnl)
add_library(mindspore::mkldnn ALIAS mkl_dnn::mkldnn)

+ 5
- 12
cmake/external_libs/nccl.cmake View File

@@ -1,19 +1,12 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/nccl/repository/archive/v2.7.6-1.tar.gz")
set(MD5 "6884364c2b1cf229f0bdaf94efcb5782")
else()
set(REQ_URL "https://github.com/NVIDIA/nccl/archive/v2.7.6-1.tar.gz")
set(MD5 "073b19899f374c5ba07d2db02dc38f9f")
endif()


set(nccl_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(nccl_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(nccl mindspore_add_pkg(nccl
VER 2.7.6-1
VER 2.4.8-1
LIBS nccl LIBS nccl
URL ${REQ_URL}
MD5 ${MD5}
BUILD_OPTION src.build
URL https://github.com/NVIDIA/nccl/archive/v2.4.8-1.tar.gz
MD5 f14b37d6af1c79db5f57cb029a753727
BUILD_OPTION src.build NVCC_GENCODE="-gencode=arch=compute_70,code=sm_70"
INSTALL_INCS build/include/* INSTALL_INCS build/include/*
INSTALL_LIBS build/lib/*) INSTALL_LIBS build/lib/*)
include_directories(${nccl_INC}) include_directories(${nccl_INC})
add_library(mindspore::nccl ALIAS nccl::nccl)
add_library(mindspore::nccl ALIAS nccl::nccl)

+ 3
- 10
cmake/external_libs/ompi.cmake View File

@@ -1,17 +1,10 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/ompi/repository/archive/v4.0.3.tar.gz")
set(MD5 "70f764c26ab6cd99487d58be0cd8c409")
else()
set(REQ_URL "https://github.com/open-mpi/ompi/archive/v4.0.3.tar.gz")
set(MD5 "86cb724e8fe71741ad3be4e7927928a2")
endif()


set(ompi_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(ompi_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(ompi mindspore_add_pkg(ompi
VER 4.0.3
VER 3.1.5
LIBS mpi LIBS mpi
URL ${REQ_URL}
MD5 ${MD5}
URL https://github.com/open-mpi/ompi/archive/v3.1.5.tar.gz
MD5 f7f220b26532c11a2efbc0bb73af3282
PRE_CONFIGURE_COMMAND ./autogen.pl PRE_CONFIGURE_COMMAND ./autogen.pl
CONFIGURE_COMMAND ./configure) CONFIGURE_COMMAND ./configure)
include_directories(${ompi_INC}) include_directories(${ompi_INC})

+ 5
- 0
cmake/external_libs/onnx.cmake View File

@@ -0,0 +1,5 @@
mindspore_add_pkg(ms_onnx
VER 1.6.0
HEAD_ONLY ./
URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz
MD5 512f2779d6215d4a36f366b6b9acdf1e)

+ 0
- 55
cmake/external_libs/opencl.cmake View File

@@ -1,55 +0,0 @@
if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "git@gitee.com:src-openeuler/opencl-clhpp.git")
set(GIT_TAG "7347fa1bb52ebee9f3d6c44ff65ef3c4253cab79")
set(MD5 "d41d8cd98f00b204e9800998ecf8427e")

__download_pkg_with_git(OpenCL-CLHPP ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
set(OPENCL_CLHPP_SRC "${TOP_DIR}/mindspore/lite/build/_deps/opencl-clhpp-src")
execute_process(COMMAND tar -xf ${OPENCL_CLHPP_SRC}/v2.0.12.tar.gz --strip-components 1 -C ${OPENCL_CLHPP_SRC})

set(OPENCL_HEADER_SRC "${TOP_DIR}/mindspore/lite/build/_deps/opencl-headers-src")
execute_process(COMMAND mkdir -p ${OPENCL_HEADER_SRC})
execute_process(COMMAND tar -xf ${OPENCL_CLHPP_SRC}/v2020.12.18.tar.gz --strip-components 1 -C ${OPENCL_HEADER_SRC})
elseif(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/OpenCL-Headers/repository/archive/v2020.12.18.tar.gz")
set(MD5 "9a34e50198ac54b795bf3822bb6e429a")
__download_pkg(OpenCL-Headers ${REQ_URL} ${MD5})
set(REQ_URL "https://gitee.com/mirrors/OpenCL-CLHPP/repository/archive/v2.0.12.tar.gz")
set(MD5 "3439d8eb6d247bfd02164bcd0c8e5adb")
__download_pkg(OpenCL-CLHPP ${REQ_URL} ${MD5})
else()
set(REQ_URL "https://github.com/KhronosGroup/OpenCL-Headers/archive/v2020.12.18.tar.gz")
set(MD5 "ea0296fb79951f43082b742234f26c9a")
__download_pkg(OpenCL-Headers ${REQ_URL} ${MD5})
set(REQ_URL "https://github.com/KhronosGroup/OpenCL-CLHPP/archive/v2.0.12.tar.gz")
set(MD5 "bd00fca8f861b3b65660d719f00a58dd")
__download_pkg(OpenCL-CLHPP ${REQ_URL} ${MD5})
endif()

function(gene_opencl CL_SRC_DIR)
message(STATUS "**********gene opencl********* cl path: " "${CL_SRC_DIR}")
if(NOT EXISTS ${CL_SRC_DIR})
return()
endif()
file(GLOB_RECURSE CL_LIST ${CL_SRC_DIR}/*.cl)
foreach(file_path ${CL_LIST})
file(REMOVE ${file_path}.inc)
string(REGEX REPLACE ".+/(.+)\\..*" "\\1" kernel_name "${file_path}")
set(inc_file_ex "${file_path}.inc")
execute_process(
COMMAND bash -c "sed 's/\\\\/\\\\\\\\/g' "
COMMAND bash -c "sed 's/\\\"/\\\\\\\"/g' "
COMMAND bash -c "sed 's/$/\\\\n\\\" \\\\/' "
COMMAND bash -c "sed 's/^/\\\"/' "
WORKING_DIRECTORY ${CL_SRC_DIR}
INPUT_FILE ${file_path}
OUTPUT_FILE ${inc_file_ex}
RESULT_VARIABLE RESULT)
if(NOT RESULT EQUAL "0")
message(FATAL_ERROR "error! when generate ${inc_file_ex}")
endif()
__exec_cmd(COMMAND sed -i "1i\\static const char *${kernel_name}_source =\\\"\\\\n\\\" \\\\"
${inc_file_ex} WORKING_DIRECTORY ${CL_SRC_DIR})
__exec_cmd(COMMAND sed -i "$a\\\\\;" ${inc_file_ex} WORKING_DIRECTORY ${CL_SRC_DIR})
endforeach()
endfunction()

+ 29
- 137
cmake/external_libs/opencv.cmake View File

@@ -1,139 +1,31 @@
if(MSVC)
set(opencv_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(opencv_CFLAGS "${CMAKE_C_FLAGS}")
set(opencv_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-attributes -Wno-unknown-pragmas")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-unused-value -Wno-implicit-fallthrough")
else()
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -O2")
if(NOT ENABLE_GLIBCXX)
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack -s")
endif()


if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/opencv.git")
set(GIT_TAG "openEuler-22.03-LTS")
set(MD5 "e2b5aa4946559d0a397148d6e1ab7284")
set(OPENCV_SRC "${TOP_DIR}/build/mindspore/_deps/opencv-src")
__download_pkg_with_git(opencv ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
execute_process(COMMAND tar -xf ${OPENCV_SRC}/opencv-4.5.2.tar.gz --strip-components 1 -C ${OPENCV_SRC})
else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.5.2.tar.gz")
set(MD5 "d3141f649ab2d76595fdd8991ee15c55")
else()
set(REQ_URL "https://github.com/opencv/opencv/archive/4.5.2.tar.gz")
set(MD5 "d3141f649ab2d76595fdd8991ee15c55")
endif()
endif()
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")


if(MSVC)
mindspore_add_pkg(opencv
VER 4.5.2
LIBS opencv_core452.lib opencv_imgcodecs452.lib opencv_imgproc452.lib
LIB_PATH x64/*/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
elseif(WIN32)
mindspore_add_pkg(opencv
VER 4.5.2
LIBS libopencv_core452.dll.a libopencv_imgcodecs452.dll.a libopencv_imgproc452.dll.a
LIB_PATH x64/mingw/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
else()
mindspore_add_pkg(opencv
VER 4.5.2
LIBS opencv_core opencv_imgcodecs opencv_imgproc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
endif()

if(MSVC)
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::opencv_core452.lib)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs452.lib)
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc452.lib)
elseif(WIN32)
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core452.dll.a)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::libopencv_imgcodecs452.dll.a)
add_library(mindspore::opencv_imgproc ALIAS opencv::libopencv_imgproc452.dll.a)
else()
include_directories(${opencv_INC}/opencv4)
add_library(mindspore::opencv_core ALIAS opencv::opencv_core)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs)
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc)
endif()
mindspore_add_pkg(opencv
VER 4.2.0
LIBS opencv_core opencv_imgcodecs opencv_imgproc
URL https://github.com/opencv/opencv/archive/4.2.0.tar.gz
MD5 e8cb208ce2723481408b604b480183b6
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF -DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
include_directories(${opencv_INC}/opencv4)
add_library(mindspore::opencv_core ALIAS opencv::opencv_core)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs)
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc)

+ 0
- 78
cmake/external_libs/openssl.cmake View File

@@ -1,78 +0,0 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/openssl/repository/archive/OpenSSL_1_1_1k.tar.gz")
set(MD5 "bdd51a68ad74618dd2519da8e0bcc759")
else()
set(REQ_URL "https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1k.tar.gz")
set(MD5 "bdd51a68ad74618dd2519da8e0bcc759")
endif()

if(BUILD_LITE)
set(OPENSSL_PATCH_ROOT ${TOP_DIR}/third_party/patch/openssl)
else()
set(OPENSSL_PATCH_ROOT ${CMAKE_SOURCE_DIR}/third_party/patch/openssl)
endif()

if(BUILD_LITE)
if(PLATFORM_ARM64 AND ANDROID_NDK_TOOLCHAIN_INCLUDED)
set(openssl_USE_STATIC_LIBS OFF)
set(ANDROID_NDK_ROOT $ENV{ANDROID_NDK})
set(PATH
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin:
${ANDROID_NDK_ROOT}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:
$ENV{PATH})
mindspore_add_pkg(openssl
VER 1.1.1k
LIBS ssl crypto
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./Configure android-arm64 -D__ANDROID_API__=29 no-zlib
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)
elseif(PLATFORM_ARM32 AND ANDROID_NDK_TOOLCHAIN_INCLUDED)
set(ANDROID_NDK_ROOT $ENV{ANDROID_NDK})
set(PATH
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin:
${ANDROID_NDK_ROOT}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:
$ENV{PATH})
mindspore_add_pkg(openssl
VER 1.1.1k
LIBS ssl crypto
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./Configure android-arm -D__ANDROID_API__=19 no-zlib
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR APPLE)
mindspore_add_pkg(openssl
VER 1.1.1k
LIBS ssl crypto
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./config no-zlib
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)
else()
MESSAGE(FATAL_ERROR "openssl does not support compilation for the current environment.")
endif()
include_directories(${openssl_INC})
add_library(mindspore::ssl ALIAS openssl::ssl)
add_library(mindspore::crypto ALIAS openssl::crypto)
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR APPLE)
mindspore_add_pkg(openssl
VER 1.1.1k
LIBS ssl crypto
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./config no-zlib no-shared
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)
include_directories(${openssl_INC})
add_library(mindspore::ssl ALIAS openssl::ssl)
add_library(mindspore::crypto ALIAS openssl::crypto)
endif()
endif()

+ 43
- 114
cmake/external_libs/protobuf.cmake View File

@@ -1,73 +1,24 @@
set(protobuf_USE_STATIC_LIBS ON)
if(BUILD_LITE)
if(MSVC)
set(protobuf_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(protobuf_CFLAGS "${CMAKE_C_FLAGS}")
set(protobuf_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(NOT ENABLE_GLIBCXX)
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC \
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(NOT ENABLE_GLIBCXX)
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
mindspore_add_pkg(protobuf
VER 3.8.0
HEAD_ONLY ./
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz
MD5 3d9e32700639618a4d2d342c99d4507a)


set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf test")
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Gen shared library")
set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})

string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_subdirectory(${protobuf_DIRPATH}/cmake ${protobuf_DIRPATH}/build)


if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.13.0.tar.gz")
set(MD5 "53ab10736257b3c61749de9800b8ce97")
else()
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz")
set(MD5 "1a6274bc4a65b55a6fa70e264d796490")
endif()
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})


if(BUILD_LITE)
set(PROTOBUF_PATCH_ROOT ${TOP_DIR}/third_party/patch/protobuf)
else()
set(PROTOBUF_PATCH_ROOT ${CMAKE_SOURCE_DIR}/third_party/patch/protobuf)
endif()
set(PROTOBUF_LIBRARY protobuf::libprotobuf)
include_directories(${protobuf_DIRPATH}/src)
add_library(mindspore::protobuf ALIAS libprotobuf)


mindspore_add_pkg(protobuf
VER 3.13.0
LIBS protobuf
EXE protoc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PATH cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
PATCHES ${PROTOBUF_PATCH_ROOT}/CVE-2021-22570.patch)

include_directories(${protobuf_INC})
add_library(mindspore::protobuf ALIAS protobuf::protobuf)
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
if(MSVC)
set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX})
endif()

function(common_protobuf_generate path c_var h_var)
function(ms_protobuf_generate c_var h_var)
if(NOT ARGN) if(NOT ARGN)
message(SEND_ERROR "Error: ms_protobuf_generate() called without any proto files") message(SEND_ERROR "Error: ms_protobuf_generate() called without any proto files")
return() return()
@@ -82,30 +33,23 @@ function(common_protobuf_generate path c_var h_var)
get_filename_component(file_dir ${abs_file} PATH) get_filename_component(file_dir ${abs_file} PATH)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir}) file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})


list(APPEND ${c_var} "${path}/${file_name}.pb.cc")
list(APPEND ${h_var} "${path}/${file_name}.pb.h")
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.h")

add_custom_command( add_custom_command(
OUTPUT "${path}/${file_name}.pb.cc" "${path}/${file_name}.pb.h"
OUTPUT "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${path}"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${path} ${abs_file}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/${rel_path}"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
DEPENDS protobuf::protoc ${abs_file} DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM )
endforeach() endforeach()


set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE)
set(${c_var} ${${c_var}} PARENT_SCOPE) set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE) set(${h_var} ${${h_var}} PARENT_SCOPE)
endfunction()


function(ms_protobuf_generate c_var h_var)
if(NOT ENABLE_CLOUD_AND_LITE)
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto ${c_var} ${h_var} ${ARGN})
else()
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto/lite ${c_var} ${h_var} ${ARGN})
endif()
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
endfunction() endfunction()


function(ms_protobuf_generate_py c_var h_var py_var) function(ms_protobuf_generate_py c_var h_var py_var)
@@ -122,46 +66,31 @@ function(ms_protobuf_generate_py c_var h_var py_var)
get_filename_component(abs_file ${file} ABSOLUTE) get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE) get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH) get_filename_component(file_dir ${abs_file} PATH)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})


list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.h")
list(APPEND ${py_var} "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py")


list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h")
list(APPEND ${py_var} "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py")
if(WIN32)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND perl -pi.bak -e "s/import (.+_pb2.*)/from . import \\1/"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
else()
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
COMMAND cp "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
endif()
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/${rel_path}/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/${rel_path}"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/${rel_path} ${abs_file}
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/" "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py"
COMMAND cp "${CMAKE_BINARY_DIR}/${rel_path}/${file_name}_pb2.py" "${PROJECT_SOURCE_DIR}/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM )
endforeach() endforeach()

set_source_files_properties(${${c_var}} ${${h_var}} ${${py_var}} PROPERTIES GENERATED TRUE) set_source_files_properties(${${c_var}} ${${h_var}} ${${py_var}} PROPERTIES GENERATED TRUE)
set(${c_var} ${${c_var}} PARENT_SCOPE) set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE) set(${h_var} ${${h_var}} PARENT_SCOPE)
set(${py_var} ${${py_var}} PARENT_SCOPE) set(${py_var} ${${py_var}} PARENT_SCOPE)

endfunction() endfunction()

+ 0
- 73
cmake/external_libs/protobuf_arm.cmake View File

@@ -1,73 +0,0 @@
set(protobuf_arm_USE_STATIC_LIBS ON)
if(BUILD_LITE)
if(MSVC)
set(protobuf_arm_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(protobuf_arm_CFLAGS "${CMAKE_C_FLAGS}")
set(protobuf_arm_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
else()
set(protobuf_arm_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(NOT ENABLE_GLIBCXX)
set(protobuf_arm_CXXFLAGS "${protobuf_arm_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(protobuf_arm_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(protobuf_arm_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC \
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(protobuf_arm_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
else()
set(protobuf_arm_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(NOT ENABLE_GLIBCXX)
set(protobuf_arm_CXXFLAGS "${protobuf_arm_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif()
set(protobuf_arm_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()

set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.13.0.tar.gz")
set(MD5 "53ab10736257b3c61749de9800b8ce97")
else()
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz")
set(MD5 "1a6274bc4a65b55a6fa70e264d796490")
endif()

if(BUILD_LITE)
set(PROTOBUF_PATCH_ROOT ${TOP_DIR}/third_party/patch/protobuf)
else()
set(PROTOBUF_PATCH_ROOT ${CMAKE_SOURCE_DIR}/third_party/patch/protobuf)
endif()

mindspore_add_pkg(protobuf_arm
VER 3.13.0
LIBS protobuf
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PATH cmake/
CMAKE_OPTION
-Dprotobuf_BUILD_TESTS=OFF
-Dprotobuf_BUILD_SHARED_LIBS=OFF
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-Dprotobuf_WITH_ZLIB=OFF
PATCHES ${PROTOBUF_PATCH_ROOT}/CVE-2021-22570.patch)

include_directories(${protobuf_arm_INC})
add_library(mindspore::protobuf_arm ALIAS protobuf_arm::protobuf)
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
if(MSVC)
set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX})
endif()

+ 3
- 52
cmake/external_libs/pybind11.cmake View File

@@ -1,60 +1,11 @@
set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})

if(ENABLE_GITEE)
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "cd04f7bd275fedb97e8b583c115769e6")
elseif(PYTHON_VERSION MATCHES "3.8")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "cd04f7bd275fedb97e8b583c115769e6")
elseif(PYTHON_VERSION MATCHES "3.7")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.4.3.tar.gz")
set(MD5 "8f69438201bc824c63e5774bf8c1d422")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
else()
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION MATCHES "3.8")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION MATCHES "3.7")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz")
set(MD5 "62254c40f89925bb894be421fe4cdef2")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
endif()
set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")

if(PYTHON_VERSION MATCHES "3.9")
mindspore_add_pkg(pybind11
VER 2.6.1
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
elseif(PYTHON_VERSION MATCHES "3.8")
mindspore_add_pkg(pybind11
VER 2.6.1
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
else()
mindspore_add_pkg(pybind11
mindspore_add_pkg(pybind11
VER 2.4.3 VER 2.4.3
URL ${REQ_URL}
MD5 ${MD5}
URL https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz
MD5 62254c40f89925bb894be421fe4cdef2
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
) )
endif()

include_directories(${pybind11_INC}) include_directories(${pybind11_INC})
find_package(pybind11 REQUIRED) find_package(pybind11 REQUIRED)
set_property(TARGET pybind11::module PROPERTY IMPORTED_GLOBAL TRUE) set_property(TARGET pybind11::module PROPERTY IMPORTED_GLOBAL TRUE)


+ 6
- 0
cmake/external_libs/rang.cmake View File

@@ -0,0 +1,6 @@

mindspore_add_pkg(rang
VER 3.1.0
HEAD_ONLY ./
URL https://github.com/agauniyal/rang/archive/cabe04d6d6b05356fa8f9741704924788f0dd762.zip
MD5 0c5c9b251fea9ee7ce32f188655be0ea)

+ 0
- 22
cmake/external_libs/re2.cmake View File

@@ -1,22 +0,0 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/re2/repository/archive/2019-12-01.tar.gz")
set(MD5 "527eab0c75d6a1a0044c6eefd816b2fb")
else()
set(REQ_URL "https://github.com/google/re2/archive/2019-12-01.tar.gz")
set(MD5 "527eab0c75d6a1a0044c6eefd816b2fb")
endif()

if(NOT ENABLE_GLIBCXX)
set(re2_CXXFLAGS "${re2_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()

mindspore_add_pkg(re2
VER 20191201
LIBS re2
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE)

include_directories(${re2_INC})
add_library(mindspore::re2 ALIAS re2::re2)


+ 0
- 58
cmake/external_libs/sentencepiece.cmake View File

@@ -1,58 +0,0 @@
if(ENABLE_GITEE_EULER)
set(GIT_REPOSITORY "https://gitee.com/src-openeuler/sentencepiece.git")
set(GIT_TAG "master")
set(MD5 "4f88df28544b5f1a351f3dbf6b6413b8")
set(SENTENCEPIECE_SRC "${TOP_DIR}/build/mindspore/_deps/sentencepiece-src")
__download_pkg_with_git(sentencepiece ${GIT_REPOSITORY} ${GIT_TAG} ${MD5})
execute_process(COMMAND tar -xf ${SENTENCEPIECE_SRC}/v0.1.92.tar.gz --strip-components 1 -C ${SENTENCEPIECE_SRC})
else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/sentencepiece/repository/archive/v0.1.92.tar.gz")
set(MD5 "0fc99de9f09b9184398f49647791799f")
else()
set(REQ_URL "https://github.com/google/sentencepiece/archive/v0.1.92.tar.gz")
set(MD5 "5dfd2241914b5598a68b2a8542ed8e91")
endif()
endif()


if(WIN32)
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-stringop-overflow \
-Wno-format-extra-args -Wno-format")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
MD5 ${MD5}
)
else()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-sign-compare")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
if(ENABLE_GLIBCXX)
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=OFF -DSPM_ENABLE_SHARED=OFF
-DPROTOBUF_INC=${protobuf_INC} -DCMAKE_CXX_STANDARD=11
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001_cpu
)
else()
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=OFF -DSPM_ENABLE_SHARED=OFF
-DPROTOBUF_INC=${protobuf_INC}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001
)
endif()
endif()
include_directories(${sentencepiece_INC})
add_library(mindspore::sentencepiece ALIAS sentencepiece::sentencepiece)
add_library(mindspore::sentencepiece_train ALIAS sentencepiece::sentencepiece_train)


+ 10
- 35
cmake/external_libs/sqlite.cmake View File

@@ -1,40 +1,15 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/sqlite/repository/archive/version-3.36.0.tar.gz")
set(MD5 "715df9c2d2ccf6207158d6c087f711cf")
else()
set(REQ_URL "https://github.com/sqlite/sqlite/archive/version-3.36.0.tar.gz")
set(MD5 "715df9c2d2ccf6207158d6c087f711cf")
endif()


set(sqlite_USE_STATIC_LIBS ON)
set(sqlite_CXXFLAGS)
set(sqlite_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(sqlite_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")


if(WIN32)
mindspore_add_pkg(sqlite
VER 3.36.0
mindspore_add_pkg(sqlite
VER 3.31.1
LIBS sqlite3 LIBS sqlite3
URL https://sqlite.org/2021/sqlite-amalgamation-3360000.zip
MD5 c5d360c74111bafae1b704721ff18fe6
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.windows.patch002
CMAKE_OPTION " "
)

else()
set(sqlite_USE_STATIC_LIBS ON)
set(sqlite_CXXFLAGS)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(sqlite_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
-O2")
else()
set(sqlite_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
-D_FORTIFY_SOURCE=2 -O2")
set(sqlite_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
mindspore_add_pkg(sqlite
VER 3.36.0
LIBS sqlite3
URL ${REQ_URL}
MD5 ${MD5}
URL https://github.com/sqlite/sqlite/archive/version-3.31.1.tar.gz
MD5 5f4e7b4016c15f4fb5855615279819da
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.patch001
CONFIGURE_COMMAND ./configure --enable-shared=no --disable-tcl --disable-editline --enable-json1) CONFIGURE_COMMAND ./configure --enable-shared=no --disable-tcl --disable-editline --enable-json1)
endif()

include_directories(${sqlite_INC}) include_directories(${sqlite_INC})
add_library(mindspore::sqlite ALIAS sqlite::sqlite3)
add_library(mindspore::sqlite ALIAS sqlite::sqlite3)

+ 0
- 24
cmake/external_libs/tinyxml2.cmake View File

@@ -1,24 +0,0 @@
set(tinyxml2_CXXFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result")
set(tinyxml2_CFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2")

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/tinyxml2/repository/archive/8.0.0.tar.gz")
set(MD5 "5dc535c8b34ee621fe2128f072d275b5")
else()
set(REQ_URL "https://github.com/leethomason/tinyxml2/archive/8.0.0.tar.gz")
set(MD5 "5dc535c8b34ee621fe2128f072d275b5")
endif()


if(NOT WIN32 AND NOT APPLE)
set(tinyxml2_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()

mindspore_add_pkg(tinyxml2
VER 8.0.0
LIBS tinyxml2
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release
MD5 ${MD5})
include_directories(${tinyxml2_INC})
add_library(mindspore::tinyxml2 ALIAS tinyxml2::tinyxml2)

+ 8
- 0
cmake/external_libs/tvm_gpu.cmake View File

@@ -0,0 +1,8 @@
set(incubator_tvm_gpu_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(incubator_tvm_gpu_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(incubator_tvm_gpu
VER 0.6.0
HEAD_ONLY ./
URL https://github.com/apache/incubator-tvm/archive/v0.6.0.tar.gz
MD5 9cbbd32545a776023acabbba270449fe)


+ 10
- 0
cmake/external_libs/tvm_predict.cmake View File

@@ -0,0 +1,10 @@
set(incubator_tvm_predict_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(incubator_tvm_predict_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(incubator_tvm_predict
VER 0.6.0
HEAD_ONLY ./
URL https://github.com/apache/incubator-tvm/release/download/v0.6.0/apache-tvm-src-v0.6.0-incubating.tar.gz
MD5 2d77a005f0046d937b99c67de82f6438
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/predict/0001-RetBugFix-CustomRuntime_v06.patch)
include_directories(${incubator_tvm_predict_INC})
add_library(mindspore::incubator_tvm_predict ALIAS incubator_tvm_predict)

+ 0
- 17
cmake/external_libs/zlib.cmake View File

@@ -1,17 +0,0 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/zlib/repository/archive/v1.2.11.tar.gz")
set(MD5 "b0ecd8eda7c5d6ed9b4a4187363482fe")
else()
set(REQ_URL "https://github.com/madler/zlib/archive/v1.2.11.tar.gz")
set(MD5 "0095d2d2d1f3442ce1318336637b695f")
endif()

mindspore_add_pkg(zlib
VER 1.2.11
LIBS z
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release)

include_directories(${zlib_INC})
add_library(mindspore::z ALIAS zlib::z)

+ 0
- 361
cmake/lite_ios.cmake View File

@@ -1,361 +0,0 @@
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)

set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR" FORCE)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.3")
set(MODERN_CMAKE YES)
message(STATUS "Merging integrated CMake 3.18.3+ iOS toolchain(s) with this toolchain!")
endif()

# Get the Xcode version
execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")

set(FORCE_CACHE FORCE)
get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
if(_CMAKE_IN_TRY_COMPILE)
unset(FORCE_CACHE)
endif()

if(NOT DEFINED PLATFORM)
if(CMAKE_OSX_ARCHITECTURES)
if(CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*" AND CMAKE_OSX_SYSROOT MATCHES ".*iphoneos.*")
set(PLATFORM "OS")
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*")
set(PLATFORM "SIMULATOR")
endif()
endif()
if(NOT PLATFORM)
set(PLATFORM "OS")
endif()
endif()

set(PLATFORM_INT "${PLATFORM}" CACHE STRING "Type of platform for which the build targets.")

if(PLATFORM_INT STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
set(PLATFORM_INT "OS64")
message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
elseif(PLATFORM_INT STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
set(PLATFORM_INT "SIMULATOR64")
message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
endif()

if(PLATFORM_INT STREQUAL "OS")
set(SDK_NAME iphoneos)
if(NOT ARCHS)
set(ARCHS armv7 armv7s arm64)
endif()
elseif(PLATFORM_INT STREQUAL "OS64")
set(SDK_NAME iphoneos)
if(NOT ARCHS)
if(XCODE_VERSION VERSION_GREATER 10.0)
set(ARCHS arm64)
else()
set(ARCHS arm64)
endif()
endif()
elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
set(SDK_NAME iphoneos)
if(MODERN_CMAKE)
if(NOT ARCHS)
if(XCODE_VERSION VERSION_GREATER 10.0)
set(ARCHS arm64 x86_64)
else()
set(ARCHS arm64 x86_64)
endif()
endif()
else()
message(FATAL_ERROR "Please make sure that you are running CMake 3.18.3+ to make the OS64COMBINED setting work")
endif()
elseif(PLATFORM_INT STREQUAL "SIMULATOR")
set(SDK_NAME iphonesimulator)
if(NOT ARCHS)
set(ARCHS i386)
endif()
message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.")
elseif(PLATFORM_INT STREQUAL "SIMULATOR64")
set(SDK_NAME iphonesimulator)
if(NOT ARCHS)
set(ARCHS x86_64)
endif()
else()
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
endif()
message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}")

if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode")
endif()

execute_process(COMMAND xcodebuild -version -sdk ${SDK_NAME} Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT)
message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
"is pointing to the correct path. Please run:"
"sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
"and see if that fixes the problem for you.")
message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
"does not exist.")
elseif(DEFINED CMAKE_OSX_SYSROOT)
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${PLATFORM_INT} when checking compatibility")
elseif(DEFINED CMAKE_OSX_SYSROOT_INT)
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT} for platform: ${PLATFORM_INT}")
set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
endif()

if(USED_CMAKE_GENERATOR MATCHES "Xcode")
set(CMAKE_OSX_SYSROOT "${SDK_NAME}" CACHE INTERNAL "")
endif()

if(NOT DEFINED DEPLOYMENT_TARGET)
set(DEPLOYMENT_TARGET "9.0" CACHE STRING "Minimum SDK version to build for.")
message(STATUS "Using the default min-version since DEPLOYMENT_TARGET not provided!")
endif()
if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+")
message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!")
set(ENABLE_BITCODE TRUE)
elseif(NOT DEFINED ENABLE_BITCODE)
message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
set(ENABLE_BITCODE FALSE)
endif()
set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL "Whether or not to enable bitcode" ${FORCE_CACHE})
if(NOT DEFINED ENABLE_ARC)
set(ENABLE_ARC TRUE)
message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
endif()
set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" ${FORCE_CACHE})
if(NOT DEFINED ENABLE_VISIBILITY)
set(ENABLE_VISIBILITY FALSE)
message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
endif()
set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL
"Whether or not to hide symbols (-fvisibility=hidden)" ${FORCE_CACHE})
# Set strict compiler checks or not
if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE)
set(ENABLE_STRICT_TRY_COMPILE FALSE)
message(STATUS "Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!")
endif()
set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL
"Whether or not to use strict compiler checks" ${FORCE_CACHE})
# Get the SDK version information.
execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
OUTPUT_VARIABLE SDK_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH)

if(NOT DEFINED CMAKE_DEVELOPER_ROOT)
message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: "
"${CMAKE_DEVELOPER_ROOT} does not exist.")
endif()
endif()
if(NOT CMAKE_C_COMPILER)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
OUTPUT_VARIABLE CMAKE_C_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
endif()
if(NOT CMAKE_CXX_COMPILER)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
endif()
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
OUTPUT_VARIABLE BUILD_LIBTOOL
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using libtool: ${BUILD_LIBTOOL}")


set(CMAKE_C_CREATE_STATIC_LIBRARY
"${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
"${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")

if(NOT CMAKE_INSTALL_NAME_TOOL)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find install_name_tool
OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE STRING "" ${FORCE_CACHE})
message(STATUS "Using install_name_tool: ${CMAKE_INSTALL_NAME_TOOL}")
endif()

execute_process(COMMAND uname -r
OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(MODERN_CMAKE)
if(SDK_NAME MATCHES "iphone")
set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE})
endif()

if(PLATFORM_INT MATCHES ".*COMBINED")
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO CACHE INTERNAL "" ${FORCE_CACHE})
set(CMAKE_IOS_INSTALL_COMBINED YES CACHE INTERNAL "" ${FORCE_CACHE})
message(STATUS "Will combine built (static) artifacts into FAT lib...")
endif()
else()
set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "" ${FORCE_CACHE})
endif()
set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
set(UNIX TRUE CACHE BOOL "")
set(APPLE TRUE CACHE BOOL "")
set(IOS TRUE CACHE BOOL "")
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE)
set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS")
if(ENABLE_STRICT_TRY_COMPILE_INT)
message(STATUS "Using strict compiler checks (default in CMake).")
else()
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
endif()
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
set(CMAKE_SHARED_MODULE_PREFIX "lib")
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
set(CMAKE_C_COMPILER_ABI ELF)
set(CMAKE_CXX_COMPILER_ABI ELF)
set(CMAKE_C_HAS_ISYSROOT 1)
set(CMAKE_CXX_HAS_ISYSROOT 1)
set(CMAKE_MODULE_EXISTS 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")

if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+")
set(CMAKE_C_SIZEOF_DATA_PTR 8)
set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+")
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
else()
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
endif()
message(STATUS "Using a data_ptr size of 8")
else()
set(CMAKE_C_SIZEOF_DATA_PTR 4)
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
set(CMAKE_SYSTEM_PROCESSOR "arm")
message(STATUS "Using a data_ptr size of 4")
endif()

message(STATUS "Building for minimum ${SDK_NAME} version: ${DEPLOYMENT_TARGET} (SDK version: ${SDK_VERSION})")

if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64")
if(XCODE_VERSION VERSION_LESS 7.0)
set(SDK_NAME_VERSION_FLAGS "-mios-version-min=${DEPLOYMENT_TARGET}")
else()
set(SDK_NAME_VERSION_FLAGS "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}")
endif()
else()
set(SDK_NAME_VERSION_FLAGS "-mios-simulator-version-min=${DEPLOYMENT_TARGET}")
endif()
message(STATUS "Version flags set to: ${SDK_NAME_VERSION_FLAGS}")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE STRING "Set CMake deployment target" ${FORCE_CACHE})

if(ENABLE_BITCODE_INT)
set(BITCODE "-fembed-bitcode")
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode CACHE INTERNAL "")
message(STATUS "Enabling bitcode support.")
else()
set(BITCODE "")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO CACHE INTERNAL "")
message(STATUS "Disabling bitcode support.")
endif()

if(ENABLE_ARC_INT)
set(FOBJC_ARC "-fobjc-arc")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES CACHE INTERNAL "")
message(STATUS "Enabling ARC support.")
else()
set(FOBJC_ARC "-fno-objc-arc")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO CACHE INTERNAL "")
message(STATUS "Disabling ARC support.")
endif()

if(NOT ENABLE_VISIBILITY_INT)
set(VISIBILITY "-fvisibility=hidden")
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES CACHE INTERNAL "")
message(STATUS "Hiding symbols (-fvisibility=hidden).")
else()
set(VISIBILITY "")
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN NO CACHE INTERNAL "")
endif()

if(USED_CMAKE_GENERATOR MATCHES "Xcode")
message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.")
else()
set(CMAKE_C_FLAGS "${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS
"${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY}
-fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
set(CMAKE_CXX_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")

list(APPEND VARS_TO_FORCE_IN_CACHE
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_LINK_FLAGS
CMAKE_CXX_LINK_FLAGS)
foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "")
endforeach()
endif()

set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")

set(CMAKE_FIND_ROOT_PATH
${CMAKE_OSX_SYSROOT_INT} ${CMAKE_PREFIX_PATH}
CACHE STRING "Root path that will be prepended to all search paths")

set(CMAKE_FIND_FRAMEWORK FIRST)

set(CMAKE_FRAMEWORK_PATH
${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks
${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks
${CMAKE_FRAMEWORK_PATH} CACHE STRING "Frameworks search paths" ${FORCE_CACHE})

if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE STRING "" ${FORCE_CACHE})
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE STRING "" ${FORCE_CACHE})
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE STRING "" ${FORCE_CACHE})
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY CACHE STRING "" ${FORCE_CACHE})
endif()

+ 22
- 49
cmake/mind_expression.cmake View File

@@ -1,34 +1,15 @@
set(SECURE_CXX_FLAGS "") set(SECURE_CXX_FLAGS "")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(WIN32)
set(SECURE_CXX_FLAGS "-fstack-protector-all")
else()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(SECURE_CXX_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") set(SECURE_CXX_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
endif()
endif() endif()
set(_ms_tmp_CMAKE_CXX_FLAGS_F ${CMAKE_CXX_FLAGS}) set(_ms_tmp_CMAKE_CXX_FLAGS_F ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
set(TOP_DIR ${CMAKE_SOURCE_DIR})


include(cmake/utils.cmake) include(cmake/utils.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/eigen.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/eigen.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/json.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/json.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec.cmake) include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake)

if(MS_BUILD_GRPC)
# build dependencies of gRPC
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/openssl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/absl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/c-ares.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/zlib.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/re2.cmake)
# build gRPC
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/grpc.cmake)
# build event
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libevent.cmake)
endif()

include(${CMAKE_SOURCE_DIR}/cmake/external_libs/pybind11.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/pybind11.cmake)
MESSAGE("go to link flatbuffers") MESSAGE("go to link flatbuffers")
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/flatbuffers.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/flatbuffers.cmake)
@@ -39,48 +20,40 @@ endif()
find_package(Python3) find_package(Python3)
include_directories(${Python3_INCLUDE_DIRS}) include_directories(${Python3_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/third_party) include_directories(${CMAKE_SOURCE_DIR}/third_party)
if(ENABLE_MPI)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/ompi.cmake)
if (ENABLE_CPU)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/mkl_dnn.cmake)
endif() endif()


if(ENABLE_CPU)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/mkl_dnn.cmake)
if (ENABLE_GPU)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/dlpack.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/dmlc_core.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/rang.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/tvm_gpu.cmake)
endif() endif()


if(ENABLE_GPU)
if(ENABLE_MPI)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/nccl.cmake)
endif()
if (ENABLE_MPI)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/nccl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/ompi.cmake)
endif() endif()


if(ENABLE_D OR ENABLE_ACL OR ENABLE_TESTCASES)
if (ENABLE_GE)
include_directories(${CMAKE_SOURCE_DIR}/third_party/ge/include)
include_directories(${CMAKE_SOURCE_DIR}/third_party/ge/include/external)
include_directories(${CMAKE_SOURCE_DIR}/third_party/ge/include/external/graph)
else()
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc) include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/ops)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/external) include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/external)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/framework)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc/aicpu)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/third_party/fwkacllib/inc/toolchain)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/metadef/inc)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/metadef/inc/external)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/metadef/inc/external/graph)
include_directories(${CMAKE_SOURCE_DIR}/graphengine/inc/external/graph)
endif() endif()


if(ENABLE_MINDDATA)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/icu4c.cmake)
if (ENABLE_MINDDATA)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/jpeg_turbo.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libtiff.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libtiff.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/opencv.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/opencv.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/sqlite.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/sqlite.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/tinyxml2.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/cppjieba.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/sentencepiece.cmake)
endif()

if(ENABLE_MINDDATA)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/jpeg_turbo.cmake)
endif()

if(ENABLE_TESTCASES OR ENABLE_CPP_ST)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/gtest.cmake)
endif() endif()


include(${CMAKE_SOURCE_DIR}/cmake/external_libs/gtest.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/onnx.cmake)
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS_F}) set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS_F})

+ 36
- 96
cmake/options.cmake View File

@@ -1,169 +1,109 @@
option(ENABLE_D "Enable d" OFF) option(ENABLE_D "Enable d" OFF)
option(ENABLE_GPU "Enable gpu" OFF) option(ENABLE_GPU "Enable gpu" OFF)
option(ENABLE_CPU "Enable cpu" OFF) option(ENABLE_CPU "Enable cpu" OFF)
option(ENABLE_GE "Enable graph engine as backend to execute" OFF)
option(ENABLE_MINDDATA "Enable minddata compile" OFF) option(ENABLE_MINDDATA "Enable minddata compile" OFF)
option(ENABLE_TRAIN "Enable ge train, default off(only infer)" OFF)
option(ENABLE_TESTCASES "Run testcases switch, default off" OFF) option(ENABLE_TESTCASES "Run testcases switch, default off" OFF)
option(ENABLE_CPP_ST "Run cpp st testcases switch, default off" OFF)
option(DEBUG_MODE "Debug mode, default off" OFF) option(DEBUG_MODE "Debug mode, default off" OFF)
option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs") option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs")
option(ENABLE_LOAD_ANF_IR "Enable load ANF-IR as input of 'infer' stage of pipeline" OFF) option(ENABLE_LOAD_ANF_IR "Enable load ANF-IR as input of 'infer' stage of pipeline" OFF)
option(ENABLE_COVERAGE "Enable code coverage report" OFF) option(ENABLE_COVERAGE "Enable code coverage report" OFF)
option(USE_GLOG "Use glog to output log" OFF) option(USE_GLOG "Use glog to output log" OFF)
option(ENABLE_SECURITY "Enable security, maintenance function will be disabled, default off" OFF)
option(ENABLE_PROFILE "Enable pipeline profile, default off" OFF) option(ENABLE_PROFILE "Enable pipeline profile, default off" OFF)
option(ENABLE_TIMELINE "Enable time line record" OFF) option(ENABLE_TIMELINE "Enable time line record" OFF)
option(ENABLE_DUMP_PROTO "Enable dump anf graph to file in ProtoBuffer format, default on" ON) option(ENABLE_DUMP_PROTO "Enable dump anf graph to file in ProtoBuffer format, default on" ON)
option(ENABLE_DUMP_IR "Enable dump function graph ir, default on" ON)
option(ENABLE_DUMP_E2E "Enable dump e2e file, default on" OFF)
option(ENABLE_DUMP_IR "Enable dump funciton graph ir, default on" ON)
option(ENABLE_MPI "enable mpi" OFF) option(ENABLE_MPI "enable mpi" OFF)
option(ENABLE_AKG "enable akg" OFF) option(ENABLE_AKG "enable akg" OFF)
option(ENABLE_DEBUGGER "enable debugger" OFF)
option(ENABLE_IBVERBS "enable IBVERBS for parameter server" OFF)
option(ENABLE_PYTHON "Enable python" ON)
option(ENABLE_ACL "enable acl" OFF)
option(ENABLE_GLIBCXX "enable_glibcxx" OFF)
option(MODE_ASCEND_ALL "supports all ascend platform" OFF)
option(MODE_ASCEND_ACL "supports ascend acl mode only" OFF)
option(ENABLE_SYM_FILE "enable sym file" OFF)
option(BUILD_DEV_MODE "MindSpore build nightly dev mode" OFF)
option(ENABLE_FAST_HASH_TABLE "Enable use fast hash table instead of std ones" ON)
option(USE_LLVM "use llvm" OFF)
option(USE_MS_THREADPOOL_FOR_DNNL "use ms threadpool for onednn ops" ON)

if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
set(USE_MS_THREADPOOL_FOR_DNNL OFF)
endif()

if(NOT ENABLE_D AND NOT ENABLE_TESTCASES AND NOT ENABLE_ACL)
set(ENABLE_GLIBCXX ON)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(WIN32)
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all")
else()
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
endif() endif()


if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Wsign-compare") set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Wsign-compare")
endif() endif()


if(ENABLE_COVERAGE)
if (ENABLE_COVERAGE)
set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage") set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
endif() endif()


if(ENABLE_ASAN)
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer")
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -static-libsan")
if (ENABLE_ASAN)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -static-libasan -fsanitize=undefined")
else()
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -static-libsan -fsanitize=undefined")
endif() endif()
endif() endif()


if(DEBUG_MODE)
if (DEBUG_MODE)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Debug")
add_compile_definitions(MEM_REUSE_DEBUG)
else() else()
add_compile_definitions(MEM_REUSE_DEBUG)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif()


if((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") OR (CMAKE_BUILD_TYPE STREQUAL Release))
if ((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") OR (CMAKE_BUILD_TYPE STREQUAL Release))
set(PYBIND11_LTO_CXX_FLAGS FALSE) set(PYBIND11_LTO_CXX_FLAGS FALSE)
endif() endif()


if(NOT BUILD_PATH)
if (NOT BUILD_PATH)
set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build")
endif() endif()


if(ENABLE_D)
if (ENABLE_GE OR ENABLE_D)
set(ENABLE_TDTQUE ON) set(ENABLE_TDTQUE ON)
endif() endif()


if(ENABLE_GPU)
if (ENABLE_GPU)
set(ENABLE_GPUQUE ON) set(ENABLE_GPUQUE ON)
add_compile_definitions(ENABLE_GPU_COLLECTIVE)
endif() endif()


if(ENABLE_CPU)
add_compile_definitions(ENABLE_CPU)
if (ENABLE_GE)
add_compile_definitions(ENABLE_GE)
add_compile_definitions(CUSTOM_OP)
endif() endif()


if(ENABLE_D)
add_compile_definitions(ENABLE_D)
add_compile_definitions(CUSTOM_OP)
if(ENABLE_TRAIN)
add_compile_definitions(ENABLE_TRAIN=1)
else()
add_compile_definitions(ENABLE_TRAIN=0)
endif() endif()


if(USE_GLOG) if(USE_GLOG)
add_compile_definitions(USE_GLOG) add_compile_definitions(USE_GLOG)
endif() endif()


if(ENABLE_PROFILE)
if (ENABLE_PROFILE)
add_compile_definitions(ENABLE_PROFILE) add_compile_definitions(ENABLE_PROFILE)
endif() endif()


if(ENABLE_SECURITY)
add_compile_definitions(ENABLE_SECURITY)
endif()

if(ENABLE_TIMELINE)
if (ENABLE_TIMELINE)
add_compile_definitions(ENABLE_TIMELINE) add_compile_definitions(ENABLE_TIMELINE)
endif() endif()


if(ENABLE_LOAD_ANF_IR)
if (ENABLE_LOAD_ANF_IR)
add_compile_definitions(ENABLE_LOAD_ANF_IR) add_compile_definitions(ENABLE_LOAD_ANF_IR)
endif() endif()


if(ENABLE_TESTCASES)
add_compile_definitions(ENABLE_TEST)
endif()

if(ENABLE_TESTCASES OR (NOT ENABLE_D))
if (ENABLE_TESTCASES OR (NOT ENABLE_D AND NOT ENABLE_GE))
add_compile_definitions(NO_DLIB=1) add_compile_definitions(NO_DLIB=1)
endif() endif()


if(ENABLE_DUMP_IR) if(ENABLE_DUMP_IR)
add_compile_definitions(ENABLE_DUMP_IR) add_compile_definitions(ENABLE_DUMP_IR)
endif()
endif(ENABLE_DUMP_IR)


if(ENABLE_MINDDATA) if(ENABLE_MINDDATA)
add_compile_definitions(ENABLE_MINDDATA) add_compile_definitions(ENABLE_MINDDATA)
if(ENABLE_TDTQUE)
if (ENABLE_TDTQUE)
add_compile_definitions(ENABLE_TDTQUE) add_compile_definitions(ENABLE_TDTQUE)
endif() endif()
endif() endif()


if(ENABLE_DEBUGGER)
add_compile_definitions(ENABLE_DEBUGGER)
endif()

if(ENABLE_DEBUGGER OR ENABLE_TESTCASES)
set(MS_BUILD_GRPC ON)
endif()
if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
set(MS_BUILD_GRPC ON)
endif()

if(ENABLE_D AND ENABLE_ACL)
set(MODE_ASCEND_ALL ON)
endif()

if(ENABLE_ACL AND NOT ENABLE_D)
set(MODE_ASCEND_ACL ON)
endif()

if(ENABLE_CPU AND NOT WIN32)
add_compile_definitions(ENABLE_ARMOUR)
endif()

if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux")
add_compile_definitions(ENABLE_AKG)
endif()

if(USE_LLVM)
add_compile_definitions(USE_LLVM)
endif()

if(USE_MS_THREADPOOL_FOR_DNNL)
add_compile_definitions(USE_MS_THREADPOOL_FOR_DNNL)
endif()
if(ENABLE_DUMP_E2E)
add_compile_definitions(ENABLE_DUMP_E2E)
endif()

+ 0
- 392
cmake/package.cmake View File

@@ -1,392 +0,0 @@
# include dependency
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# set package information
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR "External")
set(CPACK_CMAKE_GENERATOR "Ninja")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
set(CPACK_EXTERNAL_ENABLE_STAGING true)
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${BUILD_PATH}/package/mindspore)
set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${BUILD_PATH}/package/mindspore)
set(CPACK_PACK_ROOT_DIR ${BUILD_PATH}/package/)
set(CPACK_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(CPACK_ENABLE_SYM_FILE ${ENABLE_SYM_FILE})
set(CPACK_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
set(CPACK_PYTHON_EXE ${Python3_EXECUTABLE})
set(CPACK_PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})

if(ENABLE_GPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "gpu or cpu")
if(BUILD_DEV_MODE)
# providing cuda11 version of dev package only
set(CPACK_MS_PACKAGE_NAME "mindspore-cuda11-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore-gpu")
endif()
elseif(ENABLE_D)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "ascend or cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
endif()
elseif(ENABLE_CPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
elseif(ENABLE_ACL)
set(CPACK_MS_BACKEND "debug")
set(CPACK_MS_TARGET "ascend or gpu or cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore-ascend")
endif()
else()
set(CPACK_MS_BACKEND "debug")
set(CPACK_MS_TARGET "ascend or gpu or cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
endif()
include(CPack)

# set install path
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_PY_DIR ".")
set(INSTALL_BASE_DIR ".")
set(INSTALL_BIN_DIR "bin")
set(INSTALL_CFG_DIR "config")
set(INSTALL_LIB_DIR "lib")
# set package files
install(
TARGETS _c_expression
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

if(ENABLE_DEBUGGER)
install(
TARGETS _mindspore_offline_debug
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()

install(
TARGETS mindspore_shared_lib
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

install(
TARGETS mindspore_core mindspore_common mindspore_backend
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

if(USE_GLOG)
install(FILES ${glog_LIBPATH}/libmindspore_glog.so.0.4.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_glog.so.0 COMPONENT mindspore)
endif()

install(FILES ${libevent_LIBPATH}/libevent-2.1.so.7.0.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libevent-2.1.so.7 COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_core-2.1.so.7.0.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_core-2.1.so.7 COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_extra-2.1.so.7.0.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_extra-2.1.so.7 COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_openssl-2.1.so.7.0.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_openssl-2.1.so.7 COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_pthreads-2.1.so.7.0.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libevent_pthreads-2.1.so.7 COMPONENT mindspore)

if(ENABLE_MINDDATA)
install(
TARGETS _c_dataengine _c_mindrecord
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
install(
TARGETS cache_admin cache_server
OPTIONAL
DESTINATION ${INSTALL_BIN_DIR}
COMPONENT mindspore
)
endif()
install(FILES ${opencv_LIBPATH}/libopencv_core.so.4.5.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_core.so.4.5 COMPONENT mindspore)
install(FILES ${opencv_LIBPATH}/libopencv_imgcodecs.so.4.5.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgcodecs.so.4.5 COMPONENT mindspore)
install(FILES ${opencv_LIBPATH}/libopencv_imgproc.so.4.5.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgproc.so.4.5 COMPONENT mindspore)
install(FILES ${tinyxml2_LIBPATH}/libtinyxml2.so.8.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libtinyxml2.so.8 COMPONENT mindspore)

install(FILES ${icu4c_LIBPATH}/libicuuc.so.69.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libicuuc.so.69 COMPONENT mindspore)
install(FILES ${icu4c_LIBPATH}/libicudata.so.69.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libicudata.so.69 COMPONENT mindspore)
install(FILES ${icu4c_LIBPATH}/libicui18n.so.69.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libicui18n.so.69 COMPONENT mindspore)
endif()

if(ENABLE_CPU)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
install(FILES ${onednn_LIBPATH}/libdnnl.so.2.2
DESTINATION ${INSTALL_LIB_DIR} RENAME libdnnl.so.2 COMPONENT mindspore)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
install(
FILES ${DNNL_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
install(
TARGETS nnacl
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_MPI)
if(ENABLE_GPU)
install(
TARGETS _ms_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_CPU)
install(
TARGETS mpi_adapter
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS mpi_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_D)
install(
TARGETS _ascend_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
endif()

if(ENABLE_GPU)
if(ENABLE_MPI)
install(
TARGETS gpu_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS nvidia_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
install(FILES ${nccl_LIBPATH}/libnccl.so.2.7.6 DESTINATION ${INSTALL_LIB_DIR}
RENAME libnccl.so.2 COMPONENT mindspore)
endif()
endif()
install(
TARGETS gpu_queue
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS cuda_ops
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_D)
if(ENABLE_MPI)
install(
TARGETS ascend_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
endif()

if(ENABLE_CPU AND NOT WIN32)
install(
TARGETS ps_cache
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_D OR ENABLE_ACL)
if(DEFINED ENV{ASCEND_CUSTOM_PATH})
set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH})
else()
set(ASCEND_PATH /usr/local/Ascend)
endif()
set(ASCEND_DRIVER_PATH ${ASCEND_PATH}/driver/lib64/common)

if(ENABLE_D)
install(
TARGETS hccl_plugin
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
endif()

if(MS_BUILD_GRPC)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.so.1.36.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.so.1 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_gpr.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_upb.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.so.15 COMPONENT mindspore)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)

string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)

file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
install(
FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_CLOUD_AND_LITE)
install(
TARGETS mindspore-lite mslite_converter_plugin
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
install(
FILES ${MS_PY_LIST}
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)

install(
DIRECTORY
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/nn
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/_extends
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/parallel
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/mindrecord
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/numpy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/scipy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/train
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/boost
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/common
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/ops
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/communication
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/profiler
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/compression
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/rewrite
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/run_check
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)

if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux")
set (AKG_PATH ${BUILD_PATH}/mindspore/akg)
file(REMOVE_RECURSE ${AKG_PATH}/_akg)
file(MAKE_DIRECTORY ${AKG_PATH}/_akg)
file(TOUCH ${AKG_PATH}/_akg/__init__.py)
install(DIRECTORY "${AKG_PATH}/akg" DESTINATION "${AKG_PATH}/_akg")
install(
DIRECTORY
${AKG_PATH}/_akg
DESTINATION ${INSTALL_PY_DIR}/
COMPONENT mindspore
)
endif()

if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
message("offline debugger does not support windows system temporarily")
else()
if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/offline_debug)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/offline_debug
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()
endif()

## Public header files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

## Public header files for minddata
install(
FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
DESTINATION ${INSTALL_BASE_DIR}/include/dataset
COMPONENT mindspore
)

install(
FILES
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base/format.h
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base/type_id.h
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base/types.h
DESTINATION ${INSTALL_BASE_DIR}/include/mindapi/base
COMPONENT mindspore)

## config files
install(
FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
DESTINATION ${INSTALL_CFG_DIR}
COMPONENT mindspore
)


+ 0
- 1027
cmake/package_lite.cmake
File diff suppressed because it is too large
View File


+ 0
- 249
cmake/package_mac.cmake View File

@@ -1,249 +0,0 @@
# include dependency
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# set package information
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR "External")
set(CPACK_CMAKE_GENERATOR "Ninja")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
set(CPACK_EXTERNAL_ENABLE_STAGING true)
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${BUILD_PATH}/package/mindspore)
set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${BUILD_PATH}/package/mindspore)
set(CPACK_PACK_ROOT_DIR ${BUILD_PATH}/package/)
set(CPACK_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(CPACK_ENABLE_SYM_FILE ${ENABLE_SYM_FILE})
set(CPACK_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
set(CPACK_PYTHON_EXE ${Python3_EXECUTABLE})
set(CPACK_PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
set(CPACK_OSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})


if(ENABLE_CPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
else()
set(CPACK_MS_BACKEND "debug")
set(CPACK_MS_TARGET "ascend or gpu or cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore-dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
endif()
include(CPack)

# set install path
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_PY_DIR ".")
set(INSTALL_BASE_DIR ".")
set(INSTALL_BIN_DIR "bin")
set(INSTALL_CFG_DIR "config")
set(INSTALL_LIB_DIR "lib")
# set package files
install(
TARGETS _c_expression
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

if(ENABLE_DEBUGGER)
install(
TARGETS _mindspore_offline_debug
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()

install(
TARGETS mindspore_shared_lib
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

install(
TARGETS mindspore_core mindspore_common mindspore_backend
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

if(USE_GLOG)
install(FILES ${glog_LIBPATH}/libmindspore_glog.0.4.0.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_glog.0.dylib COMPONENT mindspore)
endif()

install(FILES ${libevent_LIBPATH}/libevent-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_core-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_extra-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_openssl-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)
install(FILES ${libevent_LIBPATH}/libevent_pthreads-2.1.7.dylib
DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore)

if(ENABLE_CPU AND NOT WIN32)
install(
TARGETS ps_cache
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(MS_BUILD_GRPC)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.1.36.1.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.1.dylib COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc.15.0.0.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.15.dylib COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_gpr.15.0.0.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.15.dylib COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_upb.15.0.0.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.15.dylib COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.15.0.0.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.15.dylib COMPONENT mindspore)
endif()

if(ENABLE_MINDDATA)
install(
TARGETS _c_dataengine _c_mindrecord
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

install(FILES ${opencv_LIBPATH}/libopencv_core.4.5.2.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_core.4.5.dylib COMPONENT mindspore)
install(FILES ${opencv_LIBPATH}/libopencv_imgcodecs.4.5.2.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgcodecs.4.5.dylib COMPONENT mindspore)
install(FILES ${opencv_LIBPATH}/libopencv_imgproc.4.5.2.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libopencv_imgproc.4.5.dylib COMPONENT mindspore)
install(FILES ${tinyxml2_LIBPATH}/libtinyxml2.8.0.0.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libtinyxml2.8.dylib COMPONENT mindspore)

install(FILES ${icu4c_LIBPATH}/libicuuc.69.1.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libicuuc.69.dylib COMPONENT mindspore)
install(FILES ${icu4c_LIBPATH}/libicudata.69.1.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libicudata.69.dylib COMPONENT mindspore)
install(FILES ${icu4c_LIBPATH}/libicui18n.69.1.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libicui18n.69.dylib COMPONENT mindspore)
endif()

if(ENABLE_CPU)
install(FILES ${onednn_LIBPATH}/libdnnl.2.2.dylib
DESTINATION ${INSTALL_LIB_DIR} RENAME libdnnl.2.dylib COMPONENT mindspore)
install(
TARGETS nnacl
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_MPI)
if(ENABLE_GPU)
install(
TARGETS _ms_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_CPU)
install(
TARGETS mpi_adapter
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
endif()

if(ENABLE_GPU)
if(ENABLE_MPI)
install(
TARGETS gpu_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
install(
TARGETS gpu_queue
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
install(
FILES ${MS_PY_LIST}
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)

install(
DIRECTORY
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/nn
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/_extends
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/parallel
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/mindrecord
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/numpy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/scipy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/train
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/boost
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/common
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/ops
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/communication
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/profiler
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/compression
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/rewrite
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/run_check
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)

if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()

if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/offline_debug)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/offline_debug
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()

## Public header files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

## Public header files for minddata
install(
FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
DESTINATION ${INSTALL_BASE_DIR}/include/dataset
COMPONENT mindspore
)

## config files
install(
FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
DESTINATION ${INSTALL_CFG_DIR}
COMPONENT mindspore
)

+ 0
- 164
cmake/package_script.cmake View File

@@ -1,164 +0,0 @@
# find exec
find_package(Git)
if(NOT GIT_FOUND)
message("No git found.")
return()
endif()
set(GIT ${GIT_EXECUTABLE})

# set path
set(MS_ROOT_DIR ${CPACK_CMAKE_SOURCE_DIR})
set(MS_PACK_ROOT_DIR ${CPACK_PACK_ROOT_DIR})

set(PYTHON ${CPACK_PYTHON_EXE})
set(PYTHON_VERSION ${CPACK_PYTHON_VERSION})

if(NOT (PYTHON_VERSION MATCHES "3.9" OR PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7"))
message(FATAL_ERROR "FIND PYTHON VERSION ${PYTHON_VERSION} BUT CAN NOT MATCH PYTHON VERSION 3.9 OR 3.8 OR 3.7")
endif()

# set package file name
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(PYTHON_VERSION MATCHES "3.9")
set(PY_TAGS "cp39-cp39")
elseif(PYTHON_VERSION MATCHES "3.8")
set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m")
else()
message("Could not find 'Python 3.9' OR 'Python 3.8' or 'Python 3.7'")
return()
endif()
string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_TAG)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(PYTHON_VERSION MATCHES "3.9")
set(PY_TAGS "cp39-cp39")
elseif(PYTHON_VERSION MATCHES "3.8")
set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m")
else()
message("Could not find 'Python 3.9' OR 'Python 3.8' or 'Python 3.7'")
return()
endif()
string(REGEX MATCH "[0-9]+.[0-9]+" MACOSX_SDK_VERSION "${CPACK_OSX_DEPLOYMENT_TARGET}")
string(REPLACE "." "_" MACOSX_PACKAGE_VERSION "${MACOSX_SDK_VERSION}")
string(TOLOWER macosx_${MACOSX_PACKAGE_VERSION}_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_TAG)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(PYTHON_VERSION MATCHES "3.9")
set(PY_TAGS "cp39-cp39")
elseif(PYTHON_VERSION MATCHES "3.8")
set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m")
else()
message("Could not find 'Python 3.9' OR 'Python 3.8' or 'Python 3.7'")
return()
endif()
set(PLATFORM_TAG "win_amd64")
else()
message(FATAL_ERROR "other platform: ${CMAKE_SYSTEM_NAME}")
endif()

# get git commit id
set(GIT_COMMIT_ID "")
execute_process(
COMMAND ${GIT} log --format='[sha1]:%h,[branch]:%d' --abbrev=8 -1
OUTPUT_VARIABLE GIT_COMMIT_ID
WORKING_DIRECTORY ${MS_ROOT_DIR}
ERROR_QUIET)
string(REPLACE " " "" GIT_COMMIT_ID ${GIT_COMMIT_ID})

set(ENV{BACKEND_POLICY} ${CPACK_MS_BACKEND})
set(ENV{BACKEND_TARGET} ${CPACK_MS_TARGET})
set(ENV{MS_PACKAGE_NAME} ${CPACK_MS_PACKAGE_NAME})
set(ENV{COMMIT_ID} ${GIT_COMMIT_ID})

file(GLOB DEBUG_SYM
${MS_PACK_ROOT_DIR}/mindspore/*.so
${MS_PACK_ROOT_DIR}/mindspore/lib/*.so
)

file(GLOB DEBUG_STRIP_SYM
${MS_PACK_ROOT_DIR}/mindspore/*.so
${MS_PACK_ROOT_DIR}/mindspore/lib/*.so*
)
list(REMOVE_ITEM DEBUG_STRIP_SYM ${MS_PACK_ROOT_DIR}/mindspore/lib/libmindspore_aicpu_kernels.so)

set(CMAKE_OBJCOPY $ENV{CROSS_COMPILE}objcopy)
set(CMAKE_STRIP $ENV{CROSS_COMPILE}strip)

if(CPACK_ENABLE_SYM_FILE)
foreach(schema ${DEBUG_SYM})
execute_process(
COMMAND ${CMAKE_OBJCOPY} "--only-keep-debug" ${schema} ${schema}.sym
WORKING_DIRECTORY ${MS_PACK_ROOT_DIR}
)
endforeach()
endif()

if("${CPACK_CMAKE_BUILD_TYPE}" STREQUAL "Release")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_STRIP_ARGS "-x")
else()
set(CMAKE_STRIP_ARGS "")
endif()
foreach(schema ${DEBUG_STRIP_SYM})
execute_process(
COMMAND ${CMAKE_STRIP} ${CMAKE_STRIP_ARGS} ${schema}
WORKING_DIRECTORY ${MS_PACK_ROOT_DIR}
)
endforeach()
endif()

file(GLOB DEBUG_SYM_FILE
${MS_PACK_ROOT_DIR}/mindspore/*.sym
${MS_PACK_ROOT_DIR}/mindspore/lib/*.sym
)

if(CPACK_ENABLE_SYM_FILE)
file(MAKE_DIRECTORY ${MS_ROOT_DIR}/debug_info)
file(COPY ${DEBUG_SYM_FILE} DESTINATION ${MS_ROOT_DIR}/debug_info/)
file(REMOVE_RECURSE ${DEBUG_SYM_FILE})
endif()

execute_process(
COMMAND ${PYTHON} ${MS_ROOT_DIR}/setup.py "bdist_wheel"
WORKING_DIRECTORY ${MS_PACK_ROOT_DIR}
)

# finally
set(PACKAGE_NAME ${CPACK_MS_PACKAGE_NAME})
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
string(REPLACE "-" "_" PACKAGE_NAME ${PACKAGE_NAME})
execute_process(
COMMAND chmod -R 700 ${MS_PACK_ROOT_DIR}/mindspore/
COMMAND chmod -R 700 ${MS_PACK_ROOT_DIR}/${PACKAGE_NAME}.egg-info/
)
endif()

file(GLOB WHL_FILE ${MS_PACK_ROOT_DIR}/dist/*.whl)
get_filename_component(ORIGIN_FILE_NAME ${WHL_FILE} NAME)
string(REPLACE "-" ";" ORIGIN_FILE_NAME ${ORIGIN_FILE_NAME})
list(GET ORIGIN_FILE_NAME 1 VERSION)
set(NEW_FILE_NAME ${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG}.whl)
file(RENAME ${WHL_FILE} ${MS_PACK_ROOT_DIR}/${NEW_FILE_NAME})
file(REMOVE_RECURSE ${MS_ROOT_DIR}/output)
file(MAKE_DIRECTORY ${MS_ROOT_DIR}/output)
file(COPY ${MS_PACK_ROOT_DIR}/${NEW_FILE_NAME} DESTINATION ${MS_ROOT_DIR}/output/)

file(SHA256 ${MS_ROOT_DIR}/output/${NEW_FILE_NAME} SHA256_VAR)
file(WRITE ${MS_ROOT_DIR}/output/${NEW_FILE_NAME}.sha256 ${SHA256_VAR} " " ${NEW_FILE_NAME})
set(CMAKE_TAR $ENV{CROSS_COMPILE}tar)
if(CPACK_ENABLE_SYM_FILE)
file(MAKE_DIRECTORY ${MS_ROOT_DIR}/output/${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG})
file(COPY ${MS_ROOT_DIR}/debug_info/ DESTINATION
${MS_ROOT_DIR}/output/${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG}/)
execute_process(COMMAND
${CMAKE_COMMAND} -E ${CMAKE_TAR} cfv
${MS_ROOT_DIR}/output/${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG}.zip
${MS_ROOT_DIR}/output/${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG}/ --format=zip
WORKING_DIRECTORY ${MS_ROOT_DIR})
file(REMOVE_RECURSE ${MS_ROOT_DIR}/debug_info)
file(REMOVE_RECURSE ${MS_ROOT_DIR}/output/${PACKAGE_NAME}-${VERSION}-${PY_TAGS}-${PLATFORM_TAG})
endif()

+ 0
- 173
cmake/package_tar.cmake View File

@@ -1,173 +0,0 @@
# include dependency
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# prepare output directory
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/output)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/output)

# cpack variables
string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_NAME)
set(CPACK_PACKAGE_FILE_NAME mindspore_ascend-${VERSION_NUMBER}-${PLATFORM_NAME})
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_SOURCE_DIR}/output)

set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_BASE_DIR ".")
set(INSTALL_BIN_DIR "bin")
set(INSTALL_CFG_DIR "config")
set(INSTALL_LIB_DIR "lib")

# set package files
install(
TARGETS mindspore_shared_lib
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

install(
TARGETS mindspore_core mindspore_common mindspore_backend
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

if(USE_GLOG)
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog*)
install(
FILES ${GLOG_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

file(GLOB_RECURSE LIBEVENT_LIB_LIST
${libevent_LIBPATH}/libevent*${CMAKE_SHARED_LIBRARY_SUFFIX}*
${libevent_LIBPATH}/libevent_pthreads*${CMAKE_SHARED_LIBRARY_SUFFIX}*
)

install(
FILES ${LIBEVENT_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

if(ENABLE_MINDDATA)
install(
TARGETS _c_dataengine _c_mindrecord
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
install(
TARGETS cache_admin cache_server
OPTIONAL
DESTINATION ${INSTALL_BIN_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE OPENCV_LIB_LIST
${opencv_LIBPATH}/libopencv_core*
${opencv_LIBPATH}/libopencv_imgcodecs*
${opencv_LIBPATH}/libopencv_imgproc*
)
install(
FILES ${OPENCV_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/libtinyxml2*)
install(
FILES ${TINYXML2_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE ICU4C_LIB_LIST
${icu4c_LIBPATH}/libicuuc*
${icu4c_LIBPATH}/libicudata*
${icu4c_LIBPATH}/libicui18n*
)
install(
FILES ${ICU4C_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

# CPU mode
if(ENABLE_CPU AND NOT WIN32)
install(
TARGETS ps_cache
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_CPU)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl${CMAKE_SHARED_LIBRARY_SUFFIX}*)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
endif()
install(
FILES ${DNNL_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS nnacl
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(MS_BUILD_GRPC)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc++.so.1.36.1
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc++.so.1 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_grpc.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_grpc.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_gpr.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_gpr.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_upb.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_upb.so.15 COMPONENT mindspore)
install(FILES ${grpc_LIBPATH}/libmindspore_address_sorting.so.15.0.0
DESTINATION ${INSTALL_LIB_DIR} RENAME libmindspore_address_sorting.so.15 COMPONENT mindspore)
endif()

## Public header files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

## Public header files for mindapi
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/base
${CMAKE_SOURCE_DIR}/mindspore/core/mindapi/ir
DESTINATION ${INSTALL_BASE_DIR}/include/mindapi
COMPONENT mindspore
)

## Public header files for minddata
install(
FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
DESTINATION ${INSTALL_BASE_DIR}/include/dataset
COMPONENT mindspore
)

## config files
install(
FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
DESTINATION ${INSTALL_CFG_DIR}
COMPONENT mindspore
)

include(CPack)

+ 0
- 248
cmake/package_win.cmake View File

@@ -1,248 +0,0 @@
# include dependency
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# set package information
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_GENERATOR "External")
set(CPACK_CMAKE_GENERATOR "Ninja")
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_SOURCE_DIR}/cmake/package_script.cmake)
set(CPACK_EXTERNAL_ENABLE_STAGING true)
set(CPACK_TEMPORARY_PACKAGE_FILE_NAME ${CMAKE_SOURCE_DIR}/build/package/mindspore)
set(CPACK_TEMPORARY_INSTALL_DIRECTORY ${CMAKE_SOURCE_DIR}/build/package/mindspore)
set(CPACK_PACK_ROOT_DIR ${BUILD_PATH}/package/)
set(CPACK_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(CPACK_PYTHON_EXE ${Python3_EXECUTABLE})
set(CPACK_PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})

if(ENABLE_GPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "gpu or cpu")
if(BUILD_DEV_MODE)
# providing cuda11 version of dev package only
set(CPACK_MS_PACKAGE_NAME "mindspore_cuda11_dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore_gpu")
endif()
elseif(ENABLE_CPU)
set(CPACK_MS_BACKEND "ms")
set(CPACK_MS_TARGET "cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore_dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
else()
set(CPACK_MS_BACKEND "debug")
set(CPACK_MS_TARGET "ascend or gpu or cpu")
if(BUILD_DEV_MODE)
set(CPACK_MS_PACKAGE_NAME "mindspore_dev")
else()
set(CPACK_MS_PACKAGE_NAME "mindspore")
endif()
endif()
include(CPack)

# set install path
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_PY_DIR ".")
set(INSTALL_BASE_DIR ".")
set(INSTALL_BIN_DIR "bin")
set(INSTALL_CFG_DIR "config")

set(INSTALL_LIB_DIR ".")
set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/)
set(glog_LIBPATH ${glog_LIBPATH}/../bin/)
set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/)
set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/)
set(sqlite_LIBPATH ${sqlite_LIBPATH}/../bin/)
set(tinyxml2_LIBPATH ${tinyxml2_LIBPATH}/../bin/)

message("offline debugger does not support windows system temporarily")

# set package files
install(
TARGETS _c_expression
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

install(
TARGETS mindspore_shared_lib
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

install(
TARGETS mindspore_core mindspore_common mindspore_backend
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

if(USE_GLOG)
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog.dll)
install(
FILES ${GLOG_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_MINDDATA)
message("icu4c does not support windows system temporarily")
install(
TARGETS _c_dataengine _c_mindrecord
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

file(GLOB_RECURSE OPENCV_LIB_LIST
${opencv_LIBPATH}/libopencv_core*
${opencv_LIBPATH}/libopencv_imgcodecs*
${opencv_LIBPATH}/libopencv_imgproc*
)
install(
FILES ${OPENCV_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/libtinyxml2.dll)
install(
FILES ${TINYXML2_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_CPU)
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
install(
FILES ${DNNL_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS nnacl
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

if(ENABLE_MPI)
if(ENABLE_GPU)
install(
TARGETS _ms_mpi
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
endif()
if(ENABLE_CPU)
install(
TARGETS mpi_adapter
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS mpi_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
endif()

if(ENABLE_GPU)
if(ENABLE_MPI)
install(
TARGETS gpu_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
install(
TARGETS nvidia_collective
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
install(
TARGETS gpu_queue
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()

get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)

string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)

file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
install(
FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)

# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
install(
FILES ${MS_PY_LIST}
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)

install(
DIRECTORY
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/nn
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/_extends
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/parallel
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/mindrecord
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/numpy
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/train
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/boost
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/common
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/ops
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/communication
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/profiler
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/compression
${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/run_check
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)

if(EXISTS ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/dataset
DESTINATION ${INSTALL_PY_DIR}
COMPONENT mindspore
)
endif()

## Public header files
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)

## Public header files for minddata
install(
FILES ${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/config.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/text.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h
${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h
DESTINATION ${INSTALL_BASE_DIR}/include/dataset
COMPONENT mindspore
)

## config files
install(
FILES ${CMAKE_SOURCE_DIR}/config/op_info.config
DESTINATION ${INSTALL_CFG_DIR}
COMPONENT mindspore
)

+ 95
- 212
cmake/utils.cmake View File

@@ -1,10 +1,6 @@
include(FetchContent) include(FetchContent)
set(FETCHCONTENT_QUIET OFF) set(FETCHCONTENT_QUIET OFF)


if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.17.0)
set(CMAKE_FIND_LIBRARY_SUFFIXES .dll ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()

function(mindspore_add_submodule_obj des_submodule_objs sub_dir submodule_name_obj) function(mindspore_add_submodule_obj des_submodule_objs sub_dir submodule_name_obj)


add_subdirectory(${sub_dir}) add_subdirectory(${sub_dir})
@@ -20,45 +16,25 @@ function(mindspore_add_submodule_obj des_submodule_objs sub_dir submodule_name_o


endfunction() endfunction()


if(DEFINED ENV{MSLIBS_CACHE_PATH})
set(_MS_LIB_CACHE $ENV{MSLIBS_CACHE_PATH})
else()
set(_MS_LIB_CACHE ${CMAKE_BINARY_DIR}/.mslib)
endif()
message("MS LIBS CACHE PATH: ${_MS_LIB_CACHE}")

if(NOT EXISTS ${_MS_LIB_CACHE})
get_filename_component(_MS_LIB_CACHE ~/.mslib REALPATH)
if (NOT EXISTS ${_MS_LIB_CACHE})
file(MAKE_DIRECTORY ${_MS_LIB_CACHE}) file(MAKE_DIRECTORY ${_MS_LIB_CACHE})
endif()

if(DEFINED ENV{MSLIBS_SERVER} AND NOT ENABLE_GITEE)
endif ()
# set(FETCHCONTENT_BASE_DIR ${_MS_LIB_CACHE})
# set(CMAKE_PREFIX_PATH ${_MS_LIB_CACHE})
if (DEFINED ENV{MSLIBS_SERVER})
set(LOCAL_LIBS_SERVER $ENV{MSLIBS_SERVER}) set(LOCAL_LIBS_SERVER $ENV{MSLIBS_SERVER})
message("LOCAL_LIBS_SERVER: ${LOCAL_LIBS_SERVER}") message("LOCAL_LIBS_SERVER: ${LOCAL_LIBS_SERVER}")
endif()

include(ProcessorCount)
ProcessorCount(N)
if(JOBS)
set(THNUM ${JOBS})
else()
set(JOBS 8)
if(${JOBS} GREATER ${N})
set(THNUM ${N})
else()
set(THNUM ${JOBS})
endif()
endif()
message("set make thread num: ${THNUM}")

endif ()
if(LOCAL_LIBS_SERVER) if(LOCAL_LIBS_SERVER)
if(NOT ENV{no_proxy})
if (NOT ENV{no_proxy})
set(ENV{no_proxy} "${LOCAL_LIBS_SERVER}") set(ENV{no_proxy} "${LOCAL_LIBS_SERVER}")
else() else()
string(FIND $ENV{no_proxy} ${LOCAL_LIBS_SERVER} IP_POS) string(FIND $ENV{no_proxy} ${LOCAL_LIBS_SERVER} IP_POS)
if(${IP_POS} EQUAL -1)
if (${IP_POS} EQUAL -1)
set(ENV{no_proxy} "$ENV{no_proxy},${LOCAL_LIBS_SERVER}") set(ENV{no_proxy} "$ENV{no_proxy},${LOCAL_LIBS_SERVER}")
endif()
endif()
endif ()
endif ()
endif() endif()


function(__download_pkg pkg_name pkg_url pkg_md5) function(__download_pkg pkg_name pkg_url pkg_md5)
@@ -82,32 +58,7 @@ function(__download_pkg pkg_name pkg_url pkg_md5)


endfunction() endfunction()


function(__download_pkg_with_git pkg_name pkg_url pkg_git_commit pkg_md5)

if(LOCAL_LIBS_SERVER)
set(pkg_url "http://${LOCAL_LIBS_SERVER}:8081/libs/${pkg_name}/${pkg_git_commit}")
FetchContent_Declare(
${pkg_name}
URL ${pkg_url}
URL_HASH MD5=${pkg_md5}
)
else()
FetchContent_Declare(
${pkg_name}
GIT_REPOSITORY ${pkg_url}
GIT_TAG ${pkg_git_commit})
endif()
FetchContent_GetProperties(${pkg_name})
message("download: ${${pkg_name}_SOURCE_DIR} , ${pkg_name} , ${pkg_url}")
if(NOT ${pkg_name}_POPULATED)
FetchContent_Populate(${pkg_name})
set(${pkg_name}_SOURCE_DIR ${${pkg_name}_SOURCE_DIR} PARENT_SCOPE)
endif()

endfunction()


function(__find_pkg_then_add_target pkg_name pkg_exe lib_path)
function(__find_pkg_then_add_target pkg_name pkg_exe)


unset(${pkg_name}_LIBS) unset(${pkg_name}_LIBS)


@@ -128,49 +79,35 @@ function(__find_pkg_then_add_target pkg_name pkg_exe lib_path)
foreach(_LIB_NAME ${ARGN}) foreach(_LIB_NAME ${ARGN})
set(_LIB_SEARCH_NAME ${_LIB_NAME}) set(_LIB_SEARCH_NAME ${_LIB_NAME})
set(_LIB_TYPE SHARED) set(_LIB_TYPE SHARED)
if(${pkg_name}_USE_STATIC_LIBS)
if (${pkg_name}_USE_STATIC_LIBS)
set(_LIB_SEARCH_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}${_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") set(_LIB_SEARCH_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}${_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(_LIB_TYPE STATIC) set(_LIB_TYPE STATIC)
endif()
endif ()
set(${_LIB_NAME}_LIB ${_LIB_NAME}_LIB-NOTFOUND) set(${_LIB_NAME}_LIB ${_LIB_NAME}_LIB-NOTFOUND)
if(APPLE)
find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/${lib_path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/${lib_path}
NO_DEFAULT_PATH)
endif()
find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/lib NO_DEFAULT_PATH)
if(NOT ${_LIB_NAME}_LIB) if(NOT ${_LIB_NAME}_LIB)
return() return()
endif() endif()

add_library(${pkg_name}::${_LIB_NAME} ${_LIB_TYPE} IMPORTED GLOBAL) add_library(${pkg_name}::${_LIB_NAME} ${_LIB_TYPE} IMPORTED GLOBAL)
if(WIN32 AND ${_LIB_TYPE} STREQUAL "SHARED")
set_target_properties(${pkg_name}::${_LIB_NAME} PROPERTIES IMPORTED_IMPLIB_RELEASE ${${_LIB_NAME}_LIB})
else()
set_target_properties(${pkg_name}::${_LIB_NAME} PROPERTIES IMPORTED_LOCATION ${${_LIB_NAME}_LIB})
endif()

if(EXISTS ${${pkg_name}_BASE_DIR}/include)
set_target_properties(${pkg_name}::${_LIB_NAME} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${${pkg_name}_BASE_DIR}/include")
endif()

set_target_properties(${pkg_name}::${_LIB_NAME} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${${pkg_name}_BASE_DIR}/include"
IMPORTED_LOCATION ${${_LIB_NAME}_LIB}
)
list(APPEND ${pkg_name}_LIBS ${pkg_name}::${_LIB_NAME}) list(APPEND ${pkg_name}_LIBS ${pkg_name}::${_LIB_NAME})
message("found ${${_LIB_NAME}_LIB}") message("found ${${_LIB_NAME}_LIB}")
STRING(REGEX REPLACE "(.+)/(.+)" "\\1" LIBPATH ${${_LIB_NAME}_LIB})
STRING( REGEX REPLACE "(.+)/(.+)" "\\1" LIBPATH ${${_LIB_NAME}_LIB})
set(${pkg_name}_LIBPATH ${LIBPATH} CACHE STRING INTERNAL) set(${pkg_name}_LIBPATH ${LIBPATH} CACHE STRING INTERNAL)
endforeach()
endforeach(_LIB_NAME)


set(${pkg_name}_LIBS ${${pkg_name}_LIBS} PARENT_SCOPE) set(${pkg_name}_LIBS ${${pkg_name}_LIBS} PARENT_SCOPE)
endfunction() endfunction()


function(__exec_cmd) function(__exec_cmd)
set(options)
set(options )
set(oneValueArgs WORKING_DIRECTORY) set(oneValueArgs WORKING_DIRECTORY)
set(multiValueArgs COMMAND) set(multiValueArgs COMMAND)


cmake_parse_arguments(EXEC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
cmake_parse_arguments(EXEC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )


execute_process(COMMAND ${EXEC_COMMAND} execute_process(COMMAND ${EXEC_COMMAND}
WORKING_DIRECTORY ${EXEC_WORKING_DIRECTORY} WORKING_DIRECTORY ${EXEC_WORKING_DIRECTORY}
@@ -182,57 +119,47 @@ endfunction()


function(__check_patches pkg_patches) function(__check_patches pkg_patches)
# check patches # check patches
if(PKG_PATCHES)
if (PKG_PATCHES)
file(TOUCH ${_MS_LIB_CACHE}/${pkg_name}_patch.md5) file(TOUCH ${_MS_LIB_CACHE}/${pkg_name}_patch.md5)
file(READ ${_MS_LIB_CACHE}/${pkg_name}_patch.md5 ${pkg_name}_PATCHES_MD5) file(READ ${_MS_LIB_CACHE}/${pkg_name}_patch.md5 ${pkg_name}_PATCHES_MD5)


message("patches md5:${${pkg_name}_PATCHES_MD5}") message("patches md5:${${pkg_name}_PATCHES_MD5}")


set(${pkg_name}_PATCHES_NEW_MD5)
set(${pkg_name}_PATCHES_NEW_MD5 )
foreach(_PATCH ${PKG_PATCHES}) foreach(_PATCH ${PKG_PATCHES})
file(MD5 ${_PATCH} _PF_MD5) file(MD5 ${_PATCH} _PF_MD5)
set(${pkg_name}_PATCHES_NEW_MD5 "${${pkg_name}_PATCHES_NEW_MD5},${_PF_MD5}") set(${pkg_name}_PATCHES_NEW_MD5 "${${pkg_name}_PATCHES_NEW_MD5},${_PF_MD5}")
endforeach()
endforeach(_PATCH)


if(NOT ${pkg_name}_PATCHES_MD5 STREQUAL ${pkg_name}_PATCHES_NEW_MD5)
if (NOT ${pkg_name}_PATCHES_MD5 STREQUAL ${pkg_name}_PATCHES_NEW_MD5)
set(${pkg_name}_PATCHES ${PKG_PATCHES}) set(${pkg_name}_PATCHES ${PKG_PATCHES})
file(REMOVE_RECURSE "${_MS_LIB_CACHE}/${pkg_name}-subbuild") file(REMOVE_RECURSE "${_MS_LIB_CACHE}/${pkg_name}-subbuild")
file(WRITE ${_MS_LIB_CACHE}/${pkg_name}_patch.md5 ${${pkg_name}_PATCHES_NEW_MD5}) file(WRITE ${_MS_LIB_CACHE}/${pkg_name}_patch.md5 ${${pkg_name}_PATCHES_NEW_MD5})
message("patches changed : ${${pkg_name}_PATCHES_NEW_MD5}") message("patches changed : ${${pkg_name}_PATCHES_NEW_MD5}")
endif()
endif()
endif ()
endif ()
endfunction() endfunction()


set(MS_FIND_NO_DEFAULT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH set(MS_FIND_NO_DEFAULT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY) NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
set(MS_FIND_NO_DEFAULT_PATH ${MS_FIND_NO_DEFAULT_PATH} PARENT_SCOPE) set(MS_FIND_NO_DEFAULT_PATH ${MS_FIND_NO_DEFAULT_PATH} PARENT_SCOPE)
function(mindspore_add_pkg pkg_name)

set(options)
set(oneValueArgs URL MD5 GIT_REPOSITORY GIT_TAG VER EXE DIR HEAD_ONLY CMAKE_PATH RELEASE LIB_PATH CUSTOM_CMAKE)
set(multiValueArgs
CMAKE_OPTION LIBS PRE_CONFIGURE_COMMAND CONFIGURE_COMMAND BUILD_OPTION INSTALL_INCS
INSTALL_LIBS PATCHES SUBMODULES SOURCEMODULES ONLY_MAKE ONLY_MAKE_INCS ONLY_MAKE_LIBS)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
function(mindspore_add_pkg pkg_name )


if(NOT PKG_LIB_PATH)
set(PKG_LIB_PATH lib)
endif()

if(NOT PKG_EXE)
set(PKG_EXE 0)
endif()
set(options )
set(oneValueArgs URL MD5 VER EXE DIR HEAD_ONLY)
set(multiValueArgs CMAKE_OPTION LIBS PRE_CONFIGURE_COMMAND CONFIGURE_COMMAND BUILD_OPTION INSTALL_INCS INSTALL_LIBS PATCHES)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )


set(__FIND_PKG_NAME ${pkg_name}) set(__FIND_PKG_NAME ${pkg_name})
string(TOLOWER ${pkg_name} pkg_name) string(TOLOWER ${pkg_name} pkg_name)
message("pkg name:${__FIND_PKG_NAME},${pkg_name}") message("pkg name:${__FIND_PKG_NAME},${pkg_name}")


set(${pkg_name}_PATCHES_HASH)
set(${pkg_name}_PATCHES_HASH )
foreach(_PATCH ${PKG_PATCHES}) foreach(_PATCH ${PKG_PATCHES})
file(MD5 ${_PATCH} _PF_MD5) file(MD5 ${_PATCH} _PF_MD5)
set(${pkg_name}_PATCHES_HASH "${${pkg_name}_PATCHES_HASH},${_PF_MD5}") set(${pkg_name}_PATCHES_HASH "${${pkg_name}_PATCHES_HASH},${_PF_MD5}")
endforeach()
endforeach(_PATCH)


# check options # check options
set(${pkg_name}_CONFIG_TXT set(${pkg_name}_CONFIG_TXT
@@ -244,24 +171,25 @@ function(mindspore_add_pkg pkg_name)


message("${pkg_name} config hash: ${${pkg_name}_CONFIG_HASH}") message("${pkg_name} config hash: ${${pkg_name}_CONFIG_HASH}")


set(${pkg_name}_BASE_DIR ${_MS_LIB_CACHE}/${pkg_name}_${PKG_VER}_${${pkg_name}_CONFIG_HASH})
set(${pkg_name}_BASE_DIR ${_MS_LIB_CACHE}/${pkg_name}_${${pkg_name}_CONFIG_HASH})
set(${pkg_name}_DIRPATH ${${pkg_name}_BASE_DIR} CACHE STRING INTERNAL) set(${pkg_name}_DIRPATH ${${pkg_name}_BASE_DIR} CACHE STRING INTERNAL)


if(EXISTS ${${pkg_name}_BASE_DIR}/options.txt AND PKG_HEAD_ONLY) if(EXISTS ${${pkg_name}_BASE_DIR}/options.txt AND PKG_HEAD_ONLY)
set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/${PKG_HEAD_ONLY} PARENT_SCOPE) set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/${PKG_HEAD_ONLY} PARENT_SCOPE)
add_library(${pkg_name} INTERFACE) add_library(${pkg_name} INTERFACE)
target_include_directories(${pkg_name} INTERFACE ${${pkg_name}_INC}) target_include_directories(${pkg_name} INTERFACE ${${pkg_name}_INC})
if(${PKG_RELEASE})
__find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIB_PATH} ${PKG_LIBS})
endif()
return() return()
endif ()

if(NOT PKG_EXE)
set(PKG_EXE 0)
endif() endif()


set(${__FIND_PKG_NAME}_ROOT ${${pkg_name}_BASE_DIR}) set(${__FIND_PKG_NAME}_ROOT ${${pkg_name}_BASE_DIR})
set(${__FIND_PKG_NAME}_ROOT ${${pkg_name}_BASE_DIR} PARENT_SCOPE) set(${__FIND_PKG_NAME}_ROOT ${${pkg_name}_BASE_DIR} PARENT_SCOPE)


if(PKG_LIBS)
__find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIB_PATH} ${PKG_LIBS})
if (PKG_LIBS)
__find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIBS})
if(${pkg_name}_LIBS) if(${pkg_name}_LIBS)
set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE)
message("Found libs: ${${pkg_name}_LIBS}") message("Found libs: ${${pkg_name}_LIBS}")
@@ -269,169 +197,124 @@ function(mindspore_add_pkg pkg_name)
endif() endif()
elseif(NOT PKG_HEAD_ONLY) elseif(NOT PKG_HEAD_ONLY)
find_package(${__FIND_PKG_NAME} ${PKG_VER} ${MS_FIND_NO_DEFAULT_PATH}) find_package(${__FIND_PKG_NAME} ${PKG_VER} ${MS_FIND_NO_DEFAULT_PATH})
if(${__FIND_PKG_NAME}_FOUND)
if (${__FIND_PKG_NAME}_FOUND)
set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE)
message("Found pkg: ${__FIND_PKG_NAME}") message("Found pkg: ${__FIND_PKG_NAME}")
return() return()
endif()
endif()
endif ()
endif ()


if(NOT PKG_DIR)
if(PKG_GIT_REPOSITORY)
__download_pkg_with_git(${pkg_name} ${PKG_GIT_REPOSITORY} ${PKG_GIT_TAG} ${PKG_MD5})
else()
__download_pkg(${pkg_name} ${PKG_URL} ${PKG_MD5})
endif()
foreach(_SUBMODULE_FILE ${PKG_SUBMODULES})
STRING(REGEX REPLACE "(.+)_(.+)" "\\1" _SUBMODEPATH ${_SUBMODULE_FILE})
STRING(REGEX REPLACE "(.+)/(.+)" "\\2" _SUBMODENAME ${_SUBMODEPATH})
file(GLOB ${pkg_name}_INSTALL_SUBMODULE ${_SUBMODULE_FILE}/*)
file(COPY ${${pkg_name}_INSTALL_SUBMODULE} DESTINATION ${${pkg_name}_SOURCE_DIR}/3rdparty/${_SUBMODENAME})
endforeach()
if (NOT PKG_DIR)
__download_pkg(${pkg_name} ${PKG_URL} ${PKG_MD5})
else() else()
set(${pkg_name}_SOURCE_DIR ${PKG_DIR}) set(${pkg_name}_SOURCE_DIR ${PKG_DIR})
endif()
endif ()
file(WRITE ${${pkg_name}_BASE_DIR}/options.txt ${${pkg_name}_CONFIG_TXT}) file(WRITE ${${pkg_name}_BASE_DIR}/options.txt ${${pkg_name}_CONFIG_TXT})
message("${pkg_name}_SOURCE_DIR : ${${pkg_name}_SOURCE_DIR}") message("${pkg_name}_SOURCE_DIR : ${${pkg_name}_SOURCE_DIR}")


foreach(_PATCH_FILE ${PKG_PATCHES}) foreach(_PATCH_FILE ${PKG_PATCHES})
get_filename_component(_PATCH_FILE_NAME ${_PATCH_FILE} NAME)
set(_LF_PATCH_FILE ${CMAKE_BINARY_DIR}/_ms_patch/${_PATCH_FILE_NAME})
configure_file(${_PATCH_FILE} ${_LF_PATCH_FILE} NEWLINE_STYLE LF @ONLY)

message("patching ${${pkg_name}_SOURCE_DIR} -p1 < ${_LF_PATCH_FILE}")
execute_process(COMMAND ${Patch_EXECUTABLE} -p1 INPUT_FILE ${_LF_PATCH_FILE}
message("patching ${${pkg_name}_SOURCE_DIR} -p1 < ${_PATCH_FILE}")
execute_process(COMMAND patch -p1 INPUT_FILE ${_PATCH_FILE}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR} WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}
RESULT_VARIABLE Result) RESULT_VARIABLE Result)
if(NOT Result EQUAL "0") if(NOT Result EQUAL "0")
message(FATAL_ERROR "Failed patch: ${_LF_PATCH_FILE}")
message(FATAL_ERROR "Failed patch: ${_PATCH_FILE}")
endif() endif()
endforeach()
foreach(_SOURCE_DIR ${PKG_SOURCEMODULES})
file(GLOB ${pkg_name}_INSTALL_SOURCE ${${pkg_name}_SOURCE_DIR}/${_SOURCE_DIR}/*)
file(COPY ${${pkg_name}_INSTALL_SOURCE} DESTINATION ${${pkg_name}_BASE_DIR}/${_SOURCE_DIR}/)
endforeach()
endforeach(_PATCH_FILE)
file(LOCK ${${pkg_name}_BASE_DIR} DIRECTORY GUARD FUNCTION RESULT_VARIABLE ${pkg_name}_LOCK_RET TIMEOUT 600) file(LOCK ${${pkg_name}_BASE_DIR} DIRECTORY GUARD FUNCTION RESULT_VARIABLE ${pkg_name}_LOCK_RET TIMEOUT 600)
if(NOT ${pkg_name}_LOCK_RET EQUAL "0") if(NOT ${pkg_name}_LOCK_RET EQUAL "0")
message(FATAL_ERROR "error! when try lock ${${pkg_name}_BASE_DIR} : ${${pkg_name}_LOCK_RET}") message(FATAL_ERROR "error! when try lock ${${pkg_name}_BASE_DIR} : ${${pkg_name}_LOCK_RET}")
endif() endif()


if(PKG_CUSTOM_CMAKE)
file(GLOB ${pkg_name}_cmake ${PKG_CUSTOM_CMAKE}/CMakeLists.txt)
file(COPY ${${pkg_name}_cmake} DESTINATION ${${pkg_name}_SOURCE_DIR})
endif()

if(${pkg_name}_SOURCE_DIR) if(${pkg_name}_SOURCE_DIR)
if(PKG_HEAD_ONLY)
if (PKG_HEAD_ONLY)
file(GLOB ${pkg_name}_SOURCE_SUBDIRS ${${pkg_name}_SOURCE_DIR}/*) file(GLOB ${pkg_name}_SOURCE_SUBDIRS ${${pkg_name}_SOURCE_DIR}/*)
file(COPY ${${pkg_name}_SOURCE_SUBDIRS} DESTINATION ${${pkg_name}_BASE_DIR}) file(COPY ${${pkg_name}_SOURCE_SUBDIRS} DESTINATION ${${pkg_name}_BASE_DIR})
set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/${PKG_HEAD_ONLY} PARENT_SCOPE) set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/${PKG_HEAD_ONLY} PARENT_SCOPE)
if(NOT PKG_RELEASE)
add_library(${pkg_name} INTERFACE)
target_include_directories(${pkg_name} INTERFACE ${${pkg_name}_INC})
endif()
add_library(${pkg_name} INTERFACE)
target_include_directories(${pkg_name} INTERFACE ${${pkg_name}_INC})


elseif(PKG_ONLY_MAKE)
__exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} ${${pkg_name}_CXXFLAGS} -j${THNUM}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})
set(PKG_INSTALL_INCS ${PKG_ONLY_MAKE_INCS})
set(PKG_INSTALL_LIBS ${PKG_ONLY_MAKE_LIBS})
file(GLOB ${pkg_name}_INSTALL_INCS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_INCS})
file(GLOB ${pkg_name}_INSTALL_LIBS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_LIBS})
file(COPY ${${pkg_name}_INSTALL_INCS} DESTINATION ${${pkg_name}_BASE_DIR}/include)
file(COPY ${${pkg_name}_INSTALL_LIBS} DESTINATION ${${pkg_name}_BASE_DIR}/lib)

elseif(PKG_CMAKE_OPTION)
elseif (PKG_CMAKE_OPTION)
# in cmake # in cmake
file(MAKE_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) file(MAKE_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
if(${pkg_name}_CFLAGS)
if (${pkg_name}_CFLAGS)
set(${pkg_name}_CMAKE_CFLAGS "-DCMAKE_C_FLAGS=${${pkg_name}_CFLAGS}") set(${pkg_name}_CMAKE_CFLAGS "-DCMAKE_C_FLAGS=${${pkg_name}_CFLAGS}")
endif()
if(${pkg_name}_CXXFLAGS)
endif ()
if (${pkg_name}_CXXFLAGS)
set(${pkg_name}_CMAKE_CXXFLAGS "-DCMAKE_CXX_FLAGS=${${pkg_name}_CXXFLAGS}") set(${pkg_name}_CMAKE_CXXFLAGS "-DCMAKE_CXX_FLAGS=${${pkg_name}_CXXFLAGS}")
endif()
endif ()


if(${pkg_name}_LDFLAGS)
if(${pkg_name}_USE_STATIC_LIBS)
if (${pkg_name}_LDFLAGS)
if (${pkg_name}_USE_STATIC_LIBS)
#set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_STATIC_LINKER_FLAGS=${${pkg_name}_LDFLAGS}") #set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_STATIC_LINKER_FLAGS=${${pkg_name}_LDFLAGS}")
else() else()
set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_SHARED_LINKER_FLAGS=${${pkg_name}_LDFLAGS}") set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_SHARED_LINKER_FLAGS=${${pkg_name}_LDFLAGS}")
endif()
endif()
if(APPLE)
__exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION}
${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS}
-DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install --
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
else()
__exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} -G ${CMAKE_GENERATOR}
endif ()
endif ()

__exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} -G ${CMAKE_GENERATOR}
${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS} ${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS}
-DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH}
-DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ..
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)

__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j8
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
endif()

else() else()
if(${pkg_name}_CFLAGS)
if (${pkg_name}_CFLAGS)
set(${pkg_name}_MAKE_CFLAGS "CFLAGS=${${pkg_name}_CFLAGS}") set(${pkg_name}_MAKE_CFLAGS "CFLAGS=${${pkg_name}_CFLAGS}")
endif()
if(${pkg_name}_CXXFLAGS)
endif ()
if (${pkg_name}_CXXFLAGS)
set(${pkg_name}_MAKE_CXXFLAGS "CXXFLAGS=${${pkg_name}_CXXFLAGS}") set(${pkg_name}_MAKE_CXXFLAGS "CXXFLAGS=${${pkg_name}_CXXFLAGS}")
endif()
if(${pkg_name}_LDFLAGS)
endif ()
if (${pkg_name}_LDFLAGS)
set(${pkg_name}_MAKE_LDFLAGS "LDFLAGS=${${pkg_name}_LDFLAGS}") set(${pkg_name}_MAKE_LDFLAGS "LDFLAGS=${${pkg_name}_LDFLAGS}")
endif()
endif ()
# in configure && make # in configure && make
if(PKG_PRE_CONFIGURE_COMMAND)
if (PKG_PRE_CONFIGURE_COMMAND)
__exec_cmd(COMMAND ${PKG_PRE_CONFIGURE_COMMAND} __exec_cmd(COMMAND ${PKG_PRE_CONFIGURE_COMMAND}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})
endif()
endif ()


if(PKG_CONFIGURE_COMMAND)
if (PKG_CONFIGURE_COMMAND)
__exec_cmd(COMMAND ${PKG_CONFIGURE_COMMAND} __exec_cmd(COMMAND ${PKG_CONFIGURE_COMMAND}
${${pkg_name}_MAKE_CFLAGS} ${${pkg_name}_MAKE_CXXFLAGS} ${${pkg_name}_MAKE_LDFLAGS} ${${pkg_name}_MAKE_CFLAGS} ${${pkg_name}_MAKE_CXXFLAGS} ${${pkg_name}_MAKE_LDFLAGS}
--prefix=${${pkg_name}_BASE_DIR} --prefix=${${pkg_name}_BASE_DIR}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})
endif()
endif ()
set(${pkg_name}_BUILD_OPTION ${PKG_BUILD_OPTION}) set(${pkg_name}_BUILD_OPTION ${PKG_BUILD_OPTION})
if(NOT PKG_CONFIGURE_COMMAND)
if (NOT PKG_CONFIGURE_COMMAND)
set(${pkg_name}_BUILD_OPTION ${${pkg_name}_BUILD_OPTION} set(${pkg_name}_BUILD_OPTION ${${pkg_name}_BUILD_OPTION}
${${pkg_name}_MAKE_CFLAGS} ${${pkg_name}_MAKE_CXXFLAGS} ${${pkg_name}_MAKE_LDFLAGS}) ${${pkg_name}_MAKE_CFLAGS} ${${pkg_name}_MAKE_CXXFLAGS} ${${pkg_name}_MAKE_LDFLAGS})
endif()
endif ()
# build # build
if(APPLE)
__exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} ${${pkg_name}_BUILD_OPTION}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})
else()
__exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} ${${pkg_name}_BUILD_OPTION} -j${THNUM}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})
endif()
__exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} ${${pkg_name}_BUILD_OPTION} -j8
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})


if(PKG_INSTALL_INCS OR PKG_INSTALL_LIBS)
if (PKG_INSTALL_INCS OR PKG_INSTALL_LIBS)
file(GLOB ${pkg_name}_INSTALL_INCS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_INCS}) file(GLOB ${pkg_name}_INSTALL_INCS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_INCS})
file(GLOB ${pkg_name}_INSTALL_LIBS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_LIBS}) file(GLOB ${pkg_name}_INSTALL_LIBS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_LIBS})
file(COPY ${${pkg_name}_INSTALL_INCS} DESTINATION ${${pkg_name}_BASE_DIR}/include) file(COPY ${${pkg_name}_INSTALL_INCS} DESTINATION ${${pkg_name}_BASE_DIR}/include)
file(COPY ${${pkg_name}_INSTALL_LIBS} DESTINATION ${${pkg_name}_BASE_DIR}/lib) file(COPY ${${pkg_name}_INSTALL_LIBS} DESTINATION ${${pkg_name}_BASE_DIR}/lib)
else() else()
__exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} install WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) __exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} install WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR})
endif()
endif()
endif ()
endif ()
endif() endif()


if(PKG_LIBS)
__find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIB_PATH} ${PKG_LIBS})
if (PKG_LIBS)
__find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIBS})
set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE)
if(NOT ${pkg_name}_LIBS) if(NOT ${pkg_name}_LIBS)
message(FATAL_ERROR "Can not find pkg: ${pkg_name}") message(FATAL_ERROR "Can not find pkg: ${pkg_name}")
endif() endif()
else() else()
find_package(${__FIND_PKG_NAME} ${PKG_VER} QUIET ${MS_FIND_NO_DEFAULT_PATH}) find_package(${__FIND_PKG_NAME} ${PKG_VER} QUIET ${MS_FIND_NO_DEFAULT_PATH})
if(${__FIND_PKG_NAME}_FOUND)
if (${__FIND_PKG_NAME}_FOUND)
set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE)
message("Found pkg: ${${__FIND_PKG_NAME}_LIBRARIES}") message("Found pkg: ${${__FIND_PKG_NAME}_LIBRARIES}")
return() return()
endif()
endif()
endif ()
endif ()
endfunction() endfunction()

+ 0
- 12
config/data_dump.json View File

@@ -1,12 +0,0 @@
{
"common_dump_settings": {
"dump_mode": 0,
"path": "/test",
"net_name": "ResNet50",
"iteration": "0",
"input_output": 2,
"kernels": ["Default/Conv-op12"],
"support_device": [0,1,2,3,4,5,6,7],
"op_debug_mode": 0
}
}

+ 22
- 0
config/e2e_dump_config.json View File

@@ -0,0 +1,22 @@
{
"DumpSettings": {
"enable": false,
"trans_flag": false,
"path": "/tmp/net/",
"net_name": "ResNet50",
"mode": 0,
"iteration": 0,
"kernels": ["TensorAdd"]
},

"DumpSettingsSpec": {
"enable": "true: dump enable false: dump disable",
"trans_flag": "true: trans to host format,false: not trans format",
"path": "the dump file folder",
"net_name": "net name eg:ResNet50",
"mode": "0: dump all kernels 1: dump kernels in kernels list",
"iteration": "0: all iteration others: specified iteration ",
"kernels": "kernel name list need to be dump"
},
"other": {}
}

+ 22
- 0
config/e2e_dump_config_0.json View File

@@ -0,0 +1,22 @@
{
"DumpSettings": {
"enable": false,
"trans_flag": false,
"path": "/tmp/hccllog/0",
"net_name": "ResNet50",
"mode": 0,
"iteration": 0,
"kernels": ["AllReduce","BiasAddGrad","Conv2DBackpropFilter","SparseSoftmaxCrossEntropyWithLogits"]
},

"DumpSettingsSpec": {
"enable": "true: dump enable false: dump disable",
"trans_flag": "true: trans to host format,false: not trans format",
"path": "the dump file folder",
"net_name": "net name eg:ResNet50",
"mode": "0: dump all kernels 1: dump kernels in kernels list",
"iteration": "0: all iteration others: specified iteration ",
"kernels": "kernel name list need to be dump"
},
"other": {}
}

+ 22
- 0
config/e2e_dump_config_1.json View File

@@ -0,0 +1,22 @@
{
"DumpSettings": {
"enable": false,
"trans_flag": false,
"path": "/tmp/hccllog/1",
"net_name": "ResNet50",
"mode": 0,
"iteration": 0,
"kernels": ["AllReduce","BiasAddGrad","Conv2DBackpropFilter","SparseSoftmaxCrossEntropyWithLogits"]
},

"DumpSettingsSpec": {
"enable": "true: dump enable false: dump disable",
"trans_flag": "true: trans to host format,false: not trans format",
"path": "the dump file folder",
"net_name": "net name eg:ResNet50",
"mode": "0: dump all kernels 1: dump kernels in kernels list",
"iteration": "0: all iteration others: specified iteration ",
"kernels": "kernel name list need to be dump"
},
"other": {}
}

+ 0
- 742
config/op_info.config
File diff suppressed because it is too large
View File


+ 120
- 0
dbg_dump_parser.sh View File

@@ -0,0 +1,120 @@
#!/bin/bash
# Copyright 2019 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.
# ============================================================================

set -x
set -e

export SAVE_GRAPHS=YES

# print usage message
function usage()
{
echo "Usage:"
echo "bash $0 [-g] [-d] [-a] [-h] [-f file]"
echo "e.g. $0 -f 3_specialize.dat"
echo ""
echo "Options:"
echo " -g Generate ir file for debug"
echo " -d Debug dumped ir"
echo " -a Execute all steps, default"
echo " -f File to be parse"
echo " -h Print usage"
}

# check and set options
function checkopts()
{
# init variable
MODE_GEN=0
MODE_DBG=1
MODE_ALL=2
FILE_NAME="3_optimize.dat"
mode="${MODE_ALL}" # default execute all steps

# Process the options
while getopts 'gdaf:h' opt
do
case "${opt}" in
g)
mode="${MODE_GEN}"
;;
d)
mode="${MODE_DBG}"
;;
a)
mode="${MODE_ALL}"
;;
f)
FILE_NAME="$OPTARG"
if ! [ -f "${FILE_NAME}" ]; then
echo "File $FILE_NAME does not exist"
usage
exit 1
fi
;;
h)
usage
exit 0
;;
*)
echo "Unknown option ${opt}!"
usage
exit 1
esac
done
}

# init variable
# check options
checkopts "$@"


cd build/mindspore/
make -j8
cp -v mindspore/ccsrc/_c_expression.cpython-*.so ../../mindspore/
cd -

UT_NAME="./tests/ut/python/model/test_lenet.py::test_lenet5_train_sens"
#UT_NAME="./tests/python/ops/test_math_ops.py::test_matmul_grad"
#UT_NAME="./tests/python/exec/resnet_example.py::test_compile"
#UT_NAME="./tests/perf_test/test_bert_train.py::test_bert_train"

if [[ "${mode}" == "${MODE_GEN}" || "${mode}" == "${MODE_ALL}" ]]; then
rm -rf pkl_objs
mkdir -p pkl_objs

echo "MS_IR_PATH=$(pwd)/pkl_objs pytest -s ${UT_NAME}"
MS_IR_PATH=$(pwd)/pkl_objs/ pytest -s "${UT_NAME}"
#pytest -s $UT_NAME

# 1_resolve.dat
# 3_specialize.dat
# 4_simplify_data_structures.dat
# 5_opt.dat
# 6_opt2.dat
# 7_opt_ge_adaptor_special.dat
# 8_cconv.dat
# 9_validate.dat
cp "${FILE_NAME}" anf_ir_file.dbg

rm -rf pkl_objs.dbg
cp -rf pkl_objs pkl_objs.dbg
fi

if [[ "${mode}" == "${MODE_DBG}" || "${mode}" == "${MODE_ALL}" ]]; then
echo "MS_IR_FILE=$(pwd)/anf_ir_file.dbg MS_IR_PATH=$(pwd)/pkl_objs.dbg/ pytest -s ${UT_NAME}"
MS_IR_FILE=$(pwd)/anf_ir_file.dbg MS_IR_PATH=$(pwd)/pkl_objs.dbg/ pytest -s "${UT_NAME}"
fi

BIN
docs/Automatic-parallel.png View File

Before After
Width: 763  |  Height: 657  |  Size: 36 kB Width: 751  |  Height: 648  |  Size: 124 kB

BIN
docs/MindSpore-Lite-architecture.png View File

Before After
Width: 796  |  Height: 851  |  Size: 56 kB

BIN
docs/MindSpore-architecture-zh.png View File

Before After
Width: 898  |  Height: 468  |  Size: 37 kB

BIN
docs/MindSpore-architecture.png View File

Before After
Width: 911  |  Height: 519  |  Size: 45 kB Width: 1069  |  Height: 639  |  Size: 54 kB

+ 0
- 9
docs/OWNERS View File

@@ -1,9 +0,0 @@
approvers:
- gemini524
- Hanshize
- rudy_tan
- jonyguo
- lvyufenghw
- zh_qh
- liangchenghui
- tiancixiao

BIN
docs/api/api_python/dataset/browse_dataset.png View File

Before After
Width: 1636  |  Height: 304  |  Size: 880 kB

+ 0
- 15
docs/api/api_python/dataset/mindspore.dataset.BatchInfo.rst View File

@@ -1,15 +0,0 @@
mindspore.dataset.BatchInfo
===========================
.. py:class:: mindspore.dataset.BatchInfo
此类提供了两种方法获取数据集的批处理数量(batch size)和迭代数(epoch)属性。
这些属性可以用于 `batch` 操作中的输入参数 `batch_size` 和 `per_batch_map`。
.. py:method:: get_batch_num()
返回数据集的批处理数量(batch size)。
.. py:method:: get_epoch_num()
返回数据集的迭代数(epoch)。

+ 0
- 43
docs/api/api_python/dataset/mindspore.dataset.BuiltinSampler.b.rst View File

@@ -1,43 +0,0 @@

.. py:method:: get_num_samples()

返回采样器采集样本数量,如果存在子采样器,则子采样器计数可以是数值或None。这些条件会影响最终的采样结果。

下表显示了调用此函数的可能结果。

.. list-table::
:widths: 25 25 25 25
:header-rows: 1

* - 子采样器
- num_samples
- child_samples
- 结果
* - T
- x
- y
- min(x, y)
* - T
- x
- None
- x
* - T
- None
- y
- y
* - T
- None
- None
- None
* - None
- x
- n/a
- x
* - None
- None
- n/a
- None

**返回:**

int,样本数,可为None。

+ 0
- 11
docs/api/api_python/dataset/mindspore.dataset.BuiltinSampler.rst View File

@@ -1,11 +0,0 @@
.. py:method:: add_child(sampler)

为给定采样器添加子采样器。子采样器接收父采样器输出数据作为输入,并应用其采样逻辑返回新的采样结果。

**参数:**

- **sampler** (Sampler) - 用于从数据集中选择样本的对象。仅支持内置采样器(DistributedSampler、PKSampler、RandomSampler、SequentialSampler、SubsetRandomSampler、WeightedRandomSampler)。

.. py:method:: get_child()

获取给定采样器的子采样器。

+ 0
- 217
docs/api/api_python/dataset/mindspore.dataset.CLUEDataset.rst View File

@@ -1,217 +0,0 @@
mindspore.dataset.CLUEDataset
=============================
.. py:class:: mindspore.dataset.CLUEDataset(dataset_files, task='AFQMC', usage='train', num_samples=None, num_parallel_workers=None, shuffle=Shuffle.GLOBAL, num_shards=None, shard_id=None, cache=None)
读取和解析CLUE数据集的源文件构建数据集。
目前支持的CLUE分类任务包括:'AFQMC'、'TNEWS 、'IFLYTEK'、'CMNLI'、'WSC'和'CSL'。更多CLUE数据集的说明详见 `CLUE GitHub <https://github.com/CLUEbenchmark/CLUE>`_ 。
**参数:**
- **dataset_files** (Union[str, list[str]]) - 数据集文件路径,支持单文件路径字符串、多文件路径字符串列表或可被glob库模式匹配的字符串,文件列表将在内部进行字典排序。
- **task** (str, 可选) - 任务类型,可取值为 'AFQMC' 、'TNEWS'、'IFLYTEK'、'CMNLI'、'WSC' 或 'CSL'。默认值:'AFQMC'。
- **usage** (str, 可选) - 指定数据集的子集,可取值为'train','test'或'eval',默认值:'train'。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数。默认值:None,读取所有样本。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值:None,使用mindspore.dataset.config中配置的线程数。
- **shuffle** (Union[bool, Shuffle], 可选) - 每个epoch中数据混洗的模式,支持传入bool类型与枚举类型进行指定,默认值:mindspore.dataset.Shuffle.GLOBAL。
如果 `shuffle` 为False,则不混洗,如果 `shuffle` 为True,等同于将 `shuffle` 设置为mindspore.dataset.Shuffle.GLOBAL。
通过传入枚举变量设置数据混洗的模式:
- **Shuffle.GLOBAL**:混洗文件和样本。
- **Shuffle.FILES**:仅混洗文件。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数,默认值:None。指定此参数后, `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号,默认值:None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值:None,不使用缓存。
根据给定的 `task` 参数 和 `usage` 配置,数据集会生成不同的输出列:
+-------------------------+------------------------------+-----------------------------+
| `task` | `usage` | 输出列 |
+=========================+==============================+=============================+
| AFQMC | train | [sentence1, dtype=string] |
| | | |
| | | [sentence2, dtype=string] |
| | | |
| | | [label, dtype=string] |
| +------------------------------+-----------------------------+
| | test | [id, dtype=uint32] |
| | | |
| | | [sentence1, dtype=string] |
| | | |
| | | [sentence2, dtype=string] |
| +------------------------------+-----------------------------+
| | eval | [sentence1, dtype=string] |
| | | |
| | | [sentence2, dtype=string] |
| | | |
| | | [label, dtype=string] |
+-------------------------+------------------------------+-----------------------------+
| TNEWS | train | [label, dtype=string] |
| | | |
| | | [label_des, dtype=string] |
| | | |
| | | [sentence, dtype=string] |
| | | |
| | | [keywords, dtype=string] |
| +------------------------------+-----------------------------+
| | test | [label, dtype=uint32] |
| | | |
| | | [keywords, dtype=string] |
| | | |
| | | [sentence, dtype=string] |
| +------------------------------+-----------------------------+
| | eval | [label, dtype=string] |
| | | |
| | | [label_des, dtype=string] |
| | | |
| | | [sentence, dtype=string] |
| | | |
| | | [keywords, dtype=string] |
+-------------------------+------------------------------+-----------------------------+
| IFLYTEK | train | [label, dtype=string] |
| | | |
| | | [label_des, dtype=string] |
| | | |
| | | [sentence, dtype=string] |
| +------------------------------+-----------------------------+
| | test | [id, dtype=uint32] |
| | | |
| | | [sentence, dtype=string] |
| +------------------------------+-----------------------------+
| | eval | [label, dtype=string] |
| | | |
| | | [label_des, dtype=string] |
| | | |
| | | [sentence, dtype=string] |
+-------------------------+------------------------------+-----------------------------+
| CMNLI | train | [sentence1, dtype=string] |
| | | |
| | | [sentence2, dtype=string] |
| | | |
| | | [label, dtype=string] |
| +------------------------------+-----------------------------+
| | test | [id, dtype=uint32] |
| | | |
| | | [sentence1, dtype=string] |
| | | |
| | | [sentence2, dtype=string] |
| +------------------------------+-----------------------------+
| | eval | [sentence1, dtype=string] |
| | | |
| | | [sentence2, dtype=string] |
| | | |
| | | [label, dtype=string] |
+-------------------------+------------------------------+-----------------------------+
| WSC | train | [span1_index, dtype=uint32]|
| | | |
| | | [span2_index, dtype=uint32]|
| | | |
| | | [span1_text, dtype=string] |
| | | |
| | | [span2_text, dtype=string] |
| | | |
| | | [idx, dtype=uint32] |
| | | |
| | | [text, dtype=string] |
| | | |
| | | [label, dtype=string] |
| +------------------------------+-----------------------------+
| | test | [span1_index, dtype=uint32]|
| | | |
| | | [span2_index, dtype=uint32]|
| | | |
| | | [span1_text, dtype=string] |
| | | |
| | | [span2_text, dtype=string] |
| | | |
| | | [idx, dtype=uint32] |
| | | |
| | | [text, dtype=string] |
| +------------------------------+-----------------------------+
| | eval | [span1_index, dtype=uint32]|
| | | |
| | | [span2_index, dtype=uint32]|
| | | |
| | | [span1_text, dtype=string] |
| | | |
| | | [span2_text, dtype=string] |
| | | |
| | | [idx, dtype=uint32] |
| | | |
| | | [text, dtype=string] |
| | | |
| | | [label, dtype=string] |
+-------------------------+------------------------------+-----------------------------+
| CSL | train | [id, dtype=uint32] |
| | | |
| | | [abst, dtype=string] |
| | | |
| | | [keyword, dtype=string] |
| | | |
| | | [label, dtype=string] |
| +------------------------------+-----------------------------+
| | test | [id, dtype=uint32] |
| | | |
| | | [abst, dtype=string] |
| | | |
| | | [keyword, dtype=string] |
| +------------------------------+-----------------------------+
| | eval | [id, dtype=uint32] |
| | | |
| | | [abst, dtype=string] |
| | | |
| | | [keyword, dtype=string] |
| | | |
| | | [label, dtype=string] |
+-------------------------+------------------------------+-----------------------------+
**异常:**
- **ValueError** - `dataset_files` 参数所指向的文件无效或不存在。
- **ValueError** - `task` 参数不为 'AFQMC'、'TNEWS'、'IFLYTEK'、'CMNLI'、'WSC' 或 'CSL'。
- **ValueError** - `usage` 参数不为 'train'、'test' 或 'eval'。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数错误(小于0或者大于等于 `num_shards` )。
**关于CLUE数据集:**
CLUE,又名中文语言理解测评基准,包含许多有代表性的数据集,涵盖单句分类、句对分类和机器阅读理解等任务。
您可以将数据集解压成如下的文件结构,并通过MindSpore的API进行读取,以 'afqmc' 数据集为例:
.. code-block::
.
└── afqmc_public
├── train.json
├── test.json
└── dev.json
**引用:**
.. code-block::
@article{CLUEbenchmark,
title = {CLUE: A Chinese Language Understanding Evaluation Benchmark},
author = {Liang Xu, Xuanwei Zhang, Lu Li, Hai Hu, Chenjie Cao, Weitang Liu, Junyi Li, Yudong Li,
Kai Sun, Yechen Xu, Yiming Cui, Cong Yu, Qianqian Dong, Yin Tian, Dian Yu, Bo Shi, Jun Zeng,
Rongzhao Wang, Weijian Xie, Yanting Li, Yina Patterson, Zuoyu Tian, Yiwen Zhang, He Zhou,
Shaoweihua Liu, Qipeng Zhao, Cong Yue, Xinrui Zhang, Zhengliang Yang, Zhenzhong Lan},
journal = {arXiv preprint arXiv:2004.05986},
year = {2020},
howpublished = {https://github.com/CLUEbenchmark/CLUE}
}
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.b.rst
.. include:: mindspore.dataset.Dataset.c.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.zip.rst

+ 0
- 44
docs/api/api_python/dataset/mindspore.dataset.CSVDataset.rst View File

@@ -1,44 +0,0 @@
mindspore.dataset.CSVDataset
=============================
.. py:class:: mindspore.dataset.CSVDataset(dataset_files, field_delim=',', column_defaults=None, column_names=None, num_samples=None, num_parallel_workers=None, shuffle=Shuffle.GLOBAL, num_shards=None, shard_id=None, cache=None)
读取和解析CSV数据文件构建数据集。生成的数据集的列名和列类型取决于输入的CSV文件。
**参数:**
- **dataset_files** (Union[str, list[str]]) - 数据集文件路径,支持单文件路径字符串、多文件路径字符串列表或可被glob库模式匹配的字符串,文件列表将在内部进行字典排序。
- **field_delim** (str, 可选) - 指定用于分隔字段的分隔符,默认值:','。
- **column_defaults** (list, 可选) - 指定每个数据列的数据类型,有效的类型包括float、int或string。默认值:None,不指定。如果未指定该参数,则所有列的数据类型将被视为string。
- **column_names** (list[str], 可选) - 指定数据集生成的列名。默认值:None,不指定。如果未指定该列表,则将CSV文件首行提供的字段作为列名生成。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数。默认值:None,读取全部样本。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值:None,使用mindspore.dataset.config中配置的线程数。
- **shuffle** (Union[bool, Shuffle], 可选) - 每个epoch中数据混洗的模式,支持传入bool类型与枚举类型进行指定,默认值:mindspore.dataset.Shuffle.GLOBAL。
如果 `shuffle` 为False,则不混洗,如果 `shuffle` 为True,等同于将 `shuffle` 设置为mindspore.dataset.Shuffle.GLOBAL。
通过传入枚举变量设置数据混洗的模式:
- **Shuffle.GLOBAL**:混洗文件和文件中的数据。
- **Shuffle.FILES**:仅混洗文件。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数,默认值:None。指定此参数后, `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号,默认值:None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值:None,不使用缓存。
**异常:**
- **RuntimeError** - `dataset_files` 参数所指向的文件无效或不存在。
- **ValueError** - `field_delim` 参数无效。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数错误(小于0或者大于等于 `num_shards` )。
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.b.rst
.. include:: mindspore.dataset.Dataset.c.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.zip.rst

+ 0
- 127
docs/api/api_python/dataset/mindspore.dataset.Caltech101Dataset.rst View File

@@ -1,127 +0,0 @@
mindspore.dataset.Caltech101Dataset
===================================
.. py:class:: mindspore.dataset.Caltech101Dataset(dataset_dir, target_type=None, num_samples=None, num_parallel_workers=1, shuffle=None, decode=False, sampler=None, num_shards=None, shard_id=None)
读取和解析Caltech101数据集的源文件构建数据集。
根据不同的 `target_type` 配置,数据集会生成不同的输出列。
- `target_type` = 'category',输出列为 `[image, category]` 。
- `target_type` = 'annotation',输出列为 `[image, annotation]` 。
- `target_type` = 'all',输出列为 `[image, category, annotation]` 。
列 'image' 为 uint8 类型,列 'category' 为 uint32 类型,列 'annotation' 是一个二维的ndarray,存储了图像的轮廓,由一系列的点组成。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径,该路径下将包含2个子目录,目录101_ObjectCategories用于存储图像,
目录Annotations用于存储图像的标注。
- **target_type** (str, 可选) - 指定数据集的子集,可取值为'category'、'annotation' 或 'all'。
取值为'category'时将读取图像的类别标注作为label,取值为'annotation'时将读取图像的轮廓标注作为label,
取值为'all'时将同时输出图像的类别标注和轮廓标注。默认值:None,表示'category'。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数,可以小于数据集总数。默认值:None,读取全部样本图片。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值:None,使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值:None,下表中会展示不同参数配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作,默认值:False,不解码。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器,默认值:None,下表中会展示不同配置的预期行为。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数,默认值:None。指定此参数后, `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号,默认值:None。只有当指定了 `num_shards` 时才能指定此参数。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `target_type` 参数取值不为'category'、'annotation'或'all'。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 同时指定了 `sampler` 和 `shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler` 和 `num_shards` 参数或同时指定了 `sampler` 和 `shard_id` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数值错误(小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler` 和 `shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于Caltech101数据集:**
Caltech101数据集包含 101 种类别的图片,每种类别大约 40 到 800 张图像,大多数类别有大约 50 张图像。
每张图像的大小约为 300 x 200 像素。数据集中也提供了每张图片中每个物体的轮廓数据,用于检测和定位。
您可以解压缩原始Caltech101数据集文件到如下目录结构,并通过MindSpore的API进行读取。
.. code-block::
.
└── caltech101_dataset_directory
├── 101_ObjectCategories
│ ├── Faces
│ │ ├── image_0001.jpg
│ │ ├── image_0002.jpg
│ │ ...
│ ├── Faces_easy
│ │ ├── image_0001.jpg
│ │ ├── image_0002.jpg
│ │ ...
│ ├── ...
└── Annotations
├── Airplanes_Side_2
│ ├── annotation_0001.mat
│ ├── annotation_0002.mat
│ ...
├── Faces_2
│ ├── annotation_0001.mat
│ ├── annotation_0002.mat
│ ...
├── ...
**引用:**
.. code-block::
@article{FeiFei2004LearningGV,
author = {Li Fei-Fei and Rob Fergus and Pietro Perona},
title = {Learning Generative Visual Models from Few Training Examples:
An Incremental Bayesian Approach Tested on 101 Object Categories},
journal = {Computer Vision and Pattern Recognition Workshop},
year = {2004},
url = {http://www.vision.caltech.edu/Image_Datasets/Caltech101/},
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.b.rst
.. include:: mindspore.dataset.Dataset.c.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

+ 0
- 112
docs/api/api_python/dataset/mindspore.dataset.Caltech256Dataset.rst View File

@@ -1,112 +0,0 @@
mindspore.dataset.Caltech256Dataset
===================================
.. py:class:: mindspore.dataset.Caltech256Dataset(dataset_dir, num_samples=None, num_parallel_workers=None, shuffle=None, decode=False, sampler=None, num_shards=None, shard_id=None, cache=None)
读取和解析Caltech256数据集的源文件构建数据集。
生成的数据集有两列 `[image, label]` 。 `image` 列的数据类型为uint8。`label` 列的数据类型为uint32。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数,可以小于数据集总数。默认值:None,读取全部样本图片。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值:None,使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值:None,下表中会展示不同参数配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作,默认值:False,不解码。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器,默认值:None,下表中会展示不同配置的预期行为。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数,默认值:None。指定此参数后, `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号,默认值:None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值:None,不使用缓存。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `target_type` 参数取值不为'category'、'annotation'或'all'。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **RuntimeError** - 同时指定了 `sampler` 和 `shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler` 和 `num_shards` 参数或同时指定了 `sampler` 和 `shard_id` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数值错误(小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler` 和 `shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于Caltech256数据集:**
Caltech-256 是一个对象识别数据集,包含 30,607 张不同大小的真实世界图像,共有 257 个类别(256类物体和1个其他类),
每个类别由至少 80 张图像。该数据集是 Caltech101 数据集的超集。
您可以解压缩原始Caltech256数据集文件到如下目录结构,并通过MindSpore的API进行读取。
.. code-block::
.
└── caltech256_dataset_directory
├── 001.ak47
│ ├── 001_0001.jpg
│ ├── 001_0002.jpg
│ ...
├── 002.american-flag
│ ├── 002_0001.jpg
│ ├── 002_0002.jpg
│ ...
├── 003.backpack
│ ├── 003_0001.jpg
│ ├── 003_0002.jpg
│ ...
├── ...
**引用:**
.. code-block::
@article{griffin2007caltech,
title = {Caltech-256 object category dataset},
added-at = {2021-01-21T02:54:42.000+0100},
author = {Griffin, Gregory and Holub, Alex and Perona, Pietro},
biburl = {https://www.bibsonomy.org/bibtex/21f746f23ff0307826cca3e3be45f8de7/s364315},
interhash = {bfe1e648c1778c04baa60f23d1223375},
intrahash = {1f746f23ff0307826cca3e3be45f8de7},
publisher = {California Institute of Technology},
timestamp = {2021-01-21T02:54:42.000+0100},
year = {2007}
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.b.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

+ 0
- 132
docs/api/api_python/dataset/mindspore.dataset.CelebADataset.rst View File

@@ -1,132 +0,0 @@
mindspore.dataset.CelebADataset
===============================
.. py:class:: mindspore.dataset.CelebADataset(dataset_dir, num_parallel_workers=None, shuffle=None, usage='all', sampler=None, decode=False, extensions=None, num_samples=None, num_shards=None, shard_id=None, cache=None)
读取和解析CelebA数据集的源文件构建数据集。目前仅支持解析CelebA数据集中的 `list_attr_celeba.txt` 文件作为数据集的label。
生成的数据集有两列 `[image, attr]` 。 `image` 列的数据类型为uint8。`attr` 列的数据类型为uint32,并以one-hot编码的形式生成。
**参数:**
- **dataset_dir** (str) - 包含数据集文件的根目录路径。
- **num_parallel_workers** (int, 可选) - 指定读取数据的工作线程数。默认值:None,使用mindspore.dataset.config中配置的线程数。
- **shuffle** (bool, 可选) - 是否混洗数据集。默认值:None,下表中会展示不同参数配置的预期行为。
- **usage** (str, 可选) - 指定数据集的子集,可取值为'train','valid','test'或'all'。默认值:'all',全部样本图片。
- **sampler** (Sampler, 可选) - 指定从数据集中选取样本的采样器,默认值:None,下表中会展示不同配置的预期行为。
- **decode** (bool, 可选) - 是否对读取的图片进行解码操作,默认值:False,不解码。
- **extensions** (list[str], 可选) - 指定文件的扩展名,仅读取与指定扩展名匹配的文件到数据集中,默认值:None。
- **num_samples** (int, 可选) - 指定从数据集中读取的样本数,可以小于数据集总数。默认值:None,读取全部样本图片。
- **num_shards** (int, 可选) - 指定分布式训练时将数据集进行划分的分片数,默认值:None。指定此参数后, `num_samples` 表示每个分片的最大样本数。
- **shard_id** (int, 可选) - 指定分布式训练时使用的分片ID号,默认值:None。只有当指定了 `num_shards` 时才能指定此参数。
- **cache** (DatasetCache, 可选) - 单节点数据缓存服务,用于加快数据集处理,详情请阅读 `单节点数据缓存 <https://www.mindspore.cn/docs/programming_guide/zh-CN/master/cache.html>`_ 。默认值:None,不使用缓存。
**异常:**
- **RuntimeError** - `dataset_dir` 路径下不包含任何数据文件。
- **ValueError** - `num_parallel_workers` 参数超过系统最大线程数。
- **ValueError** - `usage` 参数取值不为'train'、'valid'、'test'或'all'。
- **RuntimeError** - 同时指定了 `sampler` 和 `shuffle` 参数。
- **RuntimeError** - 同时指定了 `sampler` 和 `num_shards` 参数或同时指定了 `sampler` 和 `shard_id` 参数。
- **RuntimeError** - 指定了 `num_shards` 参数,但是未指定 `shard_id` 参数。
- **RuntimeError** - 指定了 `shard_id` 参数,但是未指定 `num_shards` 参数。
- **ValueError** - `shard_id` 参数值错误(小于0或者大于等于 `num_shards` )。
.. note:: 此数据集可以指定参数 `sampler` ,但参数 `sampler` 和参数 `shuffle` 的行为是互斥的。下表展示了几种合法的输入参数组合及预期的行为。
.. list-table:: 配置 `sampler` 和 `shuffle` 的不同组合得到的预期排序结果
:widths: 25 25 50
:header-rows: 1
* - 参数 `sampler`
- 参数 `shuffle`
- 预期数据顺序
* - None
- None
- 随机排列
* - None
- True
- 随机排列
* - None
- False
- 顺序排列
* - `sampler` 实例
- None
- 由 `sampler` 行为定义的顺序
* - `sampler` 实例
- True
- 不允许
* - `sampler` 实例
- False
- 不允许
**关于CelebA数据集:**
CelebFaces Attributes Dataset(CelebA)数据集是一个大规模的人脸属性数据集,拥有超过20万张名人图像,每个图像都有40个属性标注。此数据集包含了大量不同姿态、各种背景的人脸图像,种类丰富、数量庞大、标注充分。数据集总体包含:
- 10177个不同的身份
- 202599张人脸图像
- 每张图像拥有5个五官位置标注,40个属性标签
此数据集可用于各种计算机视觉任务的训练和测试,包括人脸识别、人脸检测、五官定位、人脸编辑和合成等。
原始CelebA数据集结构:
.. code-block::
.
└── CelebA
├── README.md
├── Img
│ ├── img_celeba.7z
│ ├── img_align_celeba_png.7z
│ └── img_align_celeba.zip
├── Eval
│ └── list_eval_partition.txt
└── Anno
├── list_landmarks_celeba.txt
├── list_landmarks_align_celeba.txt
├── list_bbox_celeba.txt
├── list_attr_celeba.txt
└── identity_CelebA.txt
您可以将上述Anno目录下的txt文件与Img目录下的文件解压放至同一目录,并通过MindSpore的API进行读取。
.. code-block::
.
└── celeba_dataset_directory
├── list_attr_celeba.txt
├── 000001.jpg
├── 000002.jpg
├── 000003.jpg
├── ...
**引用:**
.. code-block::
@article{DBLP:journals/corr/LiuLWT14,
author = {Ziwei Liu and Ping Luo and Xiaogang Wang and Xiaoou Tang},
title = {Deep Learning Face Attributes in the Wild},
journal = {CoRR},
volume = {abs/1411.7766},
year = {2014},
url = {http://arxiv.org/abs/1411.7766},
archivePrefix = {arXiv},
eprint = {1411.7766},
timestamp = {Tue, 10 Dec 2019 15:37:26 +0100},
biburl = {https://dblp.org/rec/journals/corr/LiuLWT14.bib},
bibsource = {dblp computer science bibliography, https://dblp.org},
howpublished = {http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html}
}
.. include:: mindspore.dataset.Dataset.add_sampler.rst
.. include:: mindspore.dataset.Dataset.rst
.. include:: mindspore.dataset.Dataset.d.rst
.. include:: mindspore.dataset.Dataset.use_sampler.rst
.. include:: mindspore.dataset.Dataset.zip.rst

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save