Move some basic type defines to mindapi

This commit is contained in:
He Wei 2021-12-20 16:58:09 +08:00
parent b421e46957
commit d28b189495
6 changed files with 197 additions and 82 deletions

View File

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

View File

@ -19,28 +19,10 @@
#ifndef MINDSPORE_INCLUDE_API_FORMAT_H #ifndef MINDSPORE_INCLUDE_API_FORMAT_H
#define 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 #endif // MINDSPORE_INCLUDE_API_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_

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_

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"); * 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.
@ -29,6 +29,12 @@
#include "ir/dtype/type_id.h" #include "ir/dtype/type_id.h"
#include "include/api/format.h" #include "include/api/format.h"
#include "utils/log_adapter.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 { namespace mindspore {
typedef std::pair<std::map<std::string, int64_t>, std::map<int64_t, std::string>> AttrConverterPair; 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; typedef std::map<std::string, std::vector<int64_t>> ShapeMap;
@ -51,40 +57,7 @@ enum CompareRange {
kIncludeRight = 3, // (a,b] kIncludeRight = 3, // (a,b]
kIncludeBoth = 4, // [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 { enum ReduceType : int64_t {
REDUCE_MAX = 0, REDUCE_MAX = 0,
REDUCE_MEAN = 1, REDUCE_MEAN = 1,
@ -95,16 +68,6 @@ enum ReduceType : int64_t {
REDUCE_SUM = 6, REDUCE_SUM = 6,
REDUCE_UNKNOW = 7, 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 { enum PoolMode : int64_t {
MAX_POOLING = 0, MAX_POOLING = 0,
@ -113,16 +76,6 @@ enum PoolMode : int64_t {
enum GateOrderMode : int64_t { RZH = 0, ZRH = 1 }; 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> template <typename T>
const std::map<CompareEnum, std::function<bool(T, T)>> kCompareMap = { const std::map<CompareEnum, std::function<bool(T, T)>> kCompareMap = {
{kEqual, [](T num1, T num2) -> bool { return num1 == num2; }}, {kEqual, [](T num1, T num2) -> bool { return num1 == num2; }},

View File

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