forked from mindspore-Ecosystem/mindspore
!48771 [lite]optimize arm-package size
Merge pull request !48771 from 徐安越/master5
This commit is contained in:
commit
aac3e7ad99
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,6 +23,7 @@
|
|||
#include <utility>
|
||||
#include "include/api/data_type.h"
|
||||
#include "include/api/dual_abi_helper.h"
|
||||
#include "include/api/types.h"
|
||||
|
||||
namespace mindspore {
|
||||
class Model;
|
||||
|
@ -31,24 +32,19 @@ class CallbackImpl;
|
|||
|
||||
using GraphPoint = std::pair<int, float>;
|
||||
|
||||
struct TrainCallBackData {
|
||||
TrainCallBackData(bool train_mode, int epoch, int step, Model *model): train_mode_(train_mode), epoch_(epoch),
|
||||
step_(step), model_(model) {}
|
||||
struct MS_API TrainCallBackData {
|
||||
TrainCallBackData(bool train_mode, int epoch, int step, Model *model)
|
||||
: train_mode_(train_mode), epoch_(epoch), step_(step), model_(model) {}
|
||||
|
||||
bool train_mode_; /**< training mode of LiteSession object */
|
||||
unsigned int epoch_; /**< the current training epoch (starts at 0) */
|
||||
unsigned int step_ = 0; /**< the current step within the epoch */
|
||||
Model *model_; /**< pointer to the Model object */
|
||||
Model *model_; /**< pointer to the Model object */
|
||||
};
|
||||
|
||||
enum CallbackRetValue : uint32_t {
|
||||
kContinue = 0,
|
||||
kStopTraining = 1,
|
||||
kExit = 2,
|
||||
kUnknownRetValue = 0xFFFFFFFF
|
||||
};
|
||||
enum CallbackRetValue : uint32_t { kContinue = 0, kStopTraining = 1, kExit = 2, kUnknownRetValue = 0xFFFFFFFF };
|
||||
|
||||
class TrainCallBack {
|
||||
class MS_API TrainCallBack {
|
||||
public:
|
||||
virtual ~TrainCallBack() = default;
|
||||
|
||||
|
@ -90,7 +86,7 @@ class TrainCallBack {
|
|||
protected:
|
||||
friend class Model;
|
||||
friend class ModelImpl;
|
||||
CallbackImpl* callback_impl_ = nullptr;
|
||||
CallbackImpl *callback_impl_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
|
||||
class CkptSaver: public TrainCallBack {
|
||||
class MS_API CkptSaver : public TrainCallBack {
|
||||
public:
|
||||
inline CkptSaver(int save_every_n, const std::string &filename_prefix);
|
||||
virtual ~CkptSaver();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
|
||||
class LossMonitor: public TrainCallBack {
|
||||
class MS_API LossMonitor : public TrainCallBack {
|
||||
public:
|
||||
explicit LossMonitor(int print_every_n_steps = INT_MAX);
|
||||
virtual ~LossMonitor();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 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.
|
||||
|
@ -30,18 +30,18 @@ constexpr int UPDATE_LR = 1;
|
|||
using LR_Lambda = std::function<int(float *lr, int epoch, void *cb_data)>;
|
||||
|
||||
/// \brief Multiply the LR by a factor of gamma every epoch
|
||||
int MultiplicativeLRLambda(float *lr, int epoch, void *multiplication);
|
||||
MS_API int MultiplicativeLRLambda(float *lr, int epoch, void *multiplication);
|
||||
|
||||
/// \brief Multiply the LR by a factor of gamma every step_size
|
||||
int StepLRLambda(float *lr, int epoch, void *step_size);
|
||||
struct StepLRLambda {
|
||||
MS_API int StepLRLambda(float *lr, int epoch, void *step_size);
|
||||
struct MS_API StepLRLambda {
|
||||
StepLRLambda(int step, float g) : step_size(step), gamma(g) {}
|
||||
|
||||
int step_size; // period of LR decay
|
||||
float gamma; // LR decay factor
|
||||
};
|
||||
|
||||
class LRScheduler: public TrainCallBack {
|
||||
class MS_API LRScheduler : public TrainCallBack {
|
||||
public:
|
||||
explicit LRScheduler(LR_Lambda lambda_func, void *lr_cb_data = nullptr, int step = 1);
|
||||
virtual ~LRScheduler();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 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.
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
|
||||
class TimeMonitor: public TrainCallBack {
|
||||
class MS_API TimeMonitor : public TrainCallBack {
|
||||
public:
|
||||
virtual ~TimeMonitor() = default;
|
||||
void EpochBegin(const TrainCallBackData &cb_data) override;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 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.
|
||||
|
@ -26,12 +26,10 @@
|
|||
|
||||
namespace mindspore {
|
||||
|
||||
class TrainAccuracy: public TrainCallBack {
|
||||
class MS_API TrainAccuracy : public TrainCallBack {
|
||||
public:
|
||||
explicit TrainAccuracy(int print_every_n = INT_MAX,
|
||||
int accuracy_metrics = METRICS_CLASSIFICATION,
|
||||
const std::vector<int> &input_indexes = {1},
|
||||
const std::vector<int> &output_indexes = {0});
|
||||
explicit TrainAccuracy(int print_every_n = INT_MAX, int accuracy_metrics = METRICS_CLASSIFICATION,
|
||||
const std::vector<int> &input_indexes = {1}, const std::vector<int> &output_indexes = {0});
|
||||
virtual ~TrainAccuracy();
|
||||
const std::vector<GraphPoint> &GetAccuracyPoints();
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
* Copyright 2022-2023 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.
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
constexpr int iter_th = 1000;
|
||||
class MixPrecisionCfg {
|
||||
class MS_API MixPrecisionCfg {
|
||||
public:
|
||||
MixPrecisionCfg() {
|
||||
this->dynamic_loss_scale_ = false;
|
||||
|
@ -49,7 +49,7 @@ class MixPrecisionCfg {
|
|||
bool is_raw_mix_precision_ = false; /**< Is mix precision model export from mindspore */
|
||||
};
|
||||
|
||||
class TrainCfg {
|
||||
class MS_API TrainCfg {
|
||||
public:
|
||||
TrainCfg() = default;
|
||||
TrainCfg(const TrainCfg &rhs) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,7 @@ namespace mindspore {
|
|||
constexpr int METRICS_CLASSIFICATION = 0;
|
||||
constexpr int METRICS_MULTILABEL = 1;
|
||||
|
||||
class AccuracyMetrics : public Metrics {
|
||||
class MS_API AccuracyMetrics : public Metrics {
|
||||
public:
|
||||
explicit AccuracyMetrics(int accuracy_metrics = METRICS_CLASSIFICATION, const std::vector<int> &input_indexes = {1},
|
||||
const std::vector<int> &output_indexes = {0});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 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.
|
||||
|
@ -24,16 +24,17 @@ class MetricsImpl;
|
|||
class ModelImpl;
|
||||
class MSTensor;
|
||||
|
||||
class Metrics {
|
||||
class MS_API Metrics {
|
||||
public:
|
||||
virtual ~Metrics() = default;
|
||||
virtual void Clear() {}
|
||||
virtual float Eval() { return 0.0; }
|
||||
virtual void Update(std::vector<MSTensor *> inputs, std::vector<MSTensor *> outputs) {}
|
||||
|
||||
protected:
|
||||
friend class Model;
|
||||
friend class ModelImpl;
|
||||
MetricsImpl* metrics_impl_;
|
||||
MetricsImpl *metrics_impl_;
|
||||
};
|
||||
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
* Copyright 2022-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@
|
|||
namespace mindspore {
|
||||
/// \brief The RunnerConfig class is used to store environment variables during execution
|
||||
/// management.
|
||||
class RunnerConfig {
|
||||
class MS_API RunnerConfig {
|
||||
public:
|
||||
struct Data;
|
||||
RunnerConfig();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
* Copyright 2022-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,14 +36,14 @@ class NodeSet;
|
|||
class Graph;
|
||||
class NetData;
|
||||
|
||||
class NetBase {
|
||||
class MS_API NetBase {
|
||||
public:
|
||||
NetBase() = default;
|
||||
virtual std::vector<Expr *> operator()(const std::vector<Expr *> &inputs) = 0;
|
||||
virtual uint32_t type() = 0;
|
||||
};
|
||||
|
||||
class Node : public NetBase {
|
||||
class MS_API Node : public NetBase {
|
||||
public:
|
||||
Node();
|
||||
virtual ~Node();
|
||||
|
@ -65,7 +65,7 @@ class Node : public NetBase {
|
|||
std::shared_ptr<NodeImpl> impl_ = nullptr;
|
||||
};
|
||||
|
||||
class Net : public NetBase, public std::enable_shared_from_this<Net> {
|
||||
class MS_API Net : public NetBase, public std::enable_shared_from_this<Net> {
|
||||
public:
|
||||
Net();
|
||||
virtual ~Net();
|
||||
|
@ -116,12 +116,12 @@ class Net : public NetBase, public std::enable_shared_from_this<Net> {
|
|||
std::shared_ptr<NetImpl> impl_;
|
||||
};
|
||||
|
||||
class SoftMaxCrossEntropyCfg {
|
||||
class MS_API SoftMaxCrossEntropyCfg {
|
||||
public:
|
||||
std::string reduction = "mean"; /**< Specifies reduction mode. The optional values are "none", "mean", "sum" */
|
||||
};
|
||||
|
||||
class AdamConfig {
|
||||
class MS_API AdamConfig {
|
||||
public:
|
||||
float learning_rate_ = 1e-3;
|
||||
float beta1_ = 0.9;
|
||||
|
@ -131,11 +131,12 @@ class AdamConfig {
|
|||
};
|
||||
|
||||
namespace NN {
|
||||
Net *NetWithLoss(Net *net, Node *loss);
|
||||
Graph *GraphWithLoss(Graph *g, Node *loss);
|
||||
Node *Adam(std::shared_ptr<NodeSet> learn, const AdamConfig &cfg);
|
||||
Node *SoftmaxCrossEntropy(const SoftMaxCrossEntropyCfg &cfg);
|
||||
std::unique_ptr<Node> Input(std::vector<int> dims, DataType data_type = DataType::kNumberTypeFloat32, int fmt = NHWC);
|
||||
MS_API Net *NetWithLoss(Net *net, Node *loss);
|
||||
MS_API Graph *GraphWithLoss(Graph *g, Node *loss);
|
||||
MS_API Node *Adam(std::shared_ptr<NodeSet> learn, const AdamConfig &cfg);
|
||||
MS_API Node *SoftmaxCrossEntropy(const SoftMaxCrossEntropyCfg &cfg);
|
||||
MS_API std::unique_ptr<Node> Input(std::vector<int> dims, DataType data_type = DataType::kNumberTypeFloat32,
|
||||
int fmt = NHWC);
|
||||
}; // namespace NN
|
||||
} // namespace mindspore
|
||||
#endif // MINDSPORE_INCLUDE_API_NET_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020-2022 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2023 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.
|
||||
|
@ -368,7 +368,7 @@ std::string MSTensor::Name() const { return CharToString(CharName()); }
|
|||
|
||||
void MSTensor::SetTensorName(const std::string &name) { SetTensorName(StringToChar(name)); }
|
||||
|
||||
using Key = struct Key {
|
||||
using Key = struct MS_API Key {
|
||||
const size_t max_key_len = 32;
|
||||
size_t len = 0;
|
||||
unsigned char key[32] = {0};
|
||||
|
@ -390,7 +390,7 @@ using MSKernelCallBack =
|
|||
std::function<bool(const std::vector<MSTensor> & /* inputs */, const std::vector<MSTensor> & /* outputs */,
|
||||
const MSCallBackParam &opInfo)>;
|
||||
|
||||
std::vector<char> CharVersion();
|
||||
MS_API std::vector<char> CharVersion();
|
||||
inline std::string Version() { return CharToString(CharVersion()); }
|
||||
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2023 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.
|
||||
|
@ -19,6 +19,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "include/api/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace schema {
|
||||
|
@ -29,7 +30,7 @@ typedef enum { ModelType_MSLite, ModelType_MindIR } LiteModelType;
|
|||
|
||||
// LiteGraph can be considered as a light weight and subset of FuncGraph, it can not support the advanced expression of
|
||||
// FuncGraph, e.g., non-tail recursive.
|
||||
struct LiteGraph {
|
||||
struct MS_API LiteGraph {
|
||||
struct Node {
|
||||
std::string name_;
|
||||
std::string op_type_;
|
||||
|
@ -62,7 +63,7 @@ struct LiteGraph {
|
|||
std::vector<unsigned char *> deobf_prims_;
|
||||
#endif
|
||||
};
|
||||
struct Model {
|
||||
struct MS_API Model {
|
||||
LiteGraph graph_;
|
||||
char *buf = nullptr;
|
||||
size_t buf_size_ = 0;
|
||||
|
|
|
@ -54,6 +54,11 @@ if(APPLE OR PLATFORM_ARM32 OR PLATFORM_ARM64)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
endif()
|
||||
endif()
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT MSLITE_ENABLE_TESTCASES)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility-inlines-hidden -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -fvisibility=hidden")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
endif()
|
||||
elseif(NOT MSVC)
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
|
||||
|
@ -300,16 +305,6 @@ set(LITE_SRC
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/litert/weight_decoder.cc
|
||||
)
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB_RECURSE OPENCL_RUNTIME_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/litert/kernel/gpu/opencl/*.cc
|
||||
)
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
${OPENCL_RUNTIME_SRC}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL cuda)
|
||||
file(GLOB CUDA_RUNTIME_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/litert/gpu/*.cc
|
||||
|
@ -533,7 +528,7 @@ if(NOT (MSLITE_ENABLE_CLOUD_FUSION_INFERENCE OR MSLITE_ENABLE_CLOUD_INFERENCE))
|
|||
endif()
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
add_subdirectory(litert/kernel/opencl)
|
||||
add_subdirectory(litert/kernel/gpu/opencl)
|
||||
target_link_libraries(mindspore-lite opencl_kernel_mid)
|
||||
target_link_libraries(mindspore-lite_static opencl_kernel_mid)
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* Copyright 2020-2023 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.
|
||||
|
@ -18,13 +18,14 @@
|
|||
#define MINDSPORE_LITE_SRC_COMMON_PRIM_UTIL_H_
|
||||
|
||||
#include "src/common/version_manager.h"
|
||||
#include "include/api/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
int GetPrimitiveType(const void *primitive, int schema_version = SCHEMA_CUR);
|
||||
MS_API int GetPrimitiveType(const void *primitive, int schema_version = SCHEMA_CUR);
|
||||
const char *GetPrimitiveTypeName(const void *primitive, int schema_version);
|
||||
const char *PrimitiveCurVersionTypeName(int type);
|
||||
int GenPrimVersionKey(int primitive_type, int schema_version);
|
||||
MS_API int GenPrimVersionKey(int primitive_type, int schema_version);
|
||||
bool IsPartialNode(const void *primitive, int schema_version);
|
||||
bool IsCallNode(const void *primitive, int schema_version);
|
||||
bool IsSwitchNode(const void *primitive, int schema_version);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nnacl/infer/common_infer.h"
|
||||
#include "nnacl/tensorlist_c_utils.h"
|
||||
#include "src/litert/cxx_api/tensor/tensor_impl.h"
|
||||
#include "include/api/visible.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
|
@ -38,7 +39,7 @@ int GenerateInTensorC(const std::vector<lite::Tensor *> &inputs, std::vector<Ten
|
|||
const std::shared_ptr<Allocator> &allocator = nullptr);
|
||||
int GenerateOutTensorC(const OpParameter *const parameter, const std::vector<lite::Tensor *> &outputs,
|
||||
std::vector<TensorC *> *out_tensor_c);
|
||||
int CheckTensorsInvalid(const std::vector<Tensor *> &tensors);
|
||||
MS_API int CheckTensorsInvalid(const std::vector<Tensor *> &tensors);
|
||||
int CheckGraphInputShapes(const std::vector<Tensor *> &inputs,
|
||||
const std::unordered_map<Tensor *, std::vector<int>> &input_shape_map);
|
||||
std::vector<mindspore::MSTensor> LiteTensorsToMSTensors(const std::vector<lite::Tensor *> &lite_tensors);
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
string(REPLACE "-fvisibility-inlines-hidden" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-fvisibility=hidden" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-fvisibility-inlines-hidden" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if(MSLITE_ENABLE_CLOUD_FUSION_INFERENCE OR MSLITE_ENABLE_CLOUD_INFERENCE)
|
||||
if(PLATFORM_ARM64)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@
|
|||
#include "src/common/log_adapter.h"
|
||||
|
||||
namespace mindspore {
|
||||
class ContextUtils {
|
||||
class MS_API ContextUtils {
|
||||
public:
|
||||
static std::shared_ptr<lite::InnerContext> Convert(Context *context);
|
||||
static std::shared_ptr<lite::InnerContext> Convert(const ContextC *context_c);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
* Copyright 2021-2023 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.
|
||||
|
@ -47,10 +47,10 @@ namespace mindspore {
|
|||
typedef std::shared_ptr<lite::LiteSession>(CreateTrainSessionProto)(std::shared_ptr<Graph::GraphData> graph_data,
|
||||
std::shared_ptr<TrainCfg> cfg,
|
||||
const std::shared_ptr<lite::InnerContext> &context);
|
||||
CreateTrainSessionProto *CreateTrainSessionCallbackHolder(CreateTrainSessionProto *proto = nullptr);
|
||||
MS_API CreateTrainSessionProto *CreateTrainSessionCallbackHolder(CreateTrainSessionProto *proto = nullptr);
|
||||
|
||||
using ExpressionLoader = std::function<Status(const char *, Graph *)>;
|
||||
ExpressionLoader CreateExpressionLoader(const ExpressionLoader &loader = nullptr);
|
||||
MS_API ExpressionLoader CreateExpressionLoader(const ExpressionLoader &loader = nullptr);
|
||||
|
||||
namespace session {
|
||||
class Metrics;
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
#include "include/api/allocator.h"
|
||||
|
||||
namespace mindspore::lite {
|
||||
int KernelInferShape(const std::vector<lite::Tensor *> &tensors_in, const std::vector<lite::Tensor *> &outputs,
|
||||
OpParameter *parameter, std::shared_ptr<Allocator> allocator = nullptr);
|
||||
int KernelInferShape(const std::vector<lite::Tensor *> &inputs, const std::vector<lite::Tensor *> &outputs,
|
||||
const void *primitive, std::set<std::string> &&providers, int schema_version,
|
||||
const kernel::Kernel *kernel = nullptr);
|
||||
MS_API int KernelInferShape(const std::vector<lite::Tensor *> &tensors_in, const std::vector<lite::Tensor *> &outputs,
|
||||
OpParameter *parameter, std::shared_ptr<Allocator> allocator = nullptr);
|
||||
MS_API int KernelInferShape(const std::vector<lite::Tensor *> &inputs, const std::vector<lite::Tensor *> &outputs,
|
||||
const void *primitive, std::set<std::string> &&providers, int schema_version,
|
||||
const kernel::Kernel *kernel = nullptr);
|
||||
typedef bool (*InferChecker)(const std::vector<Tensor *> &, const std::vector<Tensor *> &);
|
||||
bool InferCheckerAll(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs);
|
||||
bool InferCheckerInput(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs);
|
||||
|
|
|
@ -94,7 +94,7 @@ typedef struct InstructionsContext {
|
|||
bool support_avx512 = false;
|
||||
} InstructionsContext;
|
||||
|
||||
struct InnerContext {
|
||||
struct MS_API InnerContext {
|
||||
public:
|
||||
InnerContext();
|
||||
virtual ~InnerContext();
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
string(REPLACE "-fvisibility-inlines-hidden" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-fvisibility=hidden" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-fvisibility-inlines-hidden" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB_RECURSE OPENCL_KERNEL_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../opencl/*.cc)
|
||||
add_library(opencl_kernel_mid OBJECT ${OPENCL_KERNEL_SRC})
|
||||
add_dependencies(opencl_kernel_mid fbs_src)
|
||||
endif()
|
|
@ -1,8 +0,0 @@
|
|||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB_RECURSE OPENCL_KERNEL_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/int8/*.cc)
|
||||
add_library(opencl_kernel_mid OBJECT ${OPENCL_KERNEL_SRC})
|
||||
add_dependencies(opencl_kernel_mid fbs_src)
|
||||
endif()
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
namespace mindspore::kernel {
|
||||
|
||||
class KernelExecUtil {
|
||||
class MS_API KernelExecUtil {
|
||||
public:
|
||||
static std::vector<KernelExec *> SubgraphInputNodes(const std::vector<KernelExec *> &kernels);
|
||||
static std::vector<KernelExec *> SubgraphOutputNodes(const std::vector<KernelExec *> &kernels);
|
||||
|
|
|
@ -31,7 +31,7 @@ using mindspore::schema::PrimitiveType_MAX;
|
|||
using mindspore::schema::PrimitiveType_MIN;
|
||||
|
||||
namespace mindspore::lite {
|
||||
class KernelRegistry {
|
||||
class MS_API KernelRegistry {
|
||||
public:
|
||||
KernelRegistry() = default;
|
||||
virtual ~KernelRegistry();
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
using mindspore::infer::Abstractkernel;
|
||||
|
||||
namespace mindspore::kernel {
|
||||
class LiteKernel : public Abstractkernel {
|
||||
class MS_API LiteKernel : public Abstractkernel {
|
||||
public:
|
||||
LiteKernel() = default;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
class LiteModel : public Model {
|
||||
class MS_API LiteModel : public Model {
|
||||
public:
|
||||
explicit LiteModel(std::string model_path = "") : model_path_(std::move(model_path)) {}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace lite {
|
||||
class LiteSession {
|
||||
class MS_API LiteSession {
|
||||
public:
|
||||
LiteSession();
|
||||
virtual ~LiteSession();
|
||||
|
|
|
@ -40,7 +40,7 @@ static constexpr int kBitNum32 = 32;
|
|||
|
||||
namespace mindspore::lite {
|
||||
|
||||
class WeightDecoder {
|
||||
class MS_API WeightDecoder {
|
||||
public:
|
||||
static int DequantNode(const OpParameter *op_parameter, const std::vector<Tensor *> &in_tensors, TypeId dst_data_type,
|
||||
const std::string &model_version, bool float_mode);
|
||||
|
|
Loading…
Reference in New Issue