Module ffi

Module ffi 

Source
Expand description

FFI (Foreign Function Interface) bindings for tensorlogic-cli

This module provides C-compatible bindings for the tensorlogic-cli library, enabling integration with C/C++ projects and other languages via FFI.

§Memory Management

  • All functions that return owned strings use CString and must be freed with tl_free_string
  • All error messages are allocated and must be freed with tl_free_string
  • Graph results are allocated and must be freed with tl_free_graph_result

§Example (C)

// Compile an expression
TLGraphResult* result = tl_compile_expr("friend(alice, bob)", "soft_differentiable");
if (result->error_message != NULL) {
    fprintf(stderr, "Error: %s\n", result->error_message);
    tl_free_graph_result(result);
    return 1;
}

printf("Graph: %s\n", result->graph_data);
tl_free_graph_result(result);

Structs§

TLBenchmarkResult
FFI-compatible benchmark results
TLExecutionResult
FFI-compatible result type for execution
TLGraphResult
FFI-compatible result type for graph compilation
TLOptimizationResult
FFI-compatible result type for optimization

Functions§

tl_benchmark_compilation
Benchmark compilation of an expression
tl_compile_expr
Compile a logical expression to a tensor graph
tl_execute_graph
Execute a compiled graph
tl_free_benchmark_result
Free a benchmark result
tl_free_execution_result
Free an execution result
tl_free_graph_result
Free a graph result
tl_free_optimization_result
Free an optimization result
tl_free_string
Free a string allocated by tensorlogic
tl_is_backend_available
Check if a backend is available
tl_optimize_graph
Optimize a compiled graph
tl_version
Get the version string