Browse Source

Move some basic type defines to mindapi

tags/v1.6.0
He Wei 4 years ago
parent
commit
d28b189495
6 changed files with 197 additions and 82 deletions
  1. +20
    -4
      cmake/package_lite.cmake
  2. +5
    -23
      include/api/format.h
  3. +44
    -0
      mindspore/core/mindapi/base/format.h
  4. +118
    -0
      mindspore/core/mindapi/base/types.h
  5. +8
    -55
      mindspore/core/utils/check_convert_utils.h
  6. +2
    -0
      mindspore/lite/src/CMakeLists.txt

+ 20
- 4
cmake/package_lite.cmake View File

@@ -226,7 +226,11 @@ if(PLATFORM_ARM64)
endif()
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${RUNTIME_INC_DIR}/ir/dtype
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/core/mindapi/base/type_id.h DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
install(FILES
${TOP_DIR}/mindspore/core/mindapi/base/format.h
${TOP_DIR}/mindspore/core/mindapi/base/type_id.h
${TOP_DIR}/mindspore/core/mindapi/base/types.h
DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)
@@ -327,7 +331,11 @@ elseif(PLATFORM_ARM32)
endif()
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${RUNTIME_INC_DIR}/ir/dtype
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/core/mindapi/base/type_id.h DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
install(FILES
${TOP_DIR}/mindspore/core/mindapi/base/format.h
${TOP_DIR}/mindspore/core/mindapi/base/type_id.h
${TOP_DIR}/mindspore/core/mindapi/base/types.h
DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)
@@ -416,7 +424,11 @@ elseif(WIN32)
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${RUNTIME_INC_DIR}/ir/dtype
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/core/mindapi/base/type_id.h DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
install(FILES
${TOP_DIR}/mindspore/core/mindapi/base/format.h
${TOP_DIR}/mindspore/core/mindapi/base/type_id.h
${TOP_DIR}/mindspore/core/mindapi/base/types.h
DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)
@@ -462,7 +474,11 @@ else()
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${RUNTIME_INC_DIR}/ir/dtype
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/core/mindapi/base/type_id.h DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
install(FILES
${TOP_DIR}/mindspore/core/mindapi/base/format.h
${TOP_DIR}/mindspore/core/mindapi/base/type_id.h
${TOP_DIR}/mindspore/core/mindapi/base/types.h
DESTINATION ${RUNTIME_INC_DIR}/mindapi/base
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)


+ 5
- 23
include/api/format.h View File

@@ -19,28 +19,10 @@
#ifndef MINDSPORE_INCLUDE_API_FORMAT_H
#define MINDSPORE_INCLUDE_API_FORMAT_H

#include <cstdint>
#if __has_include("include/mindapi/base/format.h")
#include "include/mindapi/base/format.h"
#else
#include "mindapi/base/format.h"
#endif

namespace mindspore {
enum Format : int64_t {
NCHW = 0,
NHWC = 1,
NHWC4 = 2,
HWKC = 3,
HWCK = 4,
KCHW = 5,
CKHW = 6,
KHWC = 7,
CHWK = 8,
HW = 9,
HW4 = 10,
NC = 11,
NC4 = 12,
NC4HW4 = 13,
NUM_OF_FORMAT = 14,
NCDHW = 15,
NWC = 16,
NCW = 17
};
} // namespace mindspore
#endif // MINDSPORE_INCLUDE_API_FORMAT_H

+ 44
- 0
mindspore/core/mindapi/base/format.h View File

@@ -0,0 +1,44 @@
/**
* 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.
*/

#ifndef MINDSPORE_CORE_MINDAPI_BASE_FORMAT_H_
#define MINDSPORE_CORE_MINDAPI_BASE_FORMAT_H_

#include <cstdint>

namespace mindspore {
enum Format : int64_t {
NCHW = 0,
NHWC = 1,
NHWC4 = 2,
HWKC = 3,
HWCK = 4,
KCHW = 5,
CKHW = 6,
KHWC = 7,
CHWK = 8,
HW = 9,
HW4 = 10,
NC = 11,
NC4 = 12,
NC4HW4 = 13,
NUM_OF_FORMAT = 14,
NCDHW = 15,
NWC = 16,
NCW = 17,
};
} // namespace mindspore
#endif // MINDSPORE_CORE_MINDAPI_BASE_FORMAT_H_

+ 118
- 0
mindspore/core/mindapi/base/types.h View File

@@ -0,0 +1,118 @@
/**
* 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.
*/

#ifndef MINDSPORE_CORE_MINDAPI_BASE_TYPES_H_
#define MINDSPORE_CORE_MINDAPI_BASE_TYPES_H_

#include <cstdint>

