Skip to content

Commit

Permalink
[C API] Refactor code structure (#1449)
Browse files Browse the repository at this point in the history
* refactor code

* move files

* fix doc

* fix
  • Loading branch information
rainyfly authored Feb 27, 2023
1 parent 48f776b commit 266ae04
Show file tree
Hide file tree
Showing 34 changed files with 158 additions and 132 deletions.
2 changes: 1 addition & 1 deletion c_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(NOT WITH_CAPI)
return()
endif()

configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/config.h)
configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/core/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/core/config.h)
file(GLOB_RECURSE DEPLOY_CAPI_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/*.cc)
if(NOT ENABLE_VISION)
file(GLOB_RECURSE DEPLOY_VISION_CAPI_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/c_api/fastdeploy_capi/vision/*.cc)
Expand Down
22 changes: 22 additions & 0 deletions c_api/fastdeploy_capi/core/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#ifndef ENABLE_VISION
#define ENABLE_VISION
#endif

#ifndef ENABLE_TEXT
#define ENABLE_TEXT
#endif
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_type.h"

#include <opencv2/imgcodecs.hpp>

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/core/fd_common.h"

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <stdint.h>
#include <stdio.h>

#include "fastdeploy_capi/enum_variables.h"
#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/runtime/enum_variables.h"
#include "fastdeploy_capi/core/fd_common.h"

typedef struct FD_C_OneDimArrayUint8 {
size_t size;
Expand Down
71 changes: 0 additions & 71 deletions c_api/fastdeploy_capi/enum_variables.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"

namespace fastdeploy {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma once

#include "fastdeploy/runtime/runtime_option.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_type.h"
#include <memory>

#ifdef ENABLE_VISION
Expand Down
71 changes: 71 additions & 0 deletions c_api/fastdeploy_capi/runtime/enum_variables.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#define FD_ENUM(type) \
typedef int32_t type; \
enum

FD_ENUM(FD_C_ModelFormat){
FD_C_ModelFormat_AUTOREC, ///< Auto recognize the model format by model file name
FD_C_ModelFormat_PADDLE, ///< Model with paddlepaddle format
FD_C_ModelFormat_ONNX, ///< Model with ONNX format
FD_C_ModelFormat_RKNN, ///< Model with RKNN format
FD_C_ModelFormat_TORCHSCRIPT, ///< Model with TorchScript format
FD_C_ModelFormat_SOPHGO, ///< Model with SOPHGO format
};

FD_ENUM(FD_C_rknpu2_CpuName){
FD_C_ModelFormat_RK356X = 0, /* run on RK356X. */
FD_C_ModelFormat_RK3588 = 1, /* default,run on RK3588. */
FD_C_ModelFormat_UNDEFINED,
};

FD_ENUM(FD_C_rknpu2_CoreMask){
FD_C_ModelFormat_RKNN_NPU_CORE_AUTO = 0, //< default, run on NPU core randomly.
FD_C_ModelFormat_RKNN_NPU_CORE_0 = 1, //< run on NPU core 0.
FD_C_ModelFormat_RKNN_NPU_CORE_1 = 2, //< run on NPU core 1.
FD_C_ModelFormat_RKNN_NPU_CORE_2 = 4, //< run on NPU core 2.
FD_C_ModelFormat_RKNN_NPU_CORE_0_1 = FD_C_ModelFormat_RKNN_NPU_CORE_0 |
FD_C_ModelFormat_RKNN_NPU_CORE_1, //< run on NPU core 1 and core 2.
FD_C_ModelFormat_RKNN_NPU_CORE_0_1_2 = FD_C_ModelFormat_RKNN_NPU_CORE_0_1 |
FD_C_ModelFormat_RKNN_NPU_CORE_2, //< run on NPU core 1 and core 2.
FD_C_ModelFormat_RKNN_NPU_CORE_UNDEFINED,
};

FD_ENUM(FD_C_LitePowerMode){
FD_C_ModelFormat_LITE_POWER_HIGH = 0, ///< Use Lite Backend with high power mode
FD_C_ModelFormat_LITE_POWER_LOW = 1, ///< Use Lite Backend with low power mode
FD_C_ModelFormat_LITE_POWER_FULL = 2, ///< Use Lite Backend with full power mode
FD_C_ModelFormat_LITE_POWER_NO_BIND = 3, ///< Use Lite Backend with no bind power mode
FD_C_ModelFormat_LITE_POWER_RAND_HIGH = 4, ///< Use Lite Backend with rand high mode
FD_C_ModelFormat_LITE_POWER_RAND_LOW = 5 ///< Use Lite Backend with rand low power mode
};

