tensogram-ffi
C FFI bindings for Tensogram.
Building this crate produces libtensogram_ffi.{so,dylib,a} and a
generated tensogram.h header (via cbindgen) for use from C, C++,
and any language with a C foreign-function interface.
All public functions are prefixed tgm_. Opaque handles are
returned by tgm_* constructors and released by the matching
tgm_*_free function.
Usage (C)
const char* meta_json =
"{\"version\": 3, \"descriptors\": [{"
"\"type\": \"ntensor\", \"ndim\": 2, \"shape\": [100, 200], "
"\"strides\": [200, 1], \"dtype\": \"float32\", "
"\"byte_order\": \"little\", \"encoding\": \"none\", "
"\"filter\": \"none\", \"compression\": \"none\"}]}";
const uint8_t* ptrs = ;
const size_t lens = ;
TgmBytes out;
TgmError err = ;
if
// Use out.data / out.len ...
;
A thread-local error string is available via tgm_last_error()
after any tgm_* call returns non-TGM_OK.
Building
Output:
target/release/libtensogram_ffi.{a,so,dylib}— the librarycpp/include/tensogram.h— the generated C header
Installation
Documentation
- Full documentation: https://sites.ecmwf.int/docs/tensogram/main/
- Repository: https://github.com/ecmwf/tensogram
License
Copyright 2026- European Centre for Medium-Range Weather Forecasts (ECMWF).
Licensed under the Apache License, Version 2.0. See LICENSE for details.