-
Notifications
You must be signed in to change notification settings - Fork 6
feat: build C API on functional operator API #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
voltjia
wants to merge
3
commits into
master
Choose a base branch
from
feat/operator-c-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,10 @@ | ||
| #ifndef INFINI_C_OPS_H_ | ||
| #define INFINI_C_OPS_H_ | ||
|
|
||
| INFINI_OPS_API InfiniOpsStatus infiniOpsAdd(InfiniOpsHandle handle, | ||
| InfiniOpsConfig config, | ||
| const InfiniOpsTensor* input, | ||
| const InfiniOpsTensor* other, | ||
| InfiniOpsTensor* out); | ||
|
|
||
| #endif // INFINI_C_OPS_H_ |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,8 +1,114 @@ | ||
| #ifndef INFINI_OPS_H_ | ||
| #define INFINI_OPS_H_ | ||
|
|
||
| #include <stddef.h> | ||
| #include <stdint.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| #include <infini/functional_ops.h> | ||
|
|
||
| extern "C" { | ||
| #endif | ||
|
|
||
| #if defined(_WIN32) | ||
| #if defined(INFINI_OPS_BUILD_SHARED) | ||
| #define INFINI_OPS_API __declspec(dllexport) | ||
| #elif defined(INFINI_OPS_USE_SHARED) | ||
| #define INFINI_OPS_API __declspec(dllimport) | ||
| #else | ||
| #define INFINI_OPS_API | ||
| #endif | ||
| #else | ||
| #if defined(INFINI_OPS_BUILD_SHARED) | ||
| #define INFINI_OPS_API __attribute__((visibility("default"))) | ||
| #else | ||
| #define INFINI_OPS_API | ||
| #endif | ||
| #endif | ||
|
|
||
| typedef enum InfiniOpsStatus { | ||
| INFINI_OPS_STATUS_SUCCESS, | ||
| INFINI_OPS_STATUS_INVALID_ARGUMENT, | ||
| INFINI_OPS_STATUS_NOT_SUPPORTED, | ||
| INFINI_OPS_STATUS_OUT_OF_MEMORY, | ||
| INFINI_OPS_STATUS_INTERNAL_ERROR, | ||
| } InfiniOpsStatus; | ||
|
|
||
| typedef enum InfiniOpsDataType { | ||
| INFINI_OPS_DATA_TYPE_INVALID, | ||
| INFINI_OPS_DATA_TYPE_INT8, | ||
| INFINI_OPS_DATA_TYPE_INT16, | ||
| INFINI_OPS_DATA_TYPE_INT32, | ||
| INFINI_OPS_DATA_TYPE_INT64, | ||
| INFINI_OPS_DATA_TYPE_UINT8, | ||
| INFINI_OPS_DATA_TYPE_UINT16, | ||
| INFINI_OPS_DATA_TYPE_UINT32, | ||
| INFINI_OPS_DATA_TYPE_UINT64, | ||
| INFINI_OPS_DATA_TYPE_FLOAT16, | ||
| INFINI_OPS_DATA_TYPE_BFLOAT16, | ||
| INFINI_OPS_DATA_TYPE_FLOAT32, | ||
| INFINI_OPS_DATA_TYPE_FLOAT64, | ||
| } InfiniOpsDataType; | ||
|
|
||
| typedef enum InfiniOpsDeviceType { | ||
| INFINI_OPS_DEVICE_TYPE_INVALID, | ||
| INFINI_OPS_DEVICE_TYPE_CPU, | ||
| INFINI_OPS_DEVICE_TYPE_NVIDIA, | ||
| INFINI_OPS_DEVICE_TYPE_CAMBRICON, | ||
| INFINI_OPS_DEVICE_TYPE_ASCEND, | ||
| INFINI_OPS_DEVICE_TYPE_METAX, | ||
| INFINI_OPS_DEVICE_TYPE_MOORE, | ||
| INFINI_OPS_DEVICE_TYPE_ILUVATAR, | ||
| } InfiniOpsDeviceType; | ||
|
|
||
| typedef struct InfiniOpsTensor { | ||
| size_t structure_size; | ||
| void* data; | ||
| size_t byte_size; | ||
| InfiniOpsDataType data_type; | ||
| InfiniOpsDeviceType device_type; | ||
| int32_t rank; | ||
| const int64_t* shape; | ||
| const int64_t* stride; | ||
| uint64_t reserved[8]; | ||
| } InfiniOpsTensor; | ||
|
|
||
| typedef struct InfiniOpsStreamPrivate* InfiniOpsStream; | ||
| typedef struct InfiniOpsHandlePrivate* InfiniOpsHandle; | ||
| typedef struct InfiniOpsConfigPrivate* InfiniOpsConfig; | ||
|
|
||
| typedef struct InfiniOpsHandleAttributes { | ||
| size_t structure_size; | ||
| InfiniOpsStream stream; | ||
| void* workspace; | ||
| size_t workspace_byte_size; | ||
| uint64_t reserved[8]; | ||
| } InfiniOpsHandleAttributes; | ||
|
|
||
| typedef struct InfiniOpsConfigAttributes { | ||
| size_t structure_size; | ||
| size_t implementation_index; | ||
| uint64_t reserved[8]; | ||
| } InfiniOpsConfigAttributes; | ||
|
|
||
| INFINI_OPS_API InfiniOpsStatus infiniOpsGetLastError(char* buffer, | ||
| size_t capacity, | ||
| size_t* required_size); | ||
|
|
||
| INFINI_OPS_API InfiniOpsStatus infiniOpsCreateHandle( | ||
| const InfiniOpsHandleAttributes* attributes, InfiniOpsHandle* handle); | ||
|
|
||
| INFINI_OPS_API InfiniOpsStatus infiniOpsDestroyHandle(InfiniOpsHandle handle); | ||
|
|
||
| INFINI_OPS_API InfiniOpsStatus infiniOpsCreateConfig( | ||
| const InfiniOpsConfigAttributes* attributes, InfiniOpsConfig* config); | ||
|
|
||
| INFINI_OPS_API InfiniOpsStatus infiniOpsDestroyConfig(InfiniOpsConfig config); | ||
|
|
||
| #include <infini/c_ops.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif // INFINI_OPS_H_ | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.