FD_ENUM(FD_C_ResultType){
FD_C_ModelFormat_UNKNOWN_RESULT,
FD_C_ModelFormat_CLASSIFY,
FD_C_ModelFormat_DETECTION,
FD_C_ModelFormat_SEGMENTATION,
FD_C_ModelFormat_OCR,
FD_C_ModelFormat_MOT,
FD_C_ModelFormat_FACE_DETECTION,
FD_C_ModelFormat_FACE_ALIGNMENT,
FD_C_ModelFormat_FACE_RECOGNITION,
FD_C_ModelFormat_MATTING,
FD_C_ModelFormat_MASK,
FD_C_ModelFormat_KEYPOINT_DETECTION,
FD_C_ModelFormat_HEADPOSE,
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/runtime/runtime_option.h"

#include "fastdeploy/utils/utils.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_type.h"

typedef struct FD_C_RuntimeOptionWrapper FD_C_RuntimeOptionWrapper;

Expand Down
6 changes: 3 additions & 3 deletions c_api/fastdeploy_capi/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
#pragma once

#include "fastdeploy_capi/config.h"
#include "fastdeploy_capi/core/config.h"

#ifdef ENABLE_VISION
#include "fastdeploy_capi/vision/classification/ppcls/model.h"
Expand All @@ -24,5 +24,5 @@
#include "fastdeploy_capi/vision/visualize.h"
#endif

#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
2 changes: 1 addition & 1 deletion c_api/fastdeploy_capi/vision/classification/ppcls/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "fastdeploy_capi/vision/classification/ppcls/model.h"

#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions c_api/fastdeploy_capi/vision/classification/ppcls/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#pragma once

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"

typedef struct FD_C_PaddleClasModelWrapper FD_C_PaddleClasModelWrapper;
Expand Down
2 changes: 1 addition & 1 deletion c_api/fastdeploy_capi/vision/detection/ppdet/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "fastdeploy_capi/vision/detection/ppdet/model.h"

#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#include "fastdeploy_capi/vision/visualize.h"

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions c_api/fastdeploy_capi/vision/detection/ppdet/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#pragma once

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"
#include "fastdeploy_capi/vision/detection/ppdet/base_define.h"

Expand Down
2 changes: 1 addition & 1 deletion c_api/fastdeploy_capi/vision/ocr/ppocr/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "fastdeploy_capi/vision/ocr/ppocr/model.h"

#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"
#include "fastdeploy_capi/vision/visualize.h"

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions c_api/fastdeploy_capi/vision/ocr/ppocr/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#pragma once

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"
#include "fastdeploy_capi/vision/ocr/ppocr/base_define.h"

Expand Down
2 changes: 1 addition & 1 deletion c_api/fastdeploy_capi/vision/result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "fastdeploy_capi/vision/result.h"

#include "fastdeploy/utils/utils.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions c_api/fastdeploy_capi/vision/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#pragma once

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"

typedef struct FD_C_ClassifyResultWrapper FD_C_ClassifyResultWrapper;
typedef struct FD_C_DetectionResultWrapper FD_C_DetectionResultWrapper;
Expand Down
2 changes: 1 addition & 1 deletion c_api/fastdeploy_capi/vision/segmentation/ppseg/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "fastdeploy_capi/vision/segmentation/ppseg/model.h"

#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions c_api/fastdeploy_capi/vision/segmentation/ppseg/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#pragma once

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/runtime_option.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/runtime/runtime_option.h"
#include "fastdeploy_capi/vision/result.h"

typedef struct FD_C_PaddleSegModelWrapper FD_C_PaddleSegModelWrapper;
Expand Down
2 changes: 1 addition & 1 deletion c_api/fastdeploy_capi/vision/visualize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "fastdeploy_capi/vision/visualize.h"

#include "fastdeploy/vision/visualize/visualize.h"
#include "fastdeploy_capi/types_internal.h"
#include "fastdeploy_capi/internal/types_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions c_api/fastdeploy_capi/vision/visualize.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#pragma once

#include "fastdeploy_capi/fd_common.h"
#include "fastdeploy_capi/fd_type.h"
#include "fastdeploy_capi/core/fd_common.h"
#include "fastdeploy_capi/core/fd_type.h"
#include "fastdeploy_capi/vision/result.h"

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 266ae04

Please sign in to comment.