version:2.1.5

bugfixes:
update:拨号使用ocr进行识别
This commit is contained in:
2025-05-22 14:30:12 +08:00
parent a86592005f
commit d7e830985f
226 changed files with 66016 additions and 81139 deletions

View File

@@ -19,7 +19,6 @@
#ifndef PADDLE_LITE_API_H_ // NOLINT
#define PADDLE_LITE_API_H_
#include <map>
#include <memory>
#include <string>
@@ -28,567 +27,488 @@
#include "paddle_place.h" // NOLINT
namespace paddle {
namespace lite_api {
namespace lite_api {
using shape_t = std::vector<int64_t>;
using lod_t = std::vector<std::vector<uint64_t>>;
using shape_t = std::vector<int64_t>;
using lod_t = std::vector<std::vector<uint64_t>>;
enum class LiteModelType {
kProtobuf = 0, kNaiveBuffer, UNK
};
enum class LiteModelType { kProtobuf = 0, kNaiveBuffer, UNK };
// Methods for allocating L3Cache on Arm platform
enum class L3CacheSetMethod {
kDeviceL3Cache = 0, // Use the system L3 Cache size, best performance.
kDeviceL2Cache = 1, // Use the system L2 Cache size, trade off performance
// with less memory consumption.
kAbsolute = 2, // Use the external setting.
// kAutoGrow = 3, // Not supported yet, least memory consumption.
};
enum class L3CacheSetMethod {
kDeviceL3Cache = 0, // Use the system L3 Cache size, best performance.
kDeviceL2Cache = 1, // Use the system L2 Cache size, trade off performance
// with less memory consumption.
kAbsolute = 2, // Use the external setting.
// kAutoGrow = 3, // Not supported yet, least memory consumption.
};
// return true if current device supports OpenCL model
LITE_API bool IsOpenCLBackendValid(bool check_fp16_valid = false);
LITE_API bool IsOpenCLBackendValid(bool check_fp16_valid = false);
// return current opencl device type,
// if opencl not enabled or IsOpenCLBackendValid return false, it will return -1
// UNKNOWN:0, QUALCOMM_ADRENO:1, ARM_MALI:2, IMAGINATION_POWERVR:3, OTHERS:4,
LITE_API int GetOpenCLDeviceType();
LITE_API int GetOpenCLDeviceType();
struct LITE_API Tensor {
explicit Tensor(void *raw);
struct LITE_API Tensor {
explicit Tensor(void* raw);
explicit Tensor(const void* raw);
explicit Tensor(const void *raw);
void Resize(const shape_t& shape);
void Resize(const shape_t &shape);
/// Readonly data.
template <typename T>
const T* data() const;
/// Readonly data.
template<typename T>
const T *data() const;
template <typename T>
T* mutable_data(TargetType type = TargetType::kHost) const;
template<typename T>
T *mutable_data(TargetType type = TargetType::kHost) const;
void* mutable_metal_data(void* ptr) const;
void *mutable_metal_data(void *ptr) const;
// Share external memory. Note: ensure that the data pointer is in a valid
// state
// during the prediction process.
void ShareExternalMemory(void* data, size_t memory_size, TargetType target);
// Share external memory. Note: ensure that the data pointer is in a valid
// state
// during the prediction process.
void ShareExternalMemory(void *data, size_t memory_size, TargetType target);
template <typename T, TargetType type = TargetType::kHost>
void CopyFromCpu(const T* data);
template<typename T, TargetType type = TargetType::kHost>
void CopyFromCpu(const T *data);
template <typename T>
void CopyToCpu(T* data) const;
/// Shape of the tensor.
shape_t shape() const;
TargetType target() const;
PrecisionType precision() const;
void SetPrecision(PrecisionType precision);
template<typename T>
void CopyToCpu(T *data) const;
// LoD of the tensor
lod_t lod() const;
/// Shape of the tensor.
shape_t shape() const;
// Set LoD of the tensor
void SetLoD(const lod_t& lod);
bool IsInitialized() const;
TargetType target() const;
PrecisionType precision() const;
void SetPrecision(PrecisionType precision);
// LoD of the tensor
lod_t lod() const;
// Set LoD of the tensor
void SetLoD(const lod_t &lod);
bool IsInitialized() const;
private:
void *raw_tensor_;
};
private:
void* raw_tensor_;
};
/// The PaddlePredictor defines the basic interfaces for different kinds of
/// predictors.
class LITE_API PaddlePredictor {
public:
PaddlePredictor() = default;
class LITE_API PaddlePredictor {
public:
PaddlePredictor() = default;
/// Get i-th input.
virtual std::unique_ptr<Tensor> GetInput(int i) = 0;
/// Get i-th input.
virtual std::unique_ptr<Tensor> GetInput(int i) = 0;
/// Get i-th output.
virtual std::unique_ptr<const Tensor> GetOutput(int i) const = 0;
/// Get i-th output.
virtual std::unique_ptr<const Tensor> GetOutput(int i) const = 0;
virtual void Run() = 0;
virtual void Run() = 0;
virtual std::shared_ptr<PaddlePredictor> Clone() = 0;
virtual std::shared_ptr<PaddlePredictor> Clone(
const std::vector<std::string>& var_names) = 0;
virtual std::shared_ptr<PaddlePredictor> Clone() = 0;
virtual std::string GetVersion() const = 0;
virtual std::shared_ptr<PaddlePredictor> Clone(
const std::vector<std::string> &var_names) = 0;
// Get input names
virtual std::vector<std::string> GetInputNames() = 0;
// Get output names
virtual std::vector<std::string> GetOutputNames() = 0;
// Get output names
virtual std::vector<std::string> GetParamNames();
virtual std::string GetVersion() const = 0;
/// Release all tmp tensor to compress the size of the memory pool.
virtual bool TryShrinkMemory() = 0;
// Get input names
virtual std::vector<std::string> GetInputNames() = 0;
// Get Input by name
virtual std::unique_ptr<Tensor> GetInputByName(const std::string& name) = 0;
// Get output names
virtual std::vector<std::string> GetOutputNames() = 0;
/// Get a readonly tensor, return null if no one called `name` exists.
virtual std::unique_ptr<const Tensor> GetTensor(
const std::string& name) const = 0;
/// Get a mutable tensor, return null if on one called `name` exists
/// internal infereces API, not recommanded.
virtual std::unique_ptr<Tensor> GetMutableTensor(const std::string& name);
// Get output names
virtual std::vector<std::string> GetParamNames();
/// Persist the optimized model to disk. This API is only supported by
/// CxxConfig, and the persisted model can be reused for MobileConfig.
virtual void SaveOptimizedModel(
const std::string& model_dir,
LiteModelType model_type = LiteModelType::kProtobuf,
bool record_info = false);
/// Release all tmp tensor to compress the size of the memory pool.
virtual bool TryShrinkMemory() = 0;
virtual ~PaddlePredictor() = default;
// Get Input by name
virtual std::unique_ptr<Tensor> GetInputByName(const std::string &name) = 0;
/// Get a readonly tensor, return null if no one called `name` exists.
virtual std::unique_ptr<const Tensor> GetTensor(
const std::string &name) const = 0;
/// Get a mutable tensor, return null if on one called `name` exists
/// internal infereces API, not recommanded.
virtual std::unique_ptr<Tensor> GetMutableTensor(const std::string &name);
/// Persist the optimized model to disk. This API is only supported by
/// CxxConfig, and the persisted model can be reused for MobileConfig.
virtual void SaveOptimizedModel(
const std::string &model_dir,
LiteModelType model_type = LiteModelType::kProtobuf,
bool record_info = false);
virtual ~PaddlePredictor() = default;
protected:
int threads_{1};
lite_api::PowerMode mode_{lite_api::LITE_POWER_NO_BIND};
};
protected:
int threads_{1};
lite_api::PowerMode mode_{lite_api::LITE_POWER_NO_BIND};
};
/// Base class for all the configs.
class LITE_API ConfigBase {
std::string model_dir_;
int threads_{1};
PowerMode mode_{LITE_POWER_NO_BIND};
// gpu opencl
CLTuneMode opencl_tune_mode_{CL_TUNE_NONE};
std::string opencl_bin_path_{""};
std::string opencl_bin_name_{""};
CLPrecisionType opencl_precision_{CL_PRECISION_AUTO};
// Where to cache the npu/xpu/rknpu/apu offline model to the binary files
std::string subgraph_model_cache_dir_{""};
// Set the cached npu/xpu/rknpu/apu offline model from the buffers
std::map<std::string, std::pair<std::vector<char>, std::vector<char>>>
subgraph_model_cache_buffers_{};
// The selected NNAdapter devices to build and run the model.
std::vector<std::string> nnadapter_device_names_{};
// The NNAdapter context properties for device configuration, model
// compilation and execution
std::string nnadapter_context_properties_{};
// The directory to find and store the compiled NNAdapter models.
std::string nnadapter_model_cache_dir_{""};
// The buffers for loading the compiled NNAdapter models from memory.
std::map<std::string, std::vector<char>> nnadapter_model_cache_buffers_{};
// The custom configuration file or buffer for the NNAdapter subgraph
// partition, here is an example:
// op_type:in_var_name_0,in_var_name1:out_var_name_0,out_var_name1
// op_type::out_var_name_0
// op_type:in_var_name_0
// op_type
std::string nnadapter_subgraph_partition_config_path_{};
std::string nnadapter_subgraph_partition_config_buffer_{};
int device_id_{0};
int x86_math_num_threads_ = 1;
class LITE_API ConfigBase {
std::string model_dir_;
int threads_{1};
PowerMode mode_{LITE_POWER_NO_BIND};
// gpu opencl
CLTuneMode opencl_tune_mode_{CL_TUNE_NONE};
std::string opencl_bin_path_{""};
std::string opencl_bin_name_{""};
CLPrecisionType opencl_precision_{CL_PRECISION_AUTO};
// Where to cache the npu/xpu/rknpu/apu offline model to the binary files
std::string subgraph_model_cache_dir_{""};
// Set the cached npu/xpu/rknpu/apu offline model from the buffers
std::map<std::string, std::pair<std::vector<char>, std::vector<char>>>
subgraph_model_cache_buffers_{};
// The selected NNAdapter devices to build and run the model.
std::vector<std::string> nnadapter_device_names_{};
// The NNAdapter context properties for device configuration, model
// compilation and execution
std::string nnadapter_context_properties_{};
// The directory to find and store the compiled NNAdapter models.
std::string nnadapter_model_cache_dir_{""};
// The buffers for loading the compiled NNAdapter models from memory.
std::map<std::string, std::vector<char>> nnadapter_model_cache_buffers_{};
// The custom configuration file or buffer for the NNAdapter subgraph
// partition, here is an example:
// op_type:in_var_name_0,in_var_name1:out_var_name_0,out_var_name1
// op_type::out_var_name_0
// op_type:in_var_name_0
// op_type
std::string nnadapter_subgraph_partition_config_path_{};
std::string nnadapter_subgraph_partition_config_buffer_{};
int device_id_{0};
int x86_math_num_threads_ = 1;
std::string metal_path_;
bool metal_use_mps_{false};
bool metal_use_aggressive_{false};
void *metal_device_{nullptr};
bool metal_use_memory_reuse_{false};
std::string metal_path_;
bool metal_use_mps_{false};
bool metal_use_aggressive_{false};
void* metal_device_{nullptr};
bool metal_use_memory_reuse_{false};
public:
explicit ConfigBase(PowerMode mode = LITE_POWER_NO_BIND, int threads = 1);
public:
explicit ConfigBase(PowerMode mode = LITE_POWER_NO_BIND, int threads = 1);
// set Model_dir
void set_model_dir(const std::string& x) { model_dir_ = x; }
const std::string& model_dir() const { return model_dir_; }
// set Thread
void set_threads(int threads);
int threads() const { return threads_; }
// set Power_mode
void set_power_mode(PowerMode mode);
PowerMode power_mode() const { return mode_; }
/// \brief Set path and file name of generated OpenCL compiled kernel binary.
///
/// If you use GPU of specific soc, using OpenCL binary will speed up the
/// initialization.
///
/// \param path Path that OpenCL compiled kernel binay file stores in. Make
/// sure the path exist and you have Read&Write permission.
/// \param name File name of OpenCL compiled kernel binay.
/// \return void
void set_opencl_binary_path_name(const std::string& path,
const std::string& name);
// set GPU opencl tune
void set_opencl_tune(CLTuneMode tune_mode = CL_TUNE_NONE,
const std::string& path = "",
const std::string& name = "",
size_t lws_repeats = 4);
// set Model_dir
void set_model_dir(const std::string &x) { model_dir_ = x; }
// set GPU opencl precision
void set_opencl_precision(CLPrecisionType p = CL_PRECISION_AUTO);
// set subgraph_model_dir
void set_subgraph_model_cache_dir(std::string subgraph_model_cache_dir) {
subgraph_model_cache_dir_ = subgraph_model_cache_dir;
}
const std::string& subgraph_model_cache_dir() const {
return subgraph_model_cache_dir_;
}
void set_subgraph_model_cache_buffers(const std::string& key,
const std::vector<char>& cfg,
const std::vector<char>& bin);
const std::map<std::string, std::pair<std::vector<char>, std::vector<char>>>&
subgraph_model_cache_buffers() const {
return subgraph_model_cache_buffers_;
}
// Check if the NNAdapter device is valid.
bool check_nnadapter_device_name(const std::string& device_name);
// Choose the NNAdapter devices to build and run the model.
void set_nnadapter_device_names(
const std::vector<std::string>& device_names) {
nnadapter_device_names_ = device_names;
}
const std::vector<std::string>& nnadapter_device_names() const {
return nnadapter_device_names_;
}
// Set the context properties by key-value map for NNAdapter device
// configuration, model compilation and execution
// Such as "HUAWEI_ASCEND_NPU_SELECTED_DEVICE_IDS=0;"
void set_nnadapter_context_properties(const std::string& context_properties) {
nnadapter_context_properties_ = context_properties;
}
const std::string& nnadapter_context_properties() const {
return nnadapter_context_properties_;
}
// Enable caching and set the directory to search and store the compiled
// NNAdapter models in the file system.
void set_nnadapter_model_cache_dir(const std::string& model_cache_dir) {
nnadapter_model_cache_dir_ = model_cache_dir;
}
const std::string& nnadapter_model_cache_dir() const {
return nnadapter_model_cache_dir_;
}
// Set the buffers for loading the compiled NNAdapter models from memory.
void set_nnadapter_model_cache_buffers(
const std::string& model_cache_token,
const std::vector<char>& model_cache_buffer);
const std::map<std::string, std::vector<char>>&
nnadapter_model_cache_buffers() const {
return nnadapter_model_cache_buffers_;
}
// Enable the custom subgraph partition for NNAdapter by providing the
// configuration file or buffer
void set_nnadapter_subgraph_partition_config_path(
const std::string& subgraph_partition_config_path) {
nnadapter_subgraph_partition_config_path_ = subgraph_partition_config_path;
}
const std::string& nnadapter_subgraph_partition_config_path() const {
return nnadapter_subgraph_partition_config_path_;
}
void set_nnadapter_subgraph_partition_config_buffer(
const std::string& subgraph_partition_config_buffer) {
nnadapter_subgraph_partition_config_buffer_ =
subgraph_partition_config_buffer;
}
const std::string& nnadapter_subgraph_partition_config_buffer() const {
return nnadapter_subgraph_partition_config_buffer_;
}
// set Device ID
void set_device_id(int device_id) { device_id_ = device_id; }
int get_device_id() const { return device_id_; }
// set x86_math_num_threads
void set_x86_math_num_threads(int threads);
int x86_math_num_threads() const;
const std::string &model_dir() const { return model_dir_; }
void set_metal_lib_path(const std::string& path);
void set_metal_use_mps(bool flag);
void set_metal_use_aggressive(bool flag);
void set_metal_device(void* device);
void set_metal_use_memory_reuse(bool flag);
// set Thread
void set_threads(int threads);
std::string metal_lib_path() const { return metal_path_; }
bool metal_use_mps() const { return metal_use_mps_; }
bool metal_use_aggressive() const { return metal_use_aggressive_; }
void* metal_device() const { return metal_device_; }
bool metal_use_memory_reuse() const { return metal_use_memory_reuse_; }
};
int threads() const { return threads_; }
class LITE_API CxxModelBuffer {
public:
CxxModelBuffer(const char* program_buffer,
size_t program_buffer_size,
const char* params_buffer,
size_t params_buffer_size);
CxxModelBuffer(std::string&& program_buffer, std::string&& params_buffer);
const std::string& get_program() const;
const std::string& get_params() const;
bool is_empty() const;
// set Power_mode
void set_power_mode(PowerMode mode);
CxxModelBuffer() = default;
CxxModelBuffer(const CxxModelBuffer&) = delete;
PowerMode power_mode() const { return mode_; }
/// \brief Set path and file name of generated OpenCL compiled kernel binary.
///
/// If you use GPU of specific soc, using OpenCL binary will speed up the
/// initialization.
///
/// \param path Path that OpenCL compiled kernel binay file stores in. Make
/// sure the path exist and you have Read&Write permission.
/// \param name File name of OpenCL compiled kernel binay.
/// \return void
void set_opencl_binary_path_name(const std::string &path,
const std::string &name);
// set GPU opencl tune
void set_opencl_tune(CLTuneMode tune_mode = CL_TUNE_NONE,
const std::string &path = "",
const std::string &name = "",
size_t lws_repeats = 4);
// set GPU opencl precision
void set_opencl_precision(CLPrecisionType p = CL_PRECISION_AUTO);
// set subgraph_model_dir
void set_subgraph_model_cache_dir(std::string subgraph_model_cache_dir) {
subgraph_model_cache_dir_ = subgraph_model_cache_dir;
}
const std::string &subgraph_model_cache_dir() const {
return subgraph_model_cache_dir_;
}
void set_subgraph_model_cache_buffers(const std::string &key,
const std::vector<char> &cfg,
const std::vector<char> &bin);
const std::map<std::string, std::pair<std::vector<char>, std::vector<char>>> &
subgraph_model_cache_buffers() const {
return subgraph_model_cache_buffers_;
}
// Check if the NNAdapter device is valid.
bool check_nnadapter_device_name(const std::string &device_name);
// Choose the NNAdapter devices to build and run the model.
void set_nnadapter_device_names(
const std::vector<std::string> &device_names) {
nnadapter_device_names_ = device_names;
}
const std::vector<std::string> &nnadapter_device_names() const {
return nnadapter_device_names_;
}
// Set the context properties by key-value map for NNAdapter device
// configuration, model compilation and execution
// Such as "HUAWEI_ASCEND_NPU_SELECTED_DEVICE_IDS=0;"
void set_nnadapter_context_properties(const std::string &context_properties) {
nnadapter_context_properties_ = context_properties;
}
const std::string &nnadapter_context_properties() const {
return nnadapter_context_properties_;
}
// Enable caching and set the directory to search and store the compiled
// NNAdapter models in the file system.
void set_nnadapter_model_cache_dir(const std::string &model_cache_dir) {
nnadapter_model_cache_dir_ = model_cache_dir;
}
const std::string &nnadapter_model_cache_dir() const {
return nnadapter_model_cache_dir_;
}
// Set the buffers for loading the compiled NNAdapter models from memory.
void set_nnadapter_model_cache_buffers(
const std::string &model_cache_token,
const std::vector<char> &model_cache_buffer);
const std::map<std::string, std::vector<char>> &
nnadapter_model_cache_buffers() const {
return nnadapter_model_cache_buffers_;
}
// Enable the custom subgraph partition for NNAdapter by providing the
// configuration file or buffer
void set_nnadapter_subgraph_partition_config_path(
const std::string &subgraph_partition_config_path) {
nnadapter_subgraph_partition_config_path_ = subgraph_partition_config_path;
}
const std::string &nnadapter_subgraph_partition_config_path() const {
return nnadapter_subgraph_partition_config_path_;
}
void set_nnadapter_subgraph_partition_config_buffer(
const std::string &subgraph_partition_config_buffer) {
nnadapter_subgraph_partition_config_buffer_ =
subgraph_partition_config_buffer;
}
const std::string &nnadapter_subgraph_partition_config_buffer() const {
return nnadapter_subgraph_partition_config_buffer_;
}
// set Device ID
void set_device_id(int device_id) { device_id_ = device_id; }
int get_device_id() const { return device_id_; }
// set x86_math_num_threads
void set_x86_math_num_threads(int threads);
int x86_math_num_threads() const;
void set_metal_lib_path(const std::string &path);
void set_metal_use_mps(bool flag);
void set_metal_use_aggressive(bool flag);
void set_metal_device(void *device);
void set_metal_use_memory_reuse(bool flag);
std::string metal_lib_path() const { return metal_path_; }
bool metal_use_mps() const { return metal_use_mps_; }
bool metal_use_aggressive() const { return metal_use_aggressive_; }
void *metal_device() const { return metal_device_; }
bool metal_use_memory_reuse() const { return metal_use_memory_reuse_; }
};
class LITE_API CxxModelBuffer {
public:
CxxModelBuffer(const char *program_buffer,
size_t program_buffer_size,
const char *params_buffer,
size_t params_buffer_size);
CxxModelBuffer(std::string &&program_buffer, std::string &&params_buffer);
const std::string &get_program() const;
const std::string &get_params() const;
bool is_empty() const;
CxxModelBuffer() = default;
CxxModelBuffer(const CxxModelBuffer &) = delete;
private:
std::string program_;
std::string params_;
};
private:
std::string program_;
std::string params_;
};
/// CxxConfig is the config for the Full feature predictor.
class LITE_API CxxConfig : public ConfigBase {
std::vector<Place> valid_places_;
std::string model_file_;
std::string param_file_;
std::shared_ptr<CxxModelBuffer> model_buffer_{nullptr};
std::vector<std::string> passes_internal_{};
bool quant_model_{false}; // Enable post_quant_dynamic in opt
QuantType quant_type_{QuantType::QUANT_INT16};
bool sparse_model_{false}; // Enable sparse_conv_detect_pass in opt
float sparse_threshold_{0.6f};
std::map<int, std::vector<std::shared_ptr<void>>>
preferred_inputs_for_warmup_;
class LITE_API CxxConfig : public ConfigBase {
std::vector<Place> valid_places_;
std::string model_file_;
std::string param_file_;
std::shared_ptr<CxxModelBuffer> model_buffer_{nullptr};
std::vector<std::string> passes_internal_{};
bool quant_model_{false}; // Enable post_quant_dynamic in opt
QuantType quant_type_{QuantType::QUANT_INT16};
bool sparse_model_{false}; // Enable sparse_conv_detect_pass in opt
float sparse_threshold_{0.6f};
std::map<int, std::vector<std::shared_ptr<void>>>
preferred_inputs_for_warmup_;
#ifdef LITE_WITH_CUDA
bool multi_stream_{false};
bool multi_stream_{false};
#endif
#ifdef LITE_WITH_MLU
lite_api::MLUCoreVersion mlu_core_version_{lite_api::MLUCoreVersion::MLU_270};
int mlu_core_number_{1};
DataLayoutType mlu_input_layout_{DATALAYOUT(kNCHW)};
std::vector<float> mlu_first_conv_mean_{};
std::vector<float> mlu_first_conv_std_{};
lite_api::MLUCoreVersion mlu_core_version_{lite_api::MLUCoreVersion::MLU_270};
int mlu_core_number_{1};
DataLayoutType mlu_input_layout_{DATALAYOUT(kNCHW)};
std::vector<float> mlu_first_conv_mean_{};
std::vector<float> mlu_first_conv_std_{};
#endif
public:
void set_valid_places(const std::vector<Place> &x) { valid_places_ = x; }
void set_model_file(const std::string &path) { model_file_ = path; }
void set_param_file(const std::string &path) { param_file_ = path; }
void set_model_buffer(const char *model_buffer,
size_t model_buffer_size,
const char *param_buffer,
size_t param_buffer_size) {
model_buffer_.reset(new CxxModelBuffer(
model_buffer, model_buffer_size, param_buffer, param_buffer_size));
}
void set_model_buffer(std::shared_ptr<CxxModelBuffer> model_buffer) {
model_buffer_ = model_buffer;
}
const CxxModelBuffer &get_model_buffer() const;
// internal inference to choose passes for model optimizing,
// it's designed for internal developer and not recommanded
// for comman users.
void set_passes_internal(
const std::vector<std::string> &passes_internal = {}) {
passes_internal_ = passes_internal;
}
const std::vector<std::string> &get_passes_internal() const {
return passes_internal_;
}
const std::vector<Place> &valid_places() const { return valid_places_; }
std::string model_file() const { return model_file_; }
std::string param_file() const { return param_file_; }
bool is_model_from_memory() const { return static_cast<bool>(model_buffer_); }
// note: `model_from_memory` has the same effect as `is_model_from_memory`,
// but is_model_from_memory is recommended and `model_from_memory` will be
// abandoned in v3.0.
bool model_from_memory() const { return static_cast<bool>(model_buffer_); }
public:
void set_valid_places(const std::vector<Place>& x) { valid_places_ = x; }
void set_model_file(const std::string& path) { model_file_ = path; }
void set_param_file(const std::string& path) { param_file_ = path; }
void set_model_buffer(const char* model_buffer,
size_t model_buffer_size,
const char* param_buffer,
size_t param_buffer_size) {
model_buffer_.reset(new CxxModelBuffer(
model_buffer, model_buffer_size, param_buffer, param_buffer_size));
}
void set_model_buffer(std::shared_ptr<CxxModelBuffer> model_buffer) {
model_buffer_ = model_buffer;
}
const CxxModelBuffer& get_model_buffer() const;
// internal inference to choose passes for model optimizing,
// it's designed for internal developer and not recommanded
// for comman users.
void set_passes_internal(
const std::vector<std::string>& passes_internal = {}) {
passes_internal_ = passes_internal;
}
const std::vector<std::string>& get_passes_internal() const {
return passes_internal_;
}
const std::vector<Place>& valid_places() const { return valid_places_; }
std::string model_file() const { return model_file_; }
std::string param_file() const { return param_file_; }
bool is_model_from_memory() const { return static_cast<bool>(model_buffer_); }
// note: `model_from_memory` has the same effect as `is_model_from_memory`,
// but is_model_from_memory is recommended and `model_from_memory` will be
// abandoned in v3.0.
bool model_from_memory() const { return static_cast<bool>(model_buffer_); }
#ifdef LITE_WITH_CUDA
void set_multi_stream(bool multi_stream) { multi_stream_ = multi_stream; }
bool multi_stream() const { return multi_stream_; }
void set_multi_stream(bool multi_stream) { multi_stream_ = multi_stream; }
bool multi_stream() const { return multi_stream_; }
#endif
#ifdef LITE_WITH_MLU
// set MLU core version, which is used when compiling MLU kernels
void set_mlu_core_version(lite_api::MLUCoreVersion core_version);
// set MLU core number, which is used when compiling MLU kernels
void set_mlu_core_number(int core_number);
// whether use MLU's first conv kernel. First conv is a special kernel
// provided by MLU, its input is uint8, and also needs two 3-dimentional
// vectors which save all inputs' mean and std values
// set the 3-dimentional mean vector and 3-dimentional std vector used by
// MLU's first conv
void set_mlu_firstconv_param(const std::vector<float>& mean,
const std::vector<float>& std);
// set MLU input layout. User can specify layout of input data to be NHWC,
// default is NCHW
void set_mlu_input_layout(DataLayoutType layout);
// set MLU core version, which is used when compiling MLU kernels
void set_mlu_core_version(lite_api::MLUCoreVersion core_version);
// set MLU core number, which is used when compiling MLU kernels
void set_mlu_core_number(int core_number);
// whether use MLU's first conv kernel. First conv is a special kernel
// provided by MLU, its input is uint8, and also needs two 3-dimentional
// vectors which save all inputs' mean and std values
// set the 3-dimentional mean vector and 3-dimentional std vector used by
// MLU's first conv
void set_mlu_firstconv_param(const std::vector<float>& mean,
const std::vector<float>& std);
// set MLU input layout. User can specify layout of input data to be NHWC,
// default is NCHW
void set_mlu_input_layout(DataLayoutType layout);
lite_api::MLUCoreVersion mlu_core_version() const;
int mlu_core_number() const;
DataLayoutType mlu_input_layout() const;
// std::pair<mean, std>
std::pair<std::vector<float>, std::vector<float>> mlu_firstconv_param() const;
lite_api::MLUCoreVersion mlu_core_version() const;
int mlu_core_number() const;
DataLayoutType mlu_input_layout() const;
// std::pair<mean, std>
std::pair<std::vector<float>, std::vector<float>> mlu_firstconv_param() const;
#endif
// XPU only, set the size of the workspace memory from L3 cache for the
// current thread.
// **DEPRECATED**, use set_xpu_l3_cache_method() in the future
void set_xpu_workspace_l3_size_per_thread(int l3_size = 0x4000000);
// XPU only, set the size of the workspace memory from L3 cache for the
// current thread.
// **DEPRECATED**, use set_xpu_l3_cache_method() in the future
void set_xpu_workspace_l3_size_per_thread(int l3_size = 0x4000000);
void set_xpu_l3_cache_method(size_t l3_size, bool locked = false);
void set_xpu_l3_cache_method(size_t l3_size, bool locked = false);
void set_xpu_gm_workspace_method(size_t gm_size);
void set_xpu_gm_workspace_method(size_t gm_size);
void set_xpu_conv_autotune(bool autotune = true,
const std::string& autotune_file = "");
void set_xpu_conv_autotune(bool autotune = true,
const std::string &autotune_file = "");
// XPU only, specify the target device ID for the current thread.
// **DEPRECATED**, use xpu_set_device() at the very beginning of each worker
// thread
void set_xpu_dev_per_thread(int dev_no = 0);
// XPU only, specify the target device ID for the current thread.
// **DEPRECATED**, use xpu_set_device() at the very beginning of each worker
// thread
void set_xpu_dev_per_thread(int dev_no = 0);
// **DEPRECATED**, use set_xpu_multi_encoder_method() in the future
void set_xpu_multi_encoder_precision(const std::string& precision = "int16");
void set_xpu_multi_encoder_method(const std::string& precision = "int16",
bool adaptive_seqlen = false);
// **DEPRECATED**, use set_xpu_multi_encoder_method() in the future
void set_xpu_multi_encoder_precision(const std::string &precision = "int16");
// set input tensor for warmup.
// It is optional. If you set prefered_inputs, model wil run immediately when
// predictor is created
template <class T>
void set_preferred_inputs_for_warmup(const int group_idx,
const int tensor_idx,
const shape_t& shape,
const lod_t& lod = {},
const T fill_value = 0,
const void* data = nullptr);
const std::map<int, std::vector<std::shared_ptr<void>>>&
preferred_inputs_for_warmup() const {
return preferred_inputs_for_warmup_;
}
void set_xpu_multi_encoder_method(const std::string &precision = "int16",
bool adaptive_seqlen = false);
void set_quant_model(bool quant_model) { quant_model_ = quant_model; }
bool quant_model() const { return quant_model_; }
void set_quant_type(QuantType quant_type) { quant_type_ = quant_type; }
QuantType quant_type() const { return quant_type_; }
// set input tensor for warmup.
// It is optional. If you set prefered_inputs, model wil run immediately when
// predictor is created
template<class T>
void set_preferred_inputs_for_warmup(const int group_idx,
const int tensor_idx,
const shape_t &shape,
const lod_t &lod = {},
const T fill_value = 0,
const void *data = nullptr);
const std::map<int, std::vector<std::shared_ptr<void>>> &
preferred_inputs_for_warmup() const {
return preferred_inputs_for_warmup_;
}
void set_quant_model(bool quant_model) { quant_model_ = quant_model; }
bool quant_model() const { return quant_model_; }
void set_quant_type(QuantType quant_type) { quant_type_ = quant_type; }
QuantType quant_type() const { return quant_type_; }
void set_sparse_model(bool sparse_model) { sparse_model_ = sparse_model; }
bool sparse_model() const { return sparse_model_; }
void set_sparse_threshold(float sparse_threshold) {
sparse_threshold_ = sparse_threshold;
}
float sparse_threshold() const { return sparse_threshold_; }
};
void set_sparse_model(bool sparse_model) { sparse_model_ = sparse_model; }
bool sparse_model() const { return sparse_model_; }
void set_sparse_threshold(float sparse_threshold) {
sparse_threshold_ = sparse_threshold;
}
float sparse_threshold() const { return sparse_threshold_; }
};
/// MobileConfig is the config for the light weight predictor, it will skip
/// IR optimization or other unnecessary stages.
class LITE_API MobileConfig : public ConfigBase {
// whether to load data from memory. Model data will be loaded from memory
// buffer if model_from_memory_ is true.
bool model_from_memory_{false};
class LITE_API MobileConfig : public ConfigBase {
// whether to load data from memory. Model data will be loaded from memory
// buffer if model_from_memory_ is true.
bool model_from_memory_{false};
// model data readed from file or memory buffer in combined format.
std::string lite_model_file_;
// model data readed from file or memory buffer in combined format.
std::string lite_model_file_;
// NOTE: This is a deprecated variable and will be removed in latter release.
std::string model_buffer_;
std::string param_buffer_;
// NOTE: This is a deprecated variable and will be removed in latter release.
std::string model_buffer_;
std::string param_buffer_;
public:
// set model data in combined format, `set_model_from_file` refers to loading
// model from file, set_model_from_buffer refers to loading model from memory
// buffer
void set_model_from_file(const std::string &x);
public:
// set model data in combined format, `set_model_from_file` refers to loading
// model from file, set_model_from_buffer refers to loading model from memory
// buffer
void set_model_from_file(const std::string& x);
void set_model_from_buffer(const std::string& x);
// return model data in lite_model_file_, which is in combined format.
const std::string& lite_model_file() const { return lite_model_file_; }
void set_model_from_buffer(const std::string &x);
// return model_from_memory_, which indicates whether to load model from
// memory buffer.
bool is_model_from_memory() const { return model_from_memory_; }
// note: `model_from_memory` has the same effect as `is_model_from_memory`,
// but is_model_from_memory is recommended and `model_from_memory` will be
// abandoned in v3.0.
bool model_from_memory() const { return model_from_memory_; }
// return model data in lite_model_file_, which is in combined format.
const std::string &lite_model_file() const { return lite_model_file_; }
// NOTE: This is a deprecated API and will be removed in latter release.
void set_model_buffer(const char* model_buffer,
size_t model_buffer_size,
const char* param_buffer,
size_t param_buffer_size);
// return model_from_memory_, which indicates whether to load model from
// memory buffer.
bool is_model_from_memory() const { return model_from_memory_; }
// NOTE: This is a deprecated API and will be removed in latter release.
const std::string& model_buffer() const { return model_buffer_; }
// note: `model_from_memory` has the same effect as `is_model_from_memory`,
// but is_model_from_memory is recommended and `model_from_memory` will be
// abandoned in v3.0.
bool model_from_memory() const { return model_from_memory_; }
// NOTE: This is a deprecated API and will be removed in latter release.
const std::string& param_buffer() const { return param_buffer_; }
// NOTE: This is a deprecated API and will be removed in latter release.
void set_model_buffer(const char *model_buffer,
size_t model_buffer_size,
const char *param_buffer,
size_t param_buffer_size);
// This is the method for allocating workspace_size according to L3Cache size
void SetArmL3CacheSize(
L3CacheSetMethod method = L3CacheSetMethod::kDeviceL3Cache,
int absolute_val = -1);
};
// NOTE: This is a deprecated API and will be removed in latter release.
const std::string &model_buffer() const { return model_buffer_; }
template <typename ConfigT>
LITE_API std::shared_ptr<PaddlePredictor> CreatePaddlePredictor(const ConfigT&);
// NOTE: This is a deprecated API and will be removed in latter release.
const std::string &param_buffer() const { return param_buffer_; }
// This is the method for allocating workspace_size according to L3Cache size
void SetArmL3CacheSize(
L3CacheSetMethod method = L3CacheSetMethod::kDeviceL3Cache,
int absolute_val = -1);
};
template<typename ConfigT>
LITE_API std::shared_ptr<PaddlePredictor> CreatePaddlePredictor(const ConfigT &);
} // namespace lite_api
} // namespace lite_api
} // namespace paddle
#endif // NOLINT

