-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more rules based on my thinking.
- Loading branch information
Showing
2 changed files
with
114 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
In Matrix_API.h | ||
|
||
```c | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
// always add this guard for C++ include | ||
extern "C" { | ||
#endif | ||
|
||
typedef void* Paddle_C_MatrixPtr; | ||
|
||
typedef struct tagPaddle_C_Matrix_API { | ||
void (*zero) (Paddle_C_MatrixPtr* self); | ||
void (*assign) (Paddle_C_MatrixPtr* self, float value); | ||
} Paddle_C_Matrix_API; | ||
|
||
extern Paddle_C_Matrix_API paddle_c_getMatrixAPI(); | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
``` | ||
In Matrix_API.cpp | ||
|
||
```cpp | ||
#include "Matrix_API.h" | ||
|
||
extern "C" { | ||
static void zero_impl...; | ||
|
||
Paddle_C_Matrix_API paddle_c_getMatrixAPI() { | ||
Paddle_C_Matrix_API api; | ||
api.zero = zero_impl; | ||
api.assign = assign_impl; | ||
return api; | ||
} | ||
} | ||
|
||
``` |