Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pegainfer-kernels/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ anyhow = { workspace = true }
cudarc = { workspace = true }
half = { workspace = true }
serde = { workspace = true }
tvm-ffi = { version = "0.1.0-alpha.0", optional = true }

[build-dependencies]
cc = { workspace = true }
Expand All @@ -17,6 +18,7 @@ default = []
deepseek-v4 = []
deepseek-v4-cutedsl-diagnostic = ["deepseek-v4"]
kimi-k2 = []
tvm-ffi-interop = ["dep:tvm-ffi"]

[lints]
workspace = true
30 changes: 30 additions & 0 deletions pegainfer-kernels/tests/fixtures/tvm_ffi_fixture.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <tvm/ffi/function.h>

namespace ffi = tvm::ffi;

int64_t AddOneScalar(int64_t x) { return x + 1; }

int64_t ApplyCallback(ffi::Function callback, int64_t x) {
return callback(x).cast<int64_t>();
}

int64_t CallRegisteredHostAddThree(int64_t x) {
ffi::Function callback =
ffi::Function::GetGlobalRequired("pegainfer.testing.add_three");
return callback(x).cast<int64_t>();
}

int64_t CallRegisteredHostFailIfNegative(int64_t x) {
ffi::Function callback =
ffi::Function::GetGlobalRequired("pegainfer.testing.fail_if_negative");
return callback(x).cast<int64_t>();
}

TVM_FFI_DLL_EXPORT_TYPED_FUNC(add_one_scalar, AddOneScalar);
TVM_FFI_DLL_EXPORT_TYPED_FUNC(apply_callback, ApplyCallback);
TVM_FFI_DLL_EXPORT_TYPED_FUNC(
call_registered_host_add_three,
CallRegisteredHostAddThree);
TVM_FFI_DLL_EXPORT_TYPED_FUNC(
call_registered_host_fail_if_negative,
CallRegisteredHostFailIfNegative);
Loading