| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef NCNN_NET_H |
| | #define NCNN_NET_H |
| |
|
| | #include "blob.h" |
| | #include "layer.h" |
| | #include "mat.h" |
| | #include "option.h" |
| | #include "platform.h" |
| |
|
| | #if NCNN_PLATFORM_API |
| | #if __ANDROID_API__ >= 9 |
| | #include <android/asset_manager.h> |
| | #endif |
| | #endif |
| |
|
| | namespace ncnn { |
| |
|
| | #if NCNN_VULKAN |
| | class VkCompute; |
| | #endif |
| | class DataReader; |
| | class Extractor; |
| | class NetPrivate; |
| | class NCNN_EXPORT Net |
| | { |
| | public: |
| | |
| | Net(); |
| | |
| | virtual ~Net(); |
| |
|
| | public: |
| | |
| | Option opt; |
| |
|
| | #if NCNN_VULKAN |
| | |
| | void set_vulkan_device(int device_index); |
| |
|
| | |
| | void set_vulkan_device(const VulkanDevice* vkdev); |
| |
|
| | const VulkanDevice* vulkan_device() const; |
| | #endif |
| |
|
| | #if NCNN_STRING |
| | |
| | |
| | int register_custom_layer(const char* type, layer_creator_func creator, layer_destroyer_func destroyer = 0, void* userdata = 0); |
| | virtual int custom_layer_to_index(const char* type); |
| | #endif |
| | |
| | |
| | int register_custom_layer(int index, layer_creator_func creator, layer_destroyer_func destroyer = 0, void* userdata = 0); |
| |
|
| | #if NCNN_STRING |
| | int load_param(const DataReader& dr); |
| | #endif |
| |
|
| | int load_param_bin(const DataReader& dr); |
| |
|
| | int load_model(const DataReader& dr); |
| |
|
| | #if NCNN_STDIO |
| | #if NCNN_STRING |
| | |
| | |
| | int load_param(FILE* fp); |
| | int load_param(const char* protopath); |
| | int load_param_mem(const char* mem); |
| | #endif |
| | |
| | |
| | int load_param_bin(FILE* fp); |
| | int load_param_bin(const char* protopath); |
| |
|
| | |
| | |
| | int load_model(FILE* fp); |
| | int load_model(const char* modelpath); |
| | #endif |
| |
|
| | |
| | |
| | |
| | int load_param(const unsigned char* mem); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | int load_model(const unsigned char* mem); |
| |
|
| | #if NCNN_PLATFORM_API |
| | #if __ANDROID_API__ >= 9 |
| | #if NCNN_STRING |
| | |
| | int load_param(AAsset* asset); |
| | int load_param(AAssetManager* mgr, const char* assetpath); |
| | #endif |
| | |
| | int load_param_bin(AAsset* asset); |
| | int load_param_bin(AAssetManager* mgr, const char* assetpath); |
| |
|
| | |
| | int load_model(AAsset* asset); |
| | int load_model(AAssetManager* mgr, const char* assetpath); |
| | #endif |
| | #endif |
| |
|
| | |
| | void clear(); |
| |
|
| | |
| | Extractor create_extractor() const; |
| |
|
| | |
| | const std::vector<int>& input_indexes() const; |
| | const std::vector<int>& output_indexes() const; |
| | #if NCNN_STRING |
| | const std::vector<const char*>& input_names() const; |
| | const std::vector<const char*>& output_names() const; |
| | #endif |
| |
|
| | const std::vector<Blob>& blobs() const; |
| | const std::vector<Layer*>& layers() const; |
| |
|
| | std::vector<Blob>& mutable_blobs(); |
| | std::vector<Layer*>& mutable_layers(); |
| |
|
| | protected: |
| | friend class Extractor; |
| | #if NCNN_STRING |
| | int find_blob_index_by_name(const char* name) const; |
| | int find_layer_index_by_name(const char* name) const; |
| | virtual Layer* create_custom_layer(const char* type); |
| | virtual Layer* create_overwrite_builtin_layer(const char* type); |
| | #endif |
| | virtual Layer* create_custom_layer(int index); |
| | virtual Layer* create_overwrite_builtin_layer(int typeindex); |
| |
|
| | private: |
| | Net(const Net&); |
| | Net& operator=(const Net&); |
| |
|
| | private: |
| | NetPrivate* const d; |
| | }; |
| |
|
| | class ExtractorPrivate; |
| | class NCNN_EXPORT Extractor |
| | { |
| | public: |
| | virtual ~Extractor(); |
| |
|
| | |
| | Extractor(const Extractor&); |
| |
|
| | |
| | Extractor& operator=(const Extractor&); |
| |
|
| | |
| | void clear(); |
| |
|
| | |
| | |
| | |
| | void set_light_mode(bool enable); |
| |
|
| | |
| | |
| | |
| | void set_num_threads(int num_threads); |
| |
|
| | |
| | void set_blob_allocator(Allocator* allocator); |
| |
|
| | |
| | void set_workspace_allocator(Allocator* allocator); |
| |
|
| | #if NCNN_VULKAN |
| | void set_vulkan_compute(bool enable); |
| |
|
| | void set_blob_vkallocator(VkAllocator* allocator); |
| |
|
| | void set_workspace_vkallocator(VkAllocator* allocator); |
| |
|
| | void set_staging_vkallocator(VkAllocator* allocator); |
| | #endif |
| |
|
| | #if NCNN_STRING |
| | |
| | |
| | int input(const char* blob_name, const Mat& in); |
| |
|
| | |
| | |
| | |
| | |
| | int extract(const char* blob_name, Mat& feat, int type = 0); |
| | #endif |
| |
|
| | |
| | |
| | int input(int blob_index, const Mat& in); |
| |
|
| | |
| | |
| | |
| | |
| | int extract(int blob_index, Mat& feat, int type = 0); |
| |
|
| | #if NCNN_VULKAN |
| | #if NCNN_STRING |
| | |
| | |
| | int input(const char* blob_name, const VkMat& in); |
| |
|
| | |
| | |
| | int extract(const char* blob_name, VkMat& feat, VkCompute& cmd); |
| |
|
| | |
| | |
| | int input(const char* blob_name, const VkImageMat& in); |
| |
|
| | |
| | |
| | int extract(const char* blob_name, VkImageMat& feat, VkCompute& cmd); |
| | #endif |
| |
|
| | |
| | |
| | int input(int blob_index, const VkMat& in); |
| |
|
| | |
| | |
| | int extract(int blob_index, VkMat& feat, VkCompute& cmd); |
| |
|
| | |
| | |
| | int input(int blob_index, const VkImageMat& in); |
| |
|
| | |
| | |
| | int extract(int blob_index, VkImageMat& feat, VkCompute& cmd); |
| | #endif |
| |
|
| | protected: |
| | friend Extractor Net::create_extractor() const; |
| | Extractor(const Net* net, size_t blob_count); |
| |
|
| | private: |
| | ExtractorPrivate* const d; |
| | }; |
| |
|
| | } |
| |
|
| | #endif |
| |
|