View File

@@ -21,254 +21,254 @@
#include "lite/api/paddle_place.h"
namespace paddle {
namespace lite {
namespace utils {
namespace cv {
typedef paddle::lite_api::Tensor Tensor;
typedef paddle::lite_api::DataLayoutType LayoutType;
namespace lite {
namespace utils {
namespace cv {
typedef paddle::lite_api::Tensor Tensor;
typedef paddle::lite_api::DataLayoutType LayoutType;
// color enum
enum ImageFormat {
RGBA = 0,
BGRA,
RGB,
BGR,
GRAY,
NV21 = 11,
NV12,
YUV420SP,
YUV420P,
YUV422,
YUV444
};
enum ImageFormat {
RGBA = 0,
BGRA,
RGB,
BGR,
GRAY,
NV21 = 11,
NV12,
YUV420SP,
YUV420P,
YUV422,
YUV444
};
// flip enum
enum FlipParam {
XY = -1, // flip along the XY axis
X = 0, // flip along the X axis
Y // flip along the Y axis
};
enum FlipParam {
XY = -1, // flip along the XY axis
X = 0, // flip along the X axis
Y // flip along the Y axis
};
// transform param
typedef struct {
int ih; // input height
int iw; // input width
int oh; // outpu theight
int ow; // output width
FlipParam flip_param; // flip, support x, y, xy
float rotate_param; // rotate, support 90, 180, 270
} TransParam;
typedef struct {
int ih; // input height
int iw; // input width
int oh; // outpu theight
int ow; // output width
FlipParam flip_param; // flip, support x, y, xy
float rotate_param; // rotate, support 90, 180, 270
} TransParam;
class ImagePreprocess {
public:
/*
* init
* param srcFormat: input image color
* param dstFormat: output image color
* param param: input image parameter, egs: input size
*/
ImagePreprocess(ImageFormat srcFormat,
ImageFormat dstFormat,
TransParam param);
class ImagePreprocess {
public:
/*
* init
* param srcFormat: input image color
* param dstFormat: output image color
* param param: input image parameter, egs: input size
*/
ImagePreprocess(ImageFormat srcFormat,
ImageFormat dstFormat,
TransParam param);
/*
* image color convert
* support NV12/NV21_to_BGR(RGB), NV12/NV21_to_BGRA(RGBA),
* BGR(RGB)and BGRA(RGBA) transform,
* BGR(RGB)and RGB(BGR) transform,
* BGR(RGB)and RGBA(BGRA) transform,
* BGR(RGB) and GRAY transform,
* BGRA(RGBA) and GRAY transform,
* param src: input image data
* param dst: output image data
*/
void image_convert(const uint8_t *src, uint8_t *dst);
/*
* image color convert
* support NV12/NV21_to_BGR(RGB), NV12/NV21_to_BGRA(RGBA),
* BGR(RGB)and BGRA(RGBA) transform,
* BGR(RGB)and RGB(BGR) transform,
* BGR(RGB)and RGBA(BGRA) transform,
* BGR(RGB) and GRAY transform,
* BGRA(RGBA) and GRAY transform,
* param src: input image data
* param dst: output image data
*/
void image_convert(const uint8_t* src, uint8_t* dst);
/*
* image color convert
* support NV12/NV21_to_BGR(RGB), NV12/NV21_to_BGRA(RGBA),
* BGR(RGB)and BGRA(RGBA) transform,
* BGR(RGB)and RGB(BGR) transform,
* BGR(RGB)and RGBA(BGRA) transform,
* BGR(RGB)and GRAY transform,
* BGRA(RGBA) and GRAY transform,
* param src: input image data
* param dst: output image data
* param srcFormat: input image image format support: GRAY, NV12(NV21),
* BGR(RGB) and BGRA(RGBA)
* param dstFormat: output image image format, support GRAY, BGR(RGB) and
* BGRA(RGBA)
*/
void image_convert(const uint8_t *src,
uint8_t *dst,
ImageFormat srcFormat,
ImageFormat dstFormat);
/*
* image color convert
* support NV12/NV21_to_BGR(RGB), NV12/NV21_to_BGRA(RGBA),
* BGR(RGB)and BGRA(RGBA) transform,
* BGR(RGB)and RGB(BGR) transform,
* BGR(RGB)and RGBA(BGRA) transform,
* BGR(RGB)and GRAY transform,
* BGRA(RGBA) and GRAY transform,
* param src: input image data
* param dst: output image data
* param srcFormat: input image image format support: GRAY, NV12(NV21),
* BGR(RGB) and BGRA(RGBA)
* param dstFormat: output image image format, support GRAY, BGR(RGB) and
* BGRA(RGBA)
*/
void image_convert(const uint8_t* src,
uint8_t* dst,
ImageFormat srcFormat,
ImageFormat dstFormat);
/*
* image color convert
* support NV12/NV21_to_BGR(RGB), NV12/NV21_to_BGRA(RGBA),
* BGR(RGB)and BGRA(RGBA) transform,
* BGR(RGB)and RGB(BGR) transform,
* BGR(RGB)and RGBA(BGRA) transform,
* BGR(RGB)and GRAY transform,
* BGRA(RGBA) and GRAY transform,
* param src: input image data
* param dst: output image data
* param srcFormat: input image image format support: GRAY, NV12(NV21),
* BGR(RGB) and BGRA(RGBA)
* param dstFormat: output image image format, support GRAY, BGR(RGB) and
* BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
*/
void image_convert(const uint8_t *src,
uint8_t *dst,
ImageFormat srcFormat,
ImageFormat dstFormat,
int srcw,
int srch);
/*
* image color convert
* support NV12/NV21_to_BGR(RGB), NV12/NV21_to_BGRA(RGBA),
* BGR(RGB)and BGRA(RGBA) transform,
* BGR(RGB)and RGB(BGR) transform,
* BGR(RGB)and RGBA(BGRA) transform,
* BGR(RGB)and GRAY transform,
* BGRA(RGBA) and GRAY transform,
* param src: input image data
* param dst: output image data
* param srcFormat: input image image format support: GRAY, NV12(NV21),
* BGR(RGB) and BGRA(RGBA)
* param dstFormat: output image image format, support GRAY, BGR(RGB) and
* BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
*/
void image_convert(const uint8_t* src,
uint8_t* dst,
ImageFormat srcFormat,
ImageFormat dstFormat,
int srcw,
int srch);
/*
* image resize, use bilinear method
* support image format: 1-channel image (egs: GRAY, 2-channel image (egs:
* NV12, NV21), 3-channel(egs: BGR), 4-channel(egs: BGRA)
* param src: input image data
* param dst: output image data
*/
void image_resize(const uint8_t *src, uint8_t *dst);
/*
* image resize, use bilinear method
* support image format: 1-channel image (egs: GRAY, 2-channel image (egs:
* NV12, NV21), 3-channel(egs: BGR), 4-channel(egs: BGRA)
* param src: input image data
* param dst: output image data
*/
void image_resize(const uint8_t* src, uint8_t* dst);
/*
image resize, use bilinear method
* support image format: 1-channel image (egs: GRAY, 2-channel image (egs:
NV12, NV21), 3-channel image(egs: BGR), 4-channel image(egs: BGRA)
* param src: input image data
* param dst: output image data
* param srcw: input image width
* param srch: input image height
* param dstw: output image width
* param dsth: output image height
*/
void image_resize(const uint8_t *src,
uint8_t *dst,
ImageFormat srcFormat,
int srcw,
int srch,
int dstw,
int dsth);
/*
image resize, use bilinear method
* support image format: 1-channel image (egs: GRAY, 2-channel image (egs:
NV12, NV21), 3-channel image(egs: BGR), 4-channel image(egs: BGRA)
* param src: input image data
* param dst: output image data
* param srcw: input image width
* param srch: input image height
* param dstw: output image width
* param dsth: output image height
*/
void image_resize(const uint8_t* src,
uint8_t* dst,
ImageFormat srcFormat,
int srcw,
int srch,
int dstw,
int dsth);
/*
* image Rotate
* support 90, 180 and 270 Rotate process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
*/
void image_rotate(const uint8_t *src, uint8_t *dst);
/*
* image Rotate
* support 90, 180 and 270 Rotate process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
*/
void image_rotate(const uint8_t* src, uint8_t* dst);
/*
* image Rotate
* support 90, 180 and 270 Rotate process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
* param srcFormat: input image format, support GRAY, BGR(RGB) and BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
* param degree: Rotate degree, support 90, 180 and 270
*/
void image_rotate(const uint8_t *src,
uint8_t *dst,
ImageFormat srcFormat,
int srcw,
int srch,
float degree);
/*
* image Rotate
* support 90, 180 and 270 Rotate process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
* param srcFormat: input image format, support GRAY, BGR(RGB) and BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
* param degree: Rotate degree, support 90, 180 and 270
*/
void image_rotate(const uint8_t* src,
uint8_t* dst,
ImageFormat srcFormat,
int srcw,
int srch,
float degree);
/*
* image Flip
* support X, Y and XY flip process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
*/
void image_flip(const uint8_t *src, uint8_t *dst);
/*
* image Flip
* support X, Y and XY flip process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
*/
void image_flip(const uint8_t* src, uint8_t* dst);
/*
* image Flip
* support X, Y and XY flip process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
* param srcFormat: input image format, support GRAY, BGR(RGB) and BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
* param flip_param: flip parameter, support X, Y and XY
*/
void image_flip(const uint8_t *src,
uint8_t *dst,
ImageFormat srcFormat,
int srcw,
int srch,
FlipParam flip_param);
/*
* image Flip
* support X, Y and XY flip process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
* param srcFormat: input image format, support GRAY, BGR(RGB) and BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
* param flip_param: flip parameter, support X, Y and XY
*/
void image_flip(const uint8_t* src,
uint8_t* dst,
ImageFormat srcFormat,
int srcw,
int srch,
FlipParam flip_param);
/*
* change image data to tensor data
* support image format is GRAY, BGR(RGB) and BGRA(RGBA), Data layout is NHWC
* and
* NCHW
* param src: input image data
* param dstTensor: output tensor data
* param layout: output tensor layoutsupport NHWC and NCHW
* param means: means of image
* param scales: scales of image
*/
void image_to_tensor(const uint8_t *src,
Tensor *dstTensor,
LayoutType layout,
float *means,
float *scales);
/*
* change image data to tensor data
* support image format is GRAY, BGR(RGB) and BGRA(RGBA), Data layout is NHWC
* and
* NCHW
* param src: input image data
* param dstTensor: output tensor data
* param layout: output tensor layoutsupport NHWC and NCHW
* param means: means of image
* param scales: scales of image
*/
void image_to_tensor(const uint8_t* src,
Tensor* dstTensor,
LayoutType layout,
float* means,
float* scales);
/*
* change image data to tensor data
* support image format is GRAY, BGR(RGB) and BGRA(RGBA), Data layout is NHWC
* and
* NCHW
* param src: input image data
* param dstTensor: output tensor data
* param srcFormat: input image format, support BGR(RGB) and BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
* param layout: output tensor layoutsupport NHWC and NCHW
* param means: means of image
* param scales: scales of image
*/
void image_to_tensor(const uint8_t *src,
Tensor *dstTensor,
ImageFormat srcFormat,
int srcw,
int srch,
LayoutType layout,
float *means,
float *scales);
/*
* change image data to tensor data
* support image format is GRAY, BGR(RGB) and BGRA(RGBA), Data layout is NHWC
* and
* NCHW
* param src: input image data
* param dstTensor: output tensor data
* param srcFormat: input image format, support BGR(RGB) and BGRA(RGBA)
* param srcw: input image width
* param srch: input image height
* param layout: output tensor layoutsupport NHWC and NCHW
* param means: means of image
* param scales: scales of image
*/
void image_to_tensor(const uint8_t* src,
Tensor* dstTensor,
ImageFormat srcFormat,
int srcw,
int srch,
LayoutType layout,
float* means,
float* scales);
/*
* image crop process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
*/
void image_crop(const uint8_t *src,
uint8_t *dst,
ImageFormat srcFormat,
int srcw,
int srch,
int left_x,
int left_y,
int dstw,
int dsth);
/*
* image crop process
* color format support 1-channel image, 3-channel image and 4-channel image
* param src: input image data
* param dst: output image data
*/
void image_crop(const uint8_t* src,
uint8_t* dst,
ImageFormat srcFormat,
int srcw,
int srch,
int left_x,
int left_y,
int dstw,
int dsth);
private:
ImageFormat srcFormat_;
ImageFormat dstFormat_;
TransParam transParam_;
};
} // namespace cv
} // namespace utils
} // namespace lite
private:
ImageFormat srcFormat_;
ImageFormat dstFormat_;
TransParam transParam_;
};
} // namespace cv
} // namespace utils
} // namespace lite
} // namespace paddle

