onnxruntime-bnlang
ONNX Runtime-এর জন্য Bnlang বাইন্ডিং।
এটি একটি বেসরকারি তৃতীয় পক্ষীয় বাইন্ডিং। Microsoft-এর সাথে সম্পর্কিত নয়। অফিসিয়াল ORT prebuilt রিলিজ ব্যবহার করে।
Read this in English — README.en.md
দ্রুত শুরু
import "onnxruntime-bnlang" as ort;
লিখুন(ort.সংস্করণ);
লিখুন(ort.প্রদানকারী());
ধরি সেশন = ort.অনুমান_সেশন.খুলুন("model.onnx", { log_severity_level: 3 });
ধরি তথ্য = সেশন.তথ্য();
ধরি আউট = সেশন.চালান({
"input_ids": { dtype: "int64", shape: [1, 16], data: [...] },
"attention_mask": { dtype: "int64", shape: [1, 16], data: [...] }
});
// আউট["logits"] হলো { dtype, shape, handle } — টেনসর_ডেটা দিয়ে materialize:
ধরি লজিটস = ort.টেনসর_ডেটা(আউট["logits"]["handle"]);
ort.টেনসর_বন্ধ_করুন(আউট["logits"]["handle"]);
সেশন.বন্ধ_করুন();Export-গুলো
| নাম | ধরন |
|---|---|
সংস্করণ |
string |
প্রদানকারী() |
function → list |
সেশন_খুলুন(path, options) |
function → handle |
সেশন_বন্ধ_করুন(handle) |
function |
সেশন_তথ্য(handle) |
function → map |
সেশন_চালান(handle, feeds) |
function → outputs map |
টেনসর_ডেটা(handle) |
function → list |
টেনসর_বন্ধ_করুন(handle) |
function |
অনুমান_সেশন.খুলুন(path, options) |
factory → session object |
সেশন.তথ্য() / সেশন.চালান(feeds) / সেশন.বন্ধ_করুন() |
session-instance method |
অবস্থা (v1.0.0)
যা কাজ করে:
- Session lifecycle: খুলুন / তথ্য / চালান / বন্ধ_করুন
- Tensor dtype: float32, float64, float16, int64, int32, uint8, bool
- Session options:
log_severity_level,intra_op_num_threads,inter_op_num_threads,execution_providers - Tensor handle table (downstream LLM loop-এর জন্য zero-copy KV-cache reuse)
পরবর্তী:
- আরও execution provider (CUDA, CoreML)
- Fetch-list filtering (কোন output গুলো compute হবে সেটা বেছে নেওয়া)
- Profiling + IO binding
লোকাল বিল্ড
# Windows
bnl script/install.bnl # deps/windows-x64/ এ ORT prebuilt নামায়
.\build.ps1 # cmake configure + build -> build/windows-x64/*.dll# macOS / Linux
bnl script/install.bnl
./build.shক্রস-প্ল্যাটফর্ম
প্রতি platform-এ আলাদাভাবে build হয়; বাইন্ডিং রানটাইম import-এর সময় bnl.json-এর targets ম্যাপ থেকে সঠিক artifact বাছে। সমর্থিত triple:
| Triple | বিল্ড artifact |
|---|---|
windows-x64 |
build/windows-x64/onnxruntime-bnlang.dll |
linux-x64 |
build/linux-x64/onnxruntime-bnlang.so |
darwin-arm64 |
build/darwin-arm64/onnxruntime-bnlang.dylib |
darwin-x64 |
build/darwin-x64/onnxruntime-bnlang.dylib |
bnl core-এর LOAD_WITH_ALTERED_SEARCH_PATH plugin-এর নিজস্ব directory আগে খোঁজে, System32 / PATH-এর আগে।
লেআউট
bnl.json manifest (main + targets ম্যাপ)
CMakeLists.txt build config
CMakePresets.json প্রতি platform-এ একটি preset
lib/
index.bnl public API (ইংরেজি + বাংলা re-export)
session.bnl InferenceSession / অনুমান_সেশন
src/ C++ source (publish-এ আসে না)
bnl/plugin.h C ABI
main.cpp bnl_load entry
session.{h,cpp} Ort::Session handle table
tensor.{h,cpp} bnl_value <-> Ort::Value + handle table
session_options.{h,cpp}
deps/<triple>/ ORT prebuilt (gitignored; install দ্বারা populate হয়)
build/<triple>/ cmake output (gitignored)
script/
install.bnl ORT prebuilt fetch + verify + extract
install-metadata.bnl প্রতি platform-এ URL + sha256
build.bnl cmake-এর পাতলা wrapperলাইসেন্স
MIT. ORT prebuilt গুলো Microsoft-এর MIT লাইসেন্সে। তৃতীয় পক্ষীয় attribution NOTICES.md-এ আছে।
onnxruntime-bnlang
Bnlang binding for ONNX Runtime.
Unofficial third-party binding. Not affiliated with Microsoft. Consumes official ORT prebuilt releases.
এই README-এর বাংলা সংস্করণ — README.md
Quick start
import "onnxruntime-bnlang" as ort;
print(ort.version);
print(ort.providers());
var sess = ort.InferenceSession.open("model.onnx", { log_severity_level: 3 });
var info = sess.info();
var out = sess.run({
"input_ids": { dtype: "int64", shape: [1, 16], data: [...] },
"attention_mask": { dtype: "int64", shape: [1, 16], data: [...] }
});
// out["logits"] is { dtype, shape, handle } — materialize with tensor_to_data:
var logits = ort.tensor_to_data(out["logits"]["handle"]);
ort.tensor_close(out["logits"]["handle"]);
sess.close();Exports
| Name | Kind |
|---|---|
version |
string |
providers() |
function → list |
session_open(path, options) |
function → handle |
session_close(handle) |
function |
session_info(handle) |
function → map |
session_run(handle, feeds) |
function → outputs map |
tensor_to_data(handle) |
function → list |
tensor_close(handle) |
function |
InferenceSession.open(path, options) |
factory → session object |
sess.info() / sess.run(feeds) / sess.close() |
session-instance methods |
Status (v1.0.0)
Working:
- Session lifecycle: open / info / run / close
- Tensor dtypes: float32, float64, float16, int64, int32, uint8, bool
- Session options:
log_severity_level,intra_op_num_threads,inter_op_num_threads,execution_providers - Tensor handle table (zero-copy KV-cache reuse for downstream LLM loops)
Coming next:
- More execution providers (CUDA, CoreML)
- Fetch-list filtering (pick which outputs to compute)
- Profiling + IO binding
Build (local)
# Windows
bnl script/install.bnl # download ORT prebuilt into deps/windows-x64/
.\build.ps1 # cmake configure + build -> build/windows-x64/*.dll# macOS / Linux
bnl script/install.bnl
./build.shCross-platform packaging
Built per platform; the bnl runtime picks the right artifact from bnl.json's targets map at import time:
| Triple | Build artifact |
|---|---|
windows-x64 |
build/windows-x64/onnxruntime-bnlang.dll |
linux-x64 |
build/linux-x64/onnxruntime-bnlang.so |
darwin-arm64 |
build/darwin-arm64/onnxruntime-bnlang.dylib |
darwin-x64 |
build/darwin-x64/onnxruntime-bnlang.dylib |
LOAD_WITH_ALTERED_SEARCH_PATH in bnl core ensures the plugin's own directory is searched first for its dependencies, ahead of System32 / PATH.
Layout
bnl.json manifest (main + targets map)
CMakeLists.txt build config
CMakePresets.json one preset per platform
lib/
index.bnl public API (English + Bangla re-exports)
session.bnl InferenceSession + session-instance methods
src/ C++ binding (excluded from published tarball)
bnl/plugin.h C ABI contract
main.cpp bnl_load entry
session.{h,cpp} Ort::Session handle table
tensor.{h,cpp} bnl_value <-> Ort::Value + handle table
session_options.{h,cpp}
deps/<triple>/ ORT prebuilt (gitignored; install populates)
build/<triple>/ cmake output (gitignored)
script/
install.bnl download + verify + extract ORT prebuilt
install-metadata.bnl URLs + sha256 per platform
build.bnl thin wrapper around `cmake --preset`License
MIT. ORT prebuilts are MIT-licensed by Microsoft. See NOTICES.md for third-party attribution.
MIT License
Copyright (c) 2026 Bnlang | Mamun
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to furnish persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Third-party notices — onnxruntime-bnlang
This package's binary plugin dynamically links to and consumes prebuilt
binaries from the projects below. They are downloaded at install time by
script/install.bnl from their official distribution channels (NuGet,
GitHub Releases) and remain governed by their original licenses.
ONNX Runtime
- Project: Microsoft ONNX Runtime
- Upstream: https://github.com/microsoft/onnxruntime
- License: MIT
- Copyright: Copyright (c) Microsoft Corporation
Used as the inference engine. We download Microsoft's prebuilt
onnxruntime.dll / onnxruntime_providers_shared.dll at install time and
dynamically link to it from our plugin. We do not redistribute the ORT
binaries; users fetch them from Microsoft's official packages.
The full MIT license text is available at https://github.com/microsoft/onnxruntime/blob/main/LICENSE
DirectML
- Project: DirectML
- Upstream: part of Microsoft Windows (since Windows 10 1903)
- License: Microsoft Software License Terms (Windows component)
DirectML.dll is shipped with Windows itself and is not redistributed by
this package. It is loaded from the system when execution_providers
includes "DML".