Open vadimkantorov opened 3 weeks ago
If anyone's searching, this seems to work to produce C-API bindings with CppSharp (https://github.com/vadimkantorov/tritonservercppsharp/blob/master/.github/workflows/tritonservercppsharp.yml and generated bindings at https://github.com/vadimkantorov/tritonservercppsharp/releases/tag/release)
So if anyone cares to try to actually test these generated bindings, maybe it would work.
name: tritonservercppsharp
on: workflow_dispatch
env:
PLATFORM: x64
FRAMEWORK: net80
jobs:
tritonservercppsharp:
runs-on: ubuntu-22.04
steps:
- name: Clone and build CppSharp
run: |
git clone --single-branch --depth 1 https://github.com/mono/CppSharp
cd CppSharp
bash build/build.sh generate -configuration Release -platform $PLATFORM -target-framework $FRAMEWORK
bash build/build.sh download_llvm -platform $PLATFORM -target-framework $FRAMEWORK
bash build/build.sh restore -platform $PLATFORM -target-framework $FRAMEWORK
bash build/build.sh -platform $PLATFORM -build_only -target-framework $FRAMEWORK
- name: Generating bindings with CppSharp
run: |
git clone --single-branch --depth 1 --branch r24.08 https://github.com/triton-inference-server/core
./CppSharp/bin/Release_x64/CppSharp.CLI -m tritonserver -g csharp -p linux -a x64 -o ./output/ -I=core/include core/include/triton/core/tritonserver.h core/include/triton/core/tritonbackend.h core/include/triton/core/tritoncache.h core/include/triton/core/tritonrepoagent.h
- uses: actions/upload-artifact@v4
with:
path: output/
Generating C++ wrapper bindings seems to fail because CppSharp doesn't seem to support std::shared_ptr<T>
yet: https://github.com/mono/CppSharp/blob/main/docs/UsersManual.md#standard-library-support. Maybe if shared_ptr
is replaced by native pointer or value type, CppSharp would work here
In https://github.com/mono/CppSharp/issues/1860#issuecomment-2322838240 is claimed that using shared_ptr
in C++ API are not ABI-portable. Not sure what it implies for tritonserver, but maybe if the C++ wrapper is considered for simplifying / binding, it would be better to model them without public usage of std::shared_ptr
...
This seems to succeed:
name: tritonservercppsharp
on: workflow_dispatch
env:
PLATFORM: x64
FRAMEWORK: net80
FRAMEWORKDOT: net8.0
jobs:
tritonservercppsharp:
runs-on: ubuntu-22.04
steps:
- name: Clone and build CppSharp
run: |
git clone --single-branch --depth 1 https://github.com/mono/CppSharp
cd CppSharp
bash build/build.sh generate -configuration Release -platform $PLATFORM -target-framework $FRAMEWORK
bash build/build.sh download_llvm -platform $PLATFORM -target-framework $FRAMEWORK
bash build/build.sh restore -platform $PLATFORM -target-framework $FRAMEWORK
bash build/build.sh -platform $PLATFORM -build_only -target-framework $FRAMEWORK
- name: Clone tritonserver
run: |
git clone --single-branch --depth 1 --branch r24.08 https://github.com/triton-inference-server/core
git clone --single-branch --depth 1 --branch r24.08 https://github.com/triton-inference-server/developer_tools
- name: Generate bindings oftritonserver
run: |
./CppSharp/bin/Release_x64/CppSharp.CLI -m tritonserver -g csharp -p linux -a x64 -o ./variant1/ -I=core/include core/include/triton/core/tritonserver.h core/include/triton/core/tritonbackend.h core/include/triton/core/tritoncache.h core/include/triton/core/tritonrepoagent.h
./CppSharp/bin/Release_x64/CppSharp.CLI -m tritondevelopertoolsserver -g csharp -p linux -a x64 -o ./variant3/ -I=developer_tools/server/include -I=core/include -I=developer_tools/server/include/triton/developer_tools developer_tools/server/include/triton/developer_tools/server_wrapper.h developer_tools/server/include/triton/developer_tools/generic_server_wrapper.h
There exist relatively stable and supported tools for generating such bindings e.g. https://github.com/mono/CppSharp.
At least for the C-API it should run without problems similar to Javacpp generated bindings: https://github.com/bytedeco/javacpp-presets/blob/master/tritonserver/src/gen/java/org/bytedeco/tritonserver/global/tritonserver.java / https://github.com/bytedeco/javacpp-presets/tree/master/tritonserver/src/gen/java/org/bytedeco/tritonserver/tritonserver.