View File

@@ -13,7 +13,6 @@
// limitations under the License.
#pragma once
#include <set>
#include <string>
@@ -41,142 +40,140 @@
#endif
namespace paddle {
namespace lite_api {
namespace lite_api {
enum class TargetType : int {
kUnk = 0,
kHost = 1,
kX86 = 2,
kCUDA = 3,
kARM = 4,
kOpenCL = 5,
kAny = 6, // any target
kFPGA = 7,
kNPU = 8,
kXPU = 9,
kBM = 10,
kMLU = 11,
kRKNPU = 12,
kAPU = 13,
kHuaweiAscendNPU = 14,
kImaginationNNA = 15,
kIntelFPGA = 16,
kMetal = 17,
kNNAdapter = 18,
NUM = 19, // number of fields.
};
enum class PrecisionType : int {
kUnk = 0,
kFloat = 1,
kInt8 = 2,
kInt32 = 3,
kAny = 4, // any precision
kFP16 = 5,
kBool = 6,
kInt64 = 7,
kInt16 = 8,
kUInt8 = 9,
kFP64 = 10,
NUM = 11, // number of fields.
};
enum class DataLayoutType : int {
kUnk = 0,
kNCHW = 1,
kNHWC = 3,
kImageDefault = 4, // for opencl image2d
kImageFolder = 5, // for opencl image2d
kImageNW = 6, // for opencl image2d
kAny = 2, // any data layout
kMetalTexture2DArray = 7,
kMetalTexture2D = 8,
NUM = 9, // number of fields.
};
enum class TargetType : int {
kUnk = 0,
kHost = 1,
kX86 = 2,
kCUDA = 3,
kARM = 4,
kOpenCL = 5,
kAny = 6, // any target
kFPGA = 7,
kNPU = 8,
kXPU = 9,
kBM = 10,
kMLU = 11,
kRKNPU = 12,
kAPU = 13,
kHuaweiAscendNPU = 14,
kImaginationNNA = 15,
kIntelFPGA = 16,
kMetal = 17,
kNNAdapter = 18,
NUM = 19, // number of fields.
};
enum class PrecisionType : int {
kUnk = 0,
kFloat = 1,
kInt8 = 2,
kInt32 = 3,
kAny = 4, // any precision
kFP16 = 5,
kBool = 6,
kInt64 = 7,
kInt16 = 8,
kUInt8 = 9,
kFP64 = 10,
NUM = 11, // number of fields.
};
enum class DataLayoutType : int {
kUnk = 0,
kNCHW = 1,
kNHWC = 3,
kImageDefault = 4, // for opencl image2d
kImageFolder = 5, // for opencl image2d
kImageNW = 6, // for opencl image2d
kAny = 2, // any data layout
kMetalTexture2DArray = 7,
kMetalTexture2D = 8,
NUM = 9, // number of fields.
};
typedef enum {
LITE_POWER_HIGH = 0,
LITE_POWER_LOW = 1,
LITE_POWER_FULL = 2,
LITE_POWER_NO_BIND = 3,
LITE_POWER_RAND_HIGH = 4,
LITE_POWER_RAND_LOW = 5
} PowerMode;
typedef enum {
LITE_POWER_HIGH = 0,
LITE_POWER_LOW = 1,
LITE_POWER_FULL = 2,
LITE_POWER_NO_BIND = 3,
LITE_POWER_RAND_HIGH = 4,
LITE_POWER_RAND_LOW = 5
} PowerMode;
typedef enum {
CL_TUNE_NONE = 0,
CL_TUNE_RAPID = 1,
CL_TUNE_NORMAL = 2,
CL_TUNE_EXHAUSTIVE = 3
} CLTuneMode;
typedef enum {
CL_TUNE_NONE = 0,
CL_TUNE_RAPID = 1,
CL_TUNE_NORMAL = 2,
CL_TUNE_EXHAUSTIVE = 3
} CLTuneMode;
typedef enum {
CL_PRECISION_AUTO = 0,
CL_PRECISION_FP32 = 1,
CL_PRECISION_FP16 = 2
} CLPrecisionType;
typedef enum {
CL_PRECISION_AUTO = 0,
CL_PRECISION_FP32 = 1,
CL_PRECISION_FP16 = 2
} CLPrecisionType;
typedef enum {
MLU_220 = 0, MLU_270 = 1
} MLUCoreVersion;
typedef enum { MLU_220 = 0, MLU_270 = 1 } MLUCoreVersion;
enum class ActivationType : int {
kIndentity = 0,
kRelu = 1,
kRelu6 = 2,
kPRelu = 3,
kLeakyRelu = 4,
kSigmoid = 5,
kTanh = 6,
kSwish = 7,
kExp = 8,
kAbs = 9,
kHardSwish = 10,
kReciprocal = 11,
kThresholdedRelu = 12,
kElu = 13,
kHardSigmoid = 14,
kLog = 15,
kSigmoid_v2 = 16,
kTanh_v2 = 17,
kGelu = 18,
kErf = 19,
kSign = 20,
kSoftPlus = 21,
kMish = 22,
NUM = 23,
};
enum class ActivationType : int {
kIndentity = 0,
kRelu = 1,
kRelu6 = 2,
kPRelu = 3,
kLeakyRelu = 4,
kSigmoid = 5,
kTanh = 6,
kSwish = 7,
kExp = 8,
kAbs = 9,
kHardSwish = 10,
kReciprocal = 11,
kThresholdedRelu = 12,
kElu = 13,
kHardSigmoid = 14,
kLog = 15,
kSigmoid_v2 = 16,
kTanh_v2 = 17,
kGelu = 18,
kErf = 19,
kSign = 20,
kSoftPlus = 21,
kMish = 22,
NUM = 23,
};
static size_t PrecisionTypeLength(PrecisionType type) {
switch (type) {
case PrecisionType::kFloat:
return 4;
case PrecisionType::kFP64:
return 8;
case PrecisionType::kUInt8:
return 1;
case PrecisionType::kInt8:
return 1;
case PrecisionType::kInt32:
return 4;
case PrecisionType::kInt64:
return 8;
case PrecisionType::kFP16:
return 2;
case PrecisionType::kInt16:
return 2;
default:
return 0;
}
}
static size_t PrecisionTypeLength(PrecisionType type) {
switch (type) {
case PrecisionType::kFloat:
return 4;
case PrecisionType::kFP64:
return 8;
case PrecisionType::kUInt8:
return 1;
case PrecisionType::kInt8:
return 1;
case PrecisionType::kInt32:
return 4;
case PrecisionType::kInt64:
return 8;
case PrecisionType::kFP16:
return 2;
case PrecisionType::kInt16:
return 2;
default:
return 0;
}
}
enum class QuantType : int {
QUANT_INT8,
QUANT_INT16,
};
enum class QuantType : int {
QUANT_INT8,
QUANT_INT16,
};
template<typename T>
struct PrecisionTypeTrait {
constexpr static PrecisionType Type() { return PrecisionType::kUnk; }
};
template <typename T>
struct PrecisionTypeTrait {
constexpr static PrecisionType Type() { return PrecisionType::kUnk; }
};
#define _ForEachPrecisionTypeHelper(callback, cpp_type, precision_type) \
callback(cpp_type, ::paddle::lite_api::PrecisionType::precision_type);
@@ -197,11 +194,11 @@ namespace paddle {
constexpr static PrecisionType Type() { return precision_type; } \
}
_ForEachPrecisionType(DefinePrecisionTypeTrait);
_ForEachPrecisionType(DefinePrecisionTypeTrait);
#ifdef ENABLE_ARM_FP16
typedef __fp16 float16_t;
_ForEachPrecisionTypeHelper(DefinePrecisionTypeTrait, float16_t, kFP16);
typedef __fp16 float16_t;
_ForEachPrecisionTypeHelper(DefinePrecisionTypeTrait, float16_t, kFP16);
#endif
#undef _ForEachPrecisionTypeHelper
@@ -212,71 +209,70 @@ namespace paddle {
#define PRECISION(item__) paddle::lite_api::PrecisionType::item__
#define DATALAYOUT(item__) paddle::lite_api::DataLayoutType::item__
const std::string &ActivationTypeToStr(ActivationType act);
const std::string& ActivationTypeToStr(ActivationType act);
const std::string &TargetToStr(TargetType target);
const std::string& TargetToStr(TargetType target);
const std::string &PrecisionToStr(PrecisionType precision);
const std::string& PrecisionToStr(PrecisionType precision);
const std::string &DataLayoutToStr(DataLayoutType layout);
const std::string& DataLayoutToStr(DataLayoutType layout);
const std::string &TargetRepr(TargetType target);
const std::string& TargetRepr(TargetType target);
const std::string &PrecisionRepr(PrecisionType precision);
const std::string& PrecisionRepr(PrecisionType precision);
const std::string &DataLayoutRepr(DataLayoutType layout);
const std::string& DataLayoutRepr(DataLayoutType layout);
const std::string &CLTuneModeToStr(CLTuneMode mode);
const std::string& CLTuneModeToStr(CLTuneMode mode);
const std::string &CLPrecisionTypeToStr(CLPrecisionType type);
const std::string& CLPrecisionTypeToStr(CLPrecisionType type);
// Get a set of all the elements represented by the target.
std::set<TargetType> ExpandValidTargets(TargetType target = TARGET(kAny));
std::set<TargetType> ExpandValidTargets(TargetType target = TARGET(kAny));
// Get a set of all the elements represented by the precision.
std::set<PrecisionType> ExpandValidPrecisions(
PrecisionType precision = PRECISION(kAny));
std::set<PrecisionType> ExpandValidPrecisions(
PrecisionType precision = PRECISION(kAny));
// Get a set of all the elements represented by the layout.
std::set<DataLayoutType> ExpandValidLayouts(
DataLayoutType layout = DATALAYOUT(kAny));
std::set<DataLayoutType> ExpandValidLayouts(
DataLayoutType layout = DATALAYOUT(kAny));
/*
* Place specifies the execution context of a Kernel or input/output for a
* kernel. It is used to make the analysis of the MIR more clear and accurate.
*/
struct LITE_API Place {
TargetType target{TARGET(kUnk)};
PrecisionType precision{PRECISION(kUnk)};
DataLayoutType layout{DATALAYOUT(kUnk)};
int16_t device{0}; // device ID
struct LITE_API Place {
TargetType target{TARGET(kUnk)};
PrecisionType precision{PRECISION(kUnk)};
DataLayoutType layout{DATALAYOUT(kUnk)};
int16_t device{0}; // device ID
Place() = default;
Place() = default;
Place(TargetType target,
PrecisionType precision = PRECISION(kFloat),
DataLayoutType layout = DATALAYOUT(kNCHW),
int16_t device = 0)
: target(target), precision(precision), layout(layout), device(device) {}
Place(TargetType target,
PrecisionType precision = PRECISION(kFloat),
DataLayoutType layout = DATALAYOUT(kNCHW),
int16_t device = 0)
: target(target), precision(precision), layout(layout), device(device) {}
bool is_valid() const {
return target != TARGET(kUnk) && precision != PRECISION(kUnk) &&
layout != DATALAYOUT(kUnk);
}
bool is_valid() const {
return target != TARGET(kUnk) && precision != PRECISION(kUnk) &&
layout != DATALAYOUT(kUnk);
}
size_t hash() const;
size_t hash() const;
bool operator==(const Place& other) const {
return target == other.target && precision == other.precision &&
layout == other.layout && device == other.device;
}
bool operator==(const Place &other) const {
return target == other.target && precision == other.precision &&
layout == other.layout && device == other.device;
}
bool operator!=(const Place& other) const { return !(*this == other); }
bool operator!=(const Place &other) const { return !(*this == other); }
friend bool operator<(const Place& a, const Place& b);
friend bool operator<(const Place &a, const Place &b);
std::string DebugString() const;
};
std::string DebugString() const;
};
} // namespace lite_api
} // namespace lite_api
} // namespace paddle

View File

@@ -1,781 +1,392 @@
#pragma once
#include "paddle_lite_factory_helper.h"
USE_LITE_KERNEL(arg_max, kHost, kAny, kNCHW, fp32);
USE_LITE_KERNEL(arg_max, kHost, kAny, kNCHW, int64);
USE_LITE_KERNEL(arg_max, kHost, kAny, kNCHW, int32);
USE_LITE_KERNEL(arg_max, kHost, kAny, kNCHW, int16);
USE_LITE_KERNEL(arg_max, kHost, kAny, kNCHW, uint8);
USE_LITE_KERNEL(mul, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(relu, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(leaky_relu, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(relu_clipped, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(prelu, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(sigmoid, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(tanh, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(swish, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(relu6, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(log, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(exp, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(floor, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(hard_sigmoid, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(rsqrt, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(square, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(hard_swish, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(reciprocal, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(abs, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(thresholded_relu, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(elu, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(scatter_nd_add, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(scatter_nd_add, kHost, kFloat, kNCHW, float32_int64);
USE_LITE_KERNEL(scatter_nd_add, kHost, kFloat, kNCHW, int32_int32);
USE_LITE_KERNEL(scatter_nd_add, kHost, kFloat, kNCHW, int32_int64);
USE_LITE_KERNEL(scatter_nd_add, kHost, kFloat, kNCHW, int64_int32);
USE_LITE_KERNEL(scatter_nd_add, kHost, kFloat, kNCHW, int64_int64);
USE_LITE_KERNEL(strided_slice, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(strided_slice, kHost, kInt32, kNCHW, def);
USE_LITE_KERNEL(strided_slice, kHost, kInt64, kNCHW, def);
USE_LITE_KERNEL(top_k, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(split_lod_tensor, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(inverse, kHost, kFloat, kNCHW, fp32);
USE_LITE_KERNEL(box_coder, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(scatter, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sequence_pad, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(sequence_pad, kHost, kFloat, kNCHW, int32);
USE_LITE_KERNEL(sequence_pad, kHost, kFloat, kNCHW, int64);
USE_LITE_KERNEL(sequence_softmax, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(conv2d, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(depthwise_conv2d, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(conv2d, kARM, kInt8, kNCHW, int8_out);
USE_LITE_KERNEL(conv2d, kARM, kInt8, kNCHW, fp32_out);
USE_LITE_KERNEL(depthwise_conv2d, kARM, kInt8, kNCHW, int8_out);
USE_LITE_KERNEL(depthwise_conv2d, kARM, kInt8, kNCHW, fp32_out);
USE_LITE_KERNEL(sum, kARM, kFloat, kNCHW, sum_i32);
USE_LITE_KERNEL(sum, kARM, kFloat, kNCHW, sum_i64);
USE_LITE_KERNEL(sum, kARM, kFloat, kNCHW, sum_fp32);
USE_LITE_KERNEL(gather_tree, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(gather_tree, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(increment, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(write_back, kHost, kAny, kAny, write_back);
USE_LITE_KERNEL(index_select, kHost, kAny, kNCHW, fp32);
USE_LITE_KERNEL(index_select, kHost, kAny, kNCHW, int32);
USE_LITE_KERNEL(index_select, kHost, kAny, kNCHW, int16);
USE_LITE_KERNEL(index_select, kHost, kAny, kNCHW, int8);
USE_LITE_KERNEL(yolo_box, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_prod, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(reduce_prod, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_prod, kARM, kFloat, kNCHW, reduce_prod_i64);
USE_LITE_KERNEL(reduce_prod, kARM, kFloat, kNCHW, int32);
USE_LITE_KERNEL(cos, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(conditional_block, kHost, kAny, kAny, def);
USE_LITE_KERNEL(crf_decoding, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(density_prior_box, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(fill_constant_batch_size_like, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(deformable_conv, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(roi_align, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(tensor_array_to_tensor, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(print, kHost, kAny, kAny, def);
USE_LITE_KERNEL(reduce_sum, kARM, kFloat, kNCHW, def_int32);
USE_LITE_KERNEL(reduce_sum, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(expand, kHost, kAny, kAny, def);
USE_LITE_KERNEL(clip, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(generate_proposals, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(select_input, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(calib, kARM, kInt8, kNCHW, fp32_to_int8);
USE_LITE_KERNEL(calib, kARM, kInt32, kNCHW, int32_to_fp32);
USE_LITE_KERNEL(calib, kARM, kInt32, kNCHW, int32_to_int64);
USE_LITE_KERNEL(calib, kARM, kInt32, kNCHW, fp32_to_int32);
USE_LITE_KERNEL(calib, kARM, kInt64, kNCHW, int64_to_fp32);
USE_LITE_KERNEL(calib, kARM, kInt8, kNCHW, int8_to_fp32);
USE_LITE_KERNEL(calib, kARM, kInt64, kNCHW, int64_to_int32);
USE_LITE_KERNEL(calib_once, kARM, kInt8, kNCHW, fp32_to_int8);
USE_LITE_KERNEL(calib_once, kARM, kInt8, kNCHW, int8_to_fp32);
USE_LITE_KERNEL(calib_once, kARM, kInt64, kNCHW, int64_to_int32);
USE_LITE_KERNEL(affine_channel, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fill_zeros_like, kHost, kFloat, kNCHW, float32);
USE_LITE_KERNEL(fill_zeros_like, kHost, kFloat, kNCHW, int32);
USE_LITE_KERNEL(fill_zeros_like, kHost, kFloat, kNCHW, int64);
USE_LITE_KERNEL(reverse, kHost, kAny, kNCHW, fp32);
USE_LITE_KERNEL(depthwise_conv2d_transpose, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(depthwise_conv2d_transpose, kARM, kInt8, kNCHW, fp32_out);
USE_LITE_KERNEL(depthwise_conv2d_transpose, kARM, kInt8, kNCHW, int8_out);
USE_LITE_KERNEL(decode_bboxes, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sequence_unpad, kHost, kFloat, kAny, float32);
USE_LITE_KERNEL(sequence_unpad, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(shape, kHost, kAny, kAny, def);
USE_LITE_KERNEL(meshgrid, kHost, kFloat, kAny, float32);
USE_LITE_KERNEL(meshgrid, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(flatten_contiguous_range, kHost, kAny, kAny, def);
USE_LITE_KERNEL(pixel_shuffle, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(gru_unit, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(negative, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(axpy, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(gather, kHost, kFloat, kNCHW, int32int32);
USE_LITE_KERNEL(gather, kHost, kFloat, kNCHW, int64int64);
USE_LITE_KERNEL(gather, kHost, kFloat, kNCHW, int64int32);
USE_LITE_KERNEL(gather, kHost, kFloat, kNCHW, int32int64);
USE_LITE_KERNEL(equal, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(equal, kHost, kInt64, kAny, def);
USE_LITE_KERNEL(equal, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(equal, kHost, kInt32, kAny, def);
USE_LITE_KERNEL(equal, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(not_equal, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(not_equal, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(not_equal, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(less_than, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(less_than, kHost, kInt32, kAny, def);
USE_LITE_KERNEL(less_than, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(less_than, kHost, kInt64, kAny, def);
USE_LITE_KERNEL(less_than, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(less_equal, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(less_equal, kHost, kInt64, kAny, def);
USE_LITE_KERNEL(less_equal, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(greater_than, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(greater_than, kHost, kFloat, kAny, bool);
USE_LITE_KERNEL(greater_than, kHost, kInt32, kAny, def);
USE_LITE_KERNEL(greater_than, kHost, kInt64, kAny, def);
USE_LITE_KERNEL(greater_than, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(greater_equal, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(greater_equal, kHost, kFloat, kAny, def_int64);
USE_LITE_KERNEL(multiclass_nms, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(multiclass_nms2, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(multiclass_nms3, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(gaussian_random, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(read_from_array, kHost, kAny, kAny, def);
USE_LITE_KERNEL(softmax, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(split, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(split, kHost, kFloat, kNCHW, int32);
USE_LITE_KERNEL(split, kHost, kFloat, kNCHW, int64);
USE_LITE_KERNEL(split, kHost, kInt64, kNCHW, def);
USE_LITE_KERNEL(group_norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(instance_norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(pad2d, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(layer_norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(assign_value, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(one_hot, kHost, kAny, kAny, def);
USE_LITE_KERNEL(one_hot_v2, kHost, kAny, kAny, def);
USE_LITE_KERNEL(one_hot_v2, kHost, kAny, kAny, one_hot_v2_int32);
USE_LITE_KERNEL(distribute_fpn_proposals, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(sin, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(fc, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fc, kARM, kInt8, kNCHW, int8out);
USE_LITE_KERNEL(fc, kARM, kInt8, kNCHW, fp32out);
USE_LITE_KERNEL(unique_with_counts, kHost, kAny, kAny, def);
USE_LITE_KERNEL(unstack, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(unstack, kHost, kFloat, kAny, unstack_int32);
USE_LITE_KERNEL(collect_fpn_proposals, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(transpose, kARM, kAny, kNCHW, def);
USE_LITE_KERNEL(transpose2, kARM, kAny, kNCHW, def);
USE_LITE_KERNEL(assign, kHost, kAny, kAny, def);
USE_LITE_KERNEL(assign, kHost, kAny, kAny, def_tensor_array);
USE_LITE_KERNEL(lookup_table_dequant, kARM, kAny, kNCHW, def);
USE_LITE_KERNEL(crop_tensor, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(crop_tensor, kHost, kFloat, kAny, int32_precision);
USE_LITE_KERNEL(feed, kHost, kAny, kAny, def);
USE_LITE_KERNEL(matmul, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(matmul, kARM, kInt8, kNCHW, def);
USE_LITE_KERNEL(scale, kARM, kFloat, kNCHW, int32);
USE_LITE_KERNEL(scale, kARM, kFloat, kNCHW, int64);
USE_LITE_KERNEL(scale, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(scale, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(scale, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(dropout, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(grid_sampler, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(pow, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fetch, kHost, kAny, kAny, def);
USE_LITE_KERNEL(squeeze, kHost, kAny, kAny, def);
USE_LITE_KERNEL(squeeze2, kHost, kAny, kAny, def);
USE_LITE_KERNEL(affine_grid, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(crop, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(crop, kHost, kInt32, kAny, def);
USE_LITE_KERNEL(merge_lod_tensor, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(cos_sim, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(lod_reset, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(relu, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(leaky_relu, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(prelu, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sigmoid, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(tanh, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(relu6, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(thresholded_relu, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elu, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(bilinear_interp, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(nearest_interp, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(bilinear_interp_v2, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(nearest_interp_v2, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(correlation, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(tril_triu, kHost, kAny, kNCHW, float32);
USE_LITE_KERNEL(uniform_random, kHost, kAny, kAny, def);
USE_LITE_KERNEL(is_empty, kHost, kAny, kAny, def);
USE_LITE_KERNEL(anchor_generator, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(logical_xor, kHost, kAny, kAny, def);
USE_LITE_KERNEL(logical_and, kHost, kAny, kAny, def);
USE_LITE_KERNEL(logical_or, kHost, kAny, kAny, def);
USE_LITE_KERNEL(logical_not, kHost, kAny, kAny, def);
USE_LITE_KERNEL(mean, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(write_to_array, kHost, kAny, kAny, def);
USE_LITE_KERNEL(sparse_conv2d, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sparse_conv2d, kARM, kInt8, kNCHW, int8_fp32_out);
USE_LITE_KERNEL(sparse_conv2d, kARM, kInt8, kNCHW, int8_int8_out);
USE_LITE_KERNEL(arg_max, kARM, kAny, kNCHW, fp32);
USE_LITE_KERNEL(arg_max, kARM, kAny, kNCHW, int64);
USE_LITE_KERNEL(arg_max, kARM, kAny, kNCHW, int32);
USE_LITE_KERNEL(arg_max, kARM, kAny, kNCHW, int16);
USE_LITE_KERNEL(arg_max, kARM, kAny, kNCHW, uint8);
USE_LITE_KERNEL(stack, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(stack, kHost, kFloat, kAny, int32_def);
USE_LITE_KERNEL(stack, kHost, kFloat, kAny, int64_def);
USE_LITE_KERNEL(where_index, kHost, kAny, kAny, def);
USE_LITE_KERNEL(reduce_mean, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(beam_search_decode, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(argsort, kHost, kFloat, kAny, argsort_fp32);
USE_LITE_KERNEL(argsort, kHost, kFloat, kAny, argsort_int32);
USE_LITE_KERNEL(argsort, kHost, kFloat, kAny, argsort_int64);
USE_LITE_KERNEL(lookup_table, kARM, kAny, kNCHW, def);
USE_LITE_KERNEL(lookup_table_v2, kARM, kAny, kNCHW, def);
USE_LITE_KERNEL(beam_search, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(pool2d, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(slice, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(slice, kARM, kFloat, kNCHW, float_i64_starts_ends);
USE_LITE_KERNEL(slice, kARM, kFloat, kNCHW, bool_slice);
USE_LITE_KERNEL(slice, kARM, kFloat, kNCHW, int32_slice);
USE_LITE_KERNEL(slice, kARM, kFloat, kNCHW, def_int64);
USE_LITE_KERNEL(expand_as, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(expand_as, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(batch_norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sync_batch_norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(ctc_align, kHost, kInt64, kNCHW, def);
USE_LITE_KERNEL(ctc_align, kHost, kInt32, kNCHW, def);
USE_LITE_KERNEL(where, kHost, kAny, kAny, def);
USE_LITE_KERNEL(conv2d_transpose, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(conv2d_transpose, kARM, kInt8, kNCHW, fp32_out);
USE_LITE_KERNEL(conv2d_transpose, kARM, kInt8, kNCHW, int8_out);
USE_LITE_KERNEL(elementwise_add, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_add, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(elementwise_add, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(elementwise_add, kARM, kFloat, kNCHW, int32);
USE_LITE_KERNEL(elementwise_add, kARM, kFloat, kNCHW, int64);
USE_LITE_KERNEL(fusion_elementwise_add_activation, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_sub, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_sub, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(elementwise_sub, kARM, kFloat, kNCHW, int32);
USE_LITE_KERNEL(elementwise_sub, kARM, kFloat, kNCHW, int64);
USE_LITE_KERNEL(fusion_elementwise_sub_activation, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_mul, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_mul, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(elementwise_mul, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(elementwise_mul, kARM, kFloat, kNCHW, int32);
USE_LITE_KERNEL(elementwise_mul, kARM, kFloat, kNCHW, int64);
USE_LITE_KERNEL(fusion_elementwise_mul_activation, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fusion_elementwise_mul_activation, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(elementwise_max, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fusion_elementwise_max_activation, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_min, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fusion_elementwise_min_activation, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_div, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_div, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(elementwise_div, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(fusion_elementwise_div_activation, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_mod, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(elementwise_mod, kARM, kFloat, kNCHW, int64);
USE_LITE_KERNEL(elementwise_mod, kARM, kFloat, kNCHW, int32_mod);
USE_LITE_KERNEL(elementwise_pow, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_pow, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(elementwise_floordiv, kARM, kInt32, kNCHW, def);
USE_LITE_KERNEL(elementwise_floordiv, kARM, kInt64, kNCHW, def);
USE_LITE_KERNEL(elementwise_floordiv, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(elementwise_floordiv, kARM, kFloat, kNCHW, int64);
USE_LITE_KERNEL(rnn, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_min, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_min, kARM, kFloat, kNCHW, def_int64);
USE_LITE_KERNEL(sequence_expand, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(lstm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(lstm, kARM, kInt8, kNCHW, def);
USE_LITE_KERNEL(pixel_shuffle, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(box_coder, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(fill_any_like, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(fill_zeros_like, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(generate_proposals_v2, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(pad2d, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(matmul_v2, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(retinanet_detection_output, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(shuffle_channel, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(cast, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(lrn, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(prior_box, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(unsqueeze, kHost, kAny, kAny, def);
USE_LITE_KERNEL(unsqueeze2, kHost, kAny, kAny, def);
USE_LITE_KERNEL(fill_constant, kHost, kAny, kNCHW, def);
USE_LITE_KERNEL(box_clip, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(unbind, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(unbind, kHost, kInt64, kNCHW, def);
USE_LITE_KERNEL(norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(p_norm, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sequence_expand_as, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(tile, kHost, kFloat, kNCHW, def_float);
USE_LITE_KERNEL(tile, kHost, kInt32, kNCHW, def_int32);
USE_LITE_KERNEL(tile, kHost, kInt64, kNCHW, def_int64);
USE_LITE_KERNEL(tile, kHost, kFloat, kNCHW, def_int64);
USE_LITE_KERNEL(tile, kHost, kInt8, kNCHW, def_int8);
USE_LITE_KERNEL(tile, kHost, kFloat, kNCHW, def_bool);
USE_LITE_KERNEL(norm, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(p_norm, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_max, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_max, kARM, kFloat, kNCHW, i64);
USE_LITE_KERNEL(gru, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(gru, kARM, kInt8, kNCHW, def);
USE_LITE_KERNEL(reduce_all, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(reduce_any, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(reshape, kHost, kAny, kAny, def);
USE_LITE_KERNEL(reshape2, kHost, kAny, kAny, def);
USE_LITE_KERNEL(flatten, kHost, kAny, kAny, def);
USE_LITE_KERNEL(flatten2, kHost, kAny, kAny, def);
USE_LITE_KERNEL(concat, kARM, kAny, kNCHW, def);
USE_LITE_KERNEL(sequence_conv, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(relu_clipped, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(swish, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(log, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(exp, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(floor, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(hard_sigmoid, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sqrt, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(rsqrt, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(square, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(hard_swish, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(reciprocal, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(abs, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(gelu, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(erf, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sign, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(softplus, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(mish, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(lod_array_length, kHost, kAny, kAny, def);
USE_LITE_KERNEL(deformable_conv, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(layout, kARM, kFloat, kNCHW, nchw2nhwc);
USE_LITE_KERNEL(layout, kARM, kFloat, kNCHW, nhwc2nchw);
USE_LITE_KERNEL(layout, kARM, kInt8, kNCHW, int8_nchw2nhwc);
USE_LITE_KERNEL(layout, kARM, kInt8, kNCHW, int8_nhwc2nchw);
USE_LITE_KERNEL(layout_once, kARM, kFloat, kNCHW, nchw2nhwc);
USE_LITE_KERNEL(layout_once, kARM, kFloat, kNCHW, nhwc2nchw);
USE_LITE_KERNEL(layout_once, kARM, kInt8, kNCHW, int8_nchw2nhwc);
USE_LITE_KERNEL(layout_once, kARM, kInt8, kNCHW, int8_nhwc2nchw);
USE_LITE_KERNEL(roi_perspective_transform, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(while, kHost, kAny, kAny, def);
USE_LITE_KERNEL(flip, kHost, kAny, kNCHW, flip_fp32);
USE_LITE_KERNEL(flip, kHost, kAny, kNCHW, flip_i64);
USE_LITE_KERNEL(top_k_v2, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(pad3d, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(range, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(range, kHost, kInt64, kAny, def);
USE_LITE_KERNEL(range, kHost, kInt32, kAny, def);
USE_LITE_KERNEL(range, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(range, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(im2sequence, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(unfold, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(unfold, kHost, kFloat, kNCHW, def_int32);
USE_LITE_KERNEL(unfold, kHost, kFloat, kNCHW, def_int64);
USE_LITE_KERNEL(unfold, kHost, kInt8, kNCHW, def_int8);
USE_LITE_KERNEL(gather_nd, kHost, kAny, kAny, def);
USE_LITE_KERNEL(polygon_box_transform, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(expand_v2, kHost, kFloat, kAny, def);
USE_LITE_KERNEL(expand_v2, kHost, kInt32, kAny, def);
USE_LITE_KERNEL(expand_v2, kHost, kFloat, kAny, def_int64);
USE_LITE_KERNEL(sequence_pool, kARM, kFloat, kNCHW, def);
USE_LITE_KERNEL(sequence_mask, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(sequence_mask, kHost, kFloat, kNCHW, int32);
USE_LITE_KERNEL(sequence_mask, kHost, kFloat, kNCHW, int64);
USE_LITE_KERNEL(cumsum, kHost, kFloat, kAny, float32);
USE_LITE_KERNEL(cumsum, kHost, kFloat, kAny, int32);
USE_LITE_KERNEL(cumsum, kHost, kFloat, kAny, int64);
USE_LITE_KERNEL(matrix_nms, kHost, kFloat, kNCHW, def);
USE_LITE_KERNEL(linspace, kHost, kFloat, kAny, float32);
USE_LITE_KERNEL(linspace, kHost, kInt32, kAny, int32);

View File

@@ -1,547 +1,275 @@
#pragma once
#include "paddle_lite_factory_helper.h"
USE_LITE_OP(tensor_array_to_tensor);
USE_LITE_OP(beam_search);
USE_LITE_OP(index_select);
USE_LITE_OP(fusion_elementwise_sub_activation);
USE_LITE_OP(fusion_elementwise_add_activation);
USE_LITE_OP(fusion_elementwise_mul_activation);
USE_LITE_OP(fusion_elementwise_max_activation);
USE_LITE_OP(fusion_elementwise_min_activation);
USE_LITE_OP(fusion_elementwise_div_activation);
USE_LITE_OP(softmax);
USE_LITE_OP(io_copy);
USE_LITE_OP(fake_quantize_moving_average_abs_max);
USE_LITE_OP(scatter_nd_add);
USE_LITE_OP(sum);
USE_LITE_OP(norm);
USE_LITE_OP(p_norm);
USE_LITE_OP(gather_tree);
USE_LITE_OP(collect_fpn_proposals);
USE_LITE_OP(topk_pooling);
USE_LITE_OP(axpy);
USE_LITE_OP(expand_v2);
USE_LITE_OP(top_k_v2);
USE_LITE_OP(generate_proposals);
USE_LITE_OP(write_back);
USE_LITE_OP(conv2d);
USE_LITE_OP(conv3d);
USE_LITE_OP(depthwise_conv2d);
USE_LITE_OP(assign);
USE_LITE_OP(sequence_reverse_embedding);
USE_LITE_OP(cast);
USE_LITE_OP(lstm);
USE_LITE_OP(subgraph);
USE_LITE_OP(gru);
USE_LITE_OP(box_coder);
USE_LITE_OP(sequence_pool_concat);
USE_LITE_OP(crop);
USE_LITE_OP(print);
USE_LITE_OP(one_hot_v2);
USE_LITE_OP(sequence_reshape);
USE_LITE_OP(fake_quantize_range_abs_max);
USE_LITE_OP(fake_quantize_abs_max);
USE_LITE_OP(fill_zeros_like);
USE_LITE_OP(multiclass_nms);
USE_LITE_OP(multiclass_nms2);
USE_LITE_OP(multiclass_nms3);
USE_LITE_OP(tril_triu);
USE_LITE_OP(argsort);
USE_LITE_OP(fill_constant_batch_size_like);
USE_LITE_OP(cos);
USE_LITE_OP(matrix_nms);
USE_LITE_OP(lrn);
USE_LITE_OP(arg_max);
USE_LITE_OP(decode_bboxes);
USE_LITE_OP(layout_once);
USE_LITE_OP(equal);
USE_LITE_OP(not_equal);
USE_LITE_OP(less_than);
USE_LITE_OP(less_equal);
USE_LITE_OP(greater_than);
USE_LITE_OP(greater_equal);
USE_LITE_OP(sequence_mask);
USE_LITE_OP(matmul_v2);
USE_LITE_OP(search_seq_softmax);
USE_LITE_OP(pad2d);
USE_LITE_OP(search_grnn);
USE_LITE_OP(flip);
USE_LITE_OP(expand_as);
USE_LITE_OP(generate_proposals_v2);
USE_LITE_OP(distribute_fpn_proposals);
USE_LITE_OP(rnn);
USE_LITE_OP(fake_channel_wise_dequantize_max_abs);
USE_LITE_OP(search_aligned_mat_mul);
USE_LITE_OP(concat);
USE_LITE_OP(attention_padding_mask);
USE_LITE_OP(search_attention_padding_mask);
USE_LITE_OP(retinanet_detection_output);
USE_LITE_OP(fpga_conv2d);
USE_LITE_OP(pad3d);
USE_LITE_OP(reverse);
USE_LITE_OP(layout);
USE_LITE_OP(range);
USE_LITE_OP(split);
USE_LITE_OP(__xpu__dynamic_lstm_fuse_op);
USE_LITE_OP(stack);
USE_LITE_OP(__xpu__squeeze_excitation_block);
USE_LITE_OP(mean);
USE_LITE_OP(prior_box);
USE_LITE_OP(search_fc);
USE_LITE_OP(__xpu__generate_sequence);
USE_LITE_OP(elementwise_sub);
USE_LITE_OP(elementwise_add);
USE_LITE_OP(elementwise_mul);
USE_LITE_OP(elementwise_max);
USE_LITE_OP(elementwise_min);
USE_LITE_OP(elementwise_div);
USE_LITE_OP(elementwise_floordiv);
USE_LITE_OP(elementwise_mod);
USE_LITE_OP(elementwise_pow);
USE_LITE_OP(sequence_pool);
USE_LITE_OP(correlation);
USE_LITE_OP(sequence_unpad);
USE_LITE_OP(cumsum);
USE_LITE_OP(lod_array_length);
USE_LITE_OP(increment);
USE_LITE_OP(__xpu__multi_softmax);
USE_LITE_OP(fill_constant);
USE_LITE_OP(group_norm);
USE_LITE_OP(scatter);
USE_LITE_OP(lod_reset);
USE_LITE_OP(shuffle_channel);
USE_LITE_OP(gather_nd);
USE_LITE_OP(search_seq_depadding);
USE_LITE_OP(cos_sim);
USE_LITE_OP(is_empty);
USE_LITE_OP(fill_any_like);
USE_LITE_OP(match_matrix_tensor);
USE_LITE_OP(yolo_box);
USE_LITE_OP(__xpu__fc);
USE_LITE_OP(where);
USE_LITE_OP(fake_quantize_dequantize_abs_max);
USE_LITE_OP(grid_sampler);
USE_LITE_OP(conv2d_transpose);
USE_LITE_OP(depthwise_conv2d_transpose);
USE_LITE_OP(__xpu__bigru);
USE_LITE_OP(calib_once);
USE_LITE_OP(sequence_conv);
USE_LITE_OP(__xpu__resnet_cbam);
USE_LITE_OP(pixel_shuffle);
USE_LITE_OP(__xpu__logit);
USE_LITE_OP(sin);
USE_LITE_OP(beam_search_decode);
USE_LITE_OP(polygon_box_transform);
USE_LITE_OP(split_lod_tensor);
USE_LITE_OP(fc);
USE_LITE_OP(var_conv_2d);
USE_LITE_OP(calib);
USE_LITE_OP(sequence_concat);
USE_LITE_OP(__xpu__multi_encoder);
USE_LITE_OP(sequence_pad);
USE_LITE_OP(crf_decoding);
USE_LITE_OP(reshape);
USE_LITE_OP(reshape2);
USE_LITE_OP(gaussian_random);
USE_LITE_OP(pool2d);
USE_LITE_OP(sequence_arithmetic);
USE_LITE_OP(search_seq_arithmetic);
USE_LITE_OP(transpose);
USE_LITE_OP(transpose2);
USE_LITE_OP(one_hot);
USE_LITE_OP(matmul);
USE_LITE_OP(lookup_table_v2);
USE_LITE_OP(unique_with_counts);
USE_LITE_OP(assign_value);
USE_LITE_OP(lookup_table_dequant);
USE_LITE_OP(negative);
USE_LITE_OP(reduce_sum);
USE_LITE_OP(reduce_prod);
USE_LITE_OP(reduce_max);
USE_LITE_OP(reduce_min);
USE_LITE_OP(reduce_all);
USE_LITE_OP(reduce_any);
USE_LITE_OP(reduce_mean);
USE_LITE_OP(pow);
USE_LITE_OP(__xpu__conv2d);
USE_LITE_OP(uniform_random);
USE_LITE_OP(nearest_interp);
USE_LITE_OP(bilinear_interp);
USE_LITE_OP(roi_align);
USE_LITE_OP(dropout);
USE_LITE_OP(write_to_array);
USE_LITE_OP(bilinear_interp_v2);
USE_LITE_OP(nearest_interp_v2);
USE_LITE_OP(strided_slice);
USE_LITE_OP(feed);
USE_LITE_OP(fake_quantize_dequantize_moving_average_abs_max);
USE_LITE_OP(ctc_align);
USE_LITE_OP(scale);
USE_LITE_OP(linspace);
USE_LITE_OP(sequence_topk_avg_pooling);
USE_LITE_OP(im2sequence);
USE_LITE_OP(density_prior_box);
USE_LITE_OP(roi_perspective_transform);
USE_LITE_OP(while);
USE_LITE_OP(top_k);
USE_LITE_OP(mul);
USE_LITE_OP(expand);
USE_LITE_OP(__xpu__sfa_head);
USE_LITE_OP(sequence_expand);
USE_LITE_OP(where_index);
USE_LITE_OP(flatten);
USE_LITE_OP(flatten2);
USE_LITE_OP(flatten_contiguous_range);
USE_LITE_OP(max_pool2d_with_index);
USE_LITE_OP(unstack);
USE_LITE_OP(unsqueeze);
USE_LITE_OP(unsqueeze2);
USE_LITE_OP(affine_grid);
USE_LITE_OP(deformable_conv);
USE_LITE_OP(box_clip);
USE_LITE_OP(shape);
USE_LITE_OP(meshgrid);
USE_LITE_OP(__xpu__softmax_topk);
USE_LITE_OP(sequence_softmax);
USE_LITE_OP(__xpu__mmdnn_search_attention);
USE_LITE_OP(__xpu__mmdnn_search_attention2);
USE_LITE_OP(slice);
USE_LITE_OP(sign);
USE_LITE_OP(instance_norm);
USE_LITE_OP(io_copy_once);
USE_LITE_OP(gather);
USE_LITE_OP(__xpu__embedding_with_eltwise_add);
USE_LITE_OP(inverse);
USE_LITE_OP(__xpu__resnet50);
USE_LITE_OP(unfold);
USE_LITE_OP(search_seq_fc);
USE_LITE_OP(sequence_reverse);
USE_LITE_OP(sparse_conv2d);
USE_LITE_OP(layer_norm);
USE_LITE_OP(read_from_array);
USE_LITE_OP(fake_channel_wise_quantize_dequantize_abs_max);
USE_LITE_OP(search_group_padding);
USE_LITE_OP(select_input);
USE_LITE_OP(affine_channel);
USE_LITE_OP(clip);
USE_LITE_OP(fetch);
USE_LITE_OP(anchor_generator);
USE_LITE_OP(sequence_expand_as);
USE_LITE_OP(lookup_table);
USE_LITE_OP(__xpu__mmdnn_bid_emb_grnn_att);
USE_LITE_OP(__xpu__mmdnn_bid_emb_grnn_att2);
USE_LITE_OP(__xpu__mmdnn_bid_emb_att);
USE_LITE_OP(__xpu__mmdnn_match_conv_topk);
USE_LITE_OP(__xpu__mmdnn_merge_all);
USE_LITE_OP(squeeze);
USE_LITE_OP(squeeze2);
USE_LITE_OP(tile);
USE_LITE_OP(merge_lod_tensor);
USE_LITE_OP(conditional_block);
USE_LITE_OP(logical_xor);
USE_LITE_OP(logical_and);
USE_LITE_OP(logical_or);
USE_LITE_OP(logical_not);
USE_LITE_OP(crop_tensor);
USE_LITE_OP(fake_dequantize_max_abs);
USE_LITE_OP(batch_norm);
USE_LITE_OP(sync_batch_norm);
USE_LITE_OP(gru_unit);
USE_LITE_OP(square);
USE_LITE_OP(relu_clipped);
USE_LITE_OP(swish);
USE_LITE_OP(log);
USE_LITE_OP(exp);
USE_LITE_OP(abs);
USE_LITE_OP(floor);
USE_LITE_OP(hard_sigmoid);
USE_LITE_OP(sqrt);
USE_LITE_OP(rsqrt);
USE_LITE_OP(softsign);
USE_LITE_OP(gelu);
USE_LITE_OP(hard_swish);
USE_LITE_OP(reciprocal);
USE_LITE_OP(mish);
USE_LITE_OP(sigmoid);
USE_LITE_OP(tanh);
USE_LITE_OP(relu);
USE_LITE_OP(leaky_relu);
USE_LITE_OP(relu6);
USE_LITE_OP(prelu);
USE_LITE_OP(thresholded_relu);
USE_LITE_OP(elu);
USE_LITE_OP(erf);
USE_LITE_OP(softplus);

View File

@@ -13,207 +13,108 @@
// limitations under the License.
#pragma once
#include "paddle_lite_factory_helper.h" // NOLINT
USE_MIR_PASS(demo);
USE_MIR_PASS(static_kernel_pick_pass);
USE_MIR_PASS(op_transformation_pass);
USE_MIR_PASS(variable_place_inference_pass);
USE_MIR_PASS(type_target_cast_pass);
USE_MIR_PASS(lite_unsqueeze2_pad3d_squeeze2_fuse_pass);
USE_MIR_PASS(__fpga_kernel_place_correct_pass);
USE_MIR_PASS(opencl_kernel_place_correct_pass);
USE_MIR_PASS(generate_program_pass);
USE_MIR_PASS(io_copy_kernel_pick_pass);
USE_MIR_PASS(argument_type_display_pass);
USE_MIR_PASS(runtime_context_assign_pass);
USE_MIR_PASS(graph_visualize_pass);
USE_MIR_PASS(sparse_conv_detect_pass)
USE_MIR_PASS(adaptive_1x1_pool2d_convert_global_pass);
USE_MIR_PASS(remove_scale1_pass);
USE_MIR_PASS(remove_tf_redundant_ops_pass);
USE_MIR_PASS(lite_conv_bn_fuse_pass);
USE_MIR_PASS(lite_conv_conv_fuse_pass);
USE_MIR_PASS(lite_squeeze2_matmul_fuse_pass);
USE_MIR_PASS(lite_reshape2_matmul_fuse_pass);
USE_MIR_PASS(lite_matmul_fuse_pass);
USE_MIR_PASS(lite_fc_fuse_pass);
USE_MIR_PASS(lite_matmul_element_add_fuse_pass);
USE_MIR_PASS(lite_shuffle_channel_fuse_pass);
USE_MIR_PASS(lite_transpose_softmax_transpose_fuse_pass);
USE_MIR_PASS(lite_interpolate_fuse_pass);
USE_MIR_PASS(lite_sequence_pool_concat_fuse_pass);
USE_MIR_PASS(identity_scale_eliminate_pass);
USE_MIR_PASS(identity_dropout_eliminate_pass);
USE_MIR_PASS(lite_conv_elementwise_fuse_pass);
USE_MIR_PASS(lite_conv_activation_fuse_pass);
USE_MIR_PASS(lite_var_conv_2d_activation_fuse_pass);
USE_MIR_PASS(lite_match_matrix_activation_fuse_pass);
USE_MIR_PASS(lite_scales_fuse_pass);
USE_MIR_PASS(lite_scaleacts_fuse_pass);
USE_MIR_PASS(lite_sequence_reverse_embedding_fuse_pass);
USE_MIR_PASS(lite_elementwise_activation_fuse_pass);
USE_MIR_PASS(lite_elementwise_scale_fuse_pass);
USE_MIR_PASS(lite_conv_scale_fuse_pass);
USE_MIR_PASS(lite_conv_elementwise_tree_fuse_pass);
USE_MIR_PASS(lite_quant_dequant_fuse_pass);
USE_MIR_PASS(type_precision_cast_pass);
USE_MIR_PASS(type_layout_cast_pass);
USE_MIR_PASS(type_layout_cast_preprocess_pass);
USE_MIR_PASS(memory_optimize_pass);
USE_MIR_PASS(xpu_memory_optimize_pass);
USE_MIR_PASS(lite_inplace_fuse_pass);
USE_MIR_PASS(multi_stream_analysis_pass);
USE_MIR_PASS(elementwise_mul_constant_eliminate_pass)
USE_MIR_PASS(npu_subgraph_pass);
USE_MIR_PASS(huawei_ascend_npu_subgraph_pass);
USE_MIR_PASS(imagination_nna_subgraph_pass);
USE_MIR_PASS(nnadapter_subgraph_pass);
USE_MIR_PASS(xpu_subgraph_pass);
USE_MIR_PASS(mlu_subgraph_pass);
USE_MIR_PASS(mlu_postprocess_pass);
USE_MIR_PASS(weight_quantization_preprocess_pass);
USE_MIR_PASS(post_quant_dynamic_pass);
USE_MIR_PASS(fp16_attribute_pass);
USE_MIR_PASS(apu_subgraph_pass);
USE_MIR_PASS(fpga_concat_fuse_pass);
USE_MIR_PASS(quantized_op_attributes_inference_pass);
USE_MIR_PASS(quantization_parameters_propagation_pass);
USE_MIR_PASS(restrict_quantized_op_with_same_input_output_scale_pass);
USE_MIR_PASS(control_flow_op_unused_inputs_and_outputs_eliminate_pass);
USE_MIR_PASS(control_flow_op_shared_inputs_and_outputs_place_sync_pass);
USE_MIR_PASS(lite_scale_activation_fuse_pass);
USE_MIR_PASS(lite_instance_norm_activation_fuse_pass);
USE_MIR_PASS(ssd_boxes_calc_offline_pass);
USE_MIR_PASS(fix_mismatched_precision_pass);
USE_MIR_PASS(lite_flatten_fc_fuse_pass);
USE_MIR_PASS(lite_fc_prelu_fuse_pass);
USE_MIR_PASS(lite_greater_than_cast_fuse_pass);
USE_MIR_PASS(assign_value_calc_offline_pass);
USE_MIR_PASS(__xpu__graph_dedup_pass);
USE_MIR_PASS(__xpu__resnet_fuse_pass);
USE_MIR_PASS(__xpu__resnet_cbam_fuse_pass);
USE_MIR_PASS(__xpu__multi_encoder_fuse_pass);
USE_MIR_PASS(__xpu__embedding_with_eltwise_add_fuse_pass);
USE_MIR_PASS(__xpu__fc_fuse_pass);
USE_MIR_PASS(__xpu__mmdnn_fuse_pass);
USE_MIR_PASS(__xpu__conv2d_affine_channel_fuse_pass);
USE_MIR_PASS(__xpu__conv2d_fuse_pass);
USE_MIR_PASS(__xpu__sfa_head_meanstd_fuse_pass);
USE_MIR_PASS(__xpu__sfa_head_moment_fuse_pass);
USE_MIR_PASS(__xpu__softmax_topk_fuse_pass);
USE_MIR_PASS(__xpu__multi_encoder_adaptive_seqlen_fuse_pass);
USE_MIR_PASS(__xpu__multi_encoder_slice_link_fuse_pass);
USE_MIR_PASS(__xpu__generate_sequence_fuse_pass);
USE_MIR_PASS(__xpu__logit_fuse_pass);
USE_MIR_PASS(__xpu__link_previous_out_max_pass);
USE_MIR_PASS(__xpu__squeeze_excitation_fuse_pass);
USE_MIR_PASS(__xpu__bigru_fuse_pass);
USE_MIR_PASS(__xpu__dynamic_lstm_fuse_pass);
USE_MIR_PASS(__xpu__multi_softmax_fuse_pass);
USE_MIR_PASS(__xpu__max_pooling_pad_zero_detect_fuse_pass);
USE_MIR_PASS(x86_int8_attribute_pass);
USE_MIR_PASS(fill_range_fuse_pass);
USE_MIR_PASS(range_calc_offline_pass);
USE_MIR_PASS(p_norm_fill_constant_max_div_fuse_pass);