namespace mindspore {
enum CoordinateTransformMode : int64_t {
ASYMMETRIC = 0,
ALIGN_CORNERS = 1,
HALF_PIXEL = 2,
CROP_AND_RESIZE = 3,
};

enum class ResizeMethod : int64_t {
UNKNOWN = -1,
LINEAR = 0,
NEAREST = 1,
CUBIC = 2,
};

enum class NearestMode : int64_t {
NORMAL = 0,
ROUND_HALF_DOWN = 1,
ROUND_HALF_UP = 2,
FLOOR = 3,
CEIL = 4,
};

enum RoundMode : int64_t {
FLOOR = 0,
CEIL = 1,
};

enum ActivationType : int64_t {
NO_ACTIVATION = 0,
RELU = 1,
SIGMOID = 2,
RELU6 = 3,
ELU = 4,
LEAKY_RELU = 5,
ABS = 6,
RELU1 = 7,
SOFTSIGN = 8,
SOFTPLUS = 9,
TANH = 10,
SELU = 11,
HSWISH = 12,
HSIGMOID = 13,
THRESHOLDRELU = 14,
LINEAR = 15,
HARD_TANH = 16,
SIGN = 17,
SWISH = 18,
GELU = 19,
GLU = 20,
UNKNOWN = 21,
};

enum ReduceMode : int64_t {
Reduce_Mean = 0,
Reduce_Max = 1,
Reduce_Min = 2,
Reduce_Prod = 3,
Reduce_Sum = 4,
Reduce_Sum_Square = 5,
Reduce_ASum = 6,
Reduce_All = 7,
};

enum EltwiseMode : int64_t {
PROD = 0,
SUM = 1,
MAXIMUM = 2,
ELTWISEMODE_UNKNOW = 3,
};

enum Reduction : int64_t {
REDUCTION_SUM = 0,
MEAN = 1,
NONE = 2,
};

enum PadMode : int64_t {
PAD = 0,
SAME = 1,
VALID = 2,
};

enum class LshProjectionType : int64_t {
UNKNOWN = 0,
SPARSE = 1,
DENSE = 2,
};

enum PaddingMode : int64_t {
CONSTANT = 0,
REFLECT = 1,
SYMMETRIC = 2,
MODE_RESERVED = 3,
};
} // namespace mindspore
#endif // MINDSPORE_CORE_MINDAPI_BASE_TYPES_H_

+ 8
- 55
mindspore/core/utils/check_convert_utils.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright 2019-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.
@@ -29,6 +29,12 @@
#include "ir/dtype/type_id.h"
#include "include/api/format.h"
#include "utils/log_adapter.h"
#if __has_include("include/mindapi/base/types.h")
#include "include/mindapi/base/types.h"
#else
#include "mindapi/base/types.h"
#endif

namespace mindspore {
typedef std::pair<std::map<std::string, int64_t>, std::map<int64_t, std::string>> AttrConverterPair;
typedef std::map<std::string, std::vector<int64_t>> ShapeMap;
@@ -51,40 +57,7 @@ enum CompareRange {
kIncludeRight = 3, // (a,b]
kIncludeBoth = 4, // [a,b]
};
enum ActivationType : int64_t {
NO_ACTIVATION = 0,
RELU = 1,
SIGMOID = 2,
RELU6 = 3,
ELU = 4,
LEAKY_RELU = 5,
ABS = 6,
RELU1 = 7,
SOFTSIGN = 8,
SOFTPLUS = 9,
TANH = 10,
SELU = 11,
HSWISH = 12,
HSIGMOID = 13,
THRESHOLDRELU = 14,
LINEAR = 15,
HARD_TANH = 16,
SIGN = 17,
SWISH = 18,
GELU = 19,
GLU = 20,
UNKNOWN = 21
};
enum ReduceMode : int64_t {
Reduce_Mean = 0,
Reduce_Max = 1,
Reduce_Min = 2,
Reduce_Prod = 3,
Reduce_Sum = 4,
Reduce_Sum_Square = 5,
Reduce_ASum = 6,
Reduce_All = 7
};

enum ReduceType : int64_t {
REDUCE_MAX = 0,
REDUCE_MEAN = 1,
@@ -95,16 +68,6 @@ enum ReduceType : int64_t {
REDUCE_SUM = 6,
REDUCE_UNKNOW = 7,
};
enum EltwiseMode : int64_t { PROD = 0, SUM = 1, MAXIMUM = 2, ELTWISEMODE_UNKNOW = 3 };

enum Reduction : int64_t { REDUCTION_SUM = 0, MEAN = 1, NONE = 2 };

enum PadMode : int64_t { PAD = 0, SAME = 1, VALID = 2 };

enum RoundMode : int64_t {
FLOOR = 0,
CEIL = 1,
};

enum PoolMode : int64_t {
MAX_POOLING = 0,
@@ -113,16 +76,6 @@ enum PoolMode : int64_t {

enum GateOrderMode : int64_t { RZH = 0, ZRH = 1 };

enum class LshProjectionType : int64_t { UNKNOWN = 0, SPARSE = 1, DENSE = 2 };

enum PaddingMode : int64_t { CONSTANT = 0, REFLECT = 1, SYMMETRIC = 2, MODE_RESERVED = 3 };

enum class ResizeMethod : int64_t { UNKNOWN = -1, LINEAR = 0, NEAREST = 1, CUBIC = 2 };

enum CoordinateTransformMode : int64_t { ASYMMETRIC = 0, ALIGN_CORNERS = 1, HALF_PIXEL = 2, CROP_AND_RESIZE = 3 };

enum class NearestMode : int64_t { NORMAL = 0, ROUND_HALF_DOWN = 1, ROUND_HALF_UP = 2, FLOOR = 3, CEIL = 4 };

template <typename T>
const std::map<CompareEnum, std::function<bool(T, T)>> kCompareMap = {
{kEqual, [](T num1, T num2) -> bool { return num1 == num2; }},


+ 2
- 0
mindspore/lite/src/CMakeLists.txt View File

@@ -299,7 +299,9 @@ if(APPLE)
${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/dtype/type_id.h
)
set(MINDSPORE_LITE_PUB_HDRS_MINDAPI_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/../../core/mindapi/base/format.h
${CMAKE_CURRENT_SOURCE_DIR}/../../core/mindapi/base/type_id.h
${CMAKE_CURRENT_SOURCE_DIR}/../../core/mindapi/base/types.h
)
add_library(mindspore-lite_static STATIC
${LITE_SRC}


Loading…
Cancel
Save