サンプル
onnxruntime 1.28.0: IOBinding
検証済みサンプル — pypi onnxruntime 1.28.0: IOBinding. python 3.12 · linux debian/x64 · docker で contract を実行し、成功しました: assert InferenceSession.io_binding and…
sha256:b3e844654a2e5fedc3043e034200e912288369eec76237d9f979173a5cef819b
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 pip
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-07 |
ケース
HOW- ゴール
- verify onnxruntime.IOBinding in pkg:pypi/onnxruntime@1.28.0
- パッケージ
- シンボル
-
- onnxruntime.IOBinding
- 作成日
- 2026-09-07T04:49:35Z
コントラクト
- assert InferenceSession.io_binding and ort.IOBinding create valid IOBinding instances bound to the session
- assert IOBinding.bind_cpu_input binds NumPy arrays to named model inputs
- assert IOBinding.bind_output and copy_outputs_to_cpu retrieve model execution results as NumPy arrays
- assert IOBinding.bind_output supports pre-allocated output buffer using buffer_ptr
- assert IOBinding.get_outputs returns OrtValue instances matching expected inference results
- assert IOBinding.clear_binding_inputs and clear_binding_outputs reset bindings, and running without required inputs raises an exception
ファイル
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
ソース
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify onnxruntime.IOBinding in pkg:pypi/onnxruntime@1.28.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/onnxruntime@1.28.0
Demonstrate these symbols/APIs:
- onnxruntime.IOBinding
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:efceb74cd051c4d4ae2540dd279a60f36db72e2b2d8a5a7e77d8d279c624cab6","contract":["assert InferenceSession.io_binding and ort.IOBinding create valid IOBinding instances bound to the session","assert IOBinding.bind_cpu_input binds NumPy arrays to named model inputs","assert IOBinding.bind_output and copy_outputs_to_cpu retrieve model execution results as NumPy arrays","assert IOBinding.bind_output supports pre-allocated output buffer using buffer_ptr","assert IOBinding.get_outputs returns OrtValue instances matching expected inference results","assert IOBinding.clear_binding_inputs and clear_binding_outputs reset bindings, and running without required inputs raises an exception"],"goal":"verify onnxruntime.IOBinding in pkg:pypi/onnxruntime@1.28.0","kind":"HOW","packages":["pkg:pypi/onnxruntime@1.28.0"],"schemaVersion":1,"symbols":["onnxruntime.IOBinding"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/onnxruntime@1.28.0"],"schemaVersion":1,"subject":"pkg:pypi/onnxruntime@1.28.0","symbols":["onnxruntime.IOBinding"],"verifierAdapter":"python@1"}
[project]
name = "verify-onnxruntime-iobinding"
version = "0.1.0"
dependencies = [
"onnxruntime==1.28.0",
"numpy==2.2.3",
]
onnxruntime==1.28.0
numpy==2.2.3
{
"schemaVersion": 1,
"goal": "verify onnxruntime.IOBinding in pkg:pypi/onnxruntime@1.28.0",
"kind": "HOW",
"packages": [
"pkg:pypi/onnxruntime@1.28.0"
],
"symbols": [
"onnxruntime.IOBinding"
]
}
import numpy as np
import onnxruntime as ort
MODEL_BYTES = bytes.fromhex(
"080d120a6373782d73616d706c653a540a0e0a01580a0157120159220341646412096164645f"
"67726170685a110a0158120c0a0a080112060a000a0208035a110a0157120c0a0a080112060a"
"000a02080362110a0159120c0a0a080112060a000a02080342040a00100e"
)
def test_io_binding_creation():
session = ort.InferenceSession(MODEL_BYTES, providers=["CPUExecutionProvider"])
io_binding = session.io_binding()
assert io_binding is not None
io_binding_direct = ort.IOBinding(session)
assert io_binding_direct is not None
def test_io_binding_cpu_input_and_output():
session = ort.InferenceSession(MODEL_BYTES, providers=["CPUExecutionProvider"])
io_binding = session.io_binding()
x_val = np.array([[1.0, 2.0, 3.0]], dtype=np.float32)
w_val = np.array([[10.0, 20.0, 30.0]], dtype=np.float32)
io_binding.bind_cpu_input("X", x_val)
io_binding.bind_cpu_input("W", w_val)
io_binding.bind_output("Y")
session.run_with_iobinding(io_binding)
outputs = io_binding.copy_outputs_to_cpu()
assert isinstance(outputs, list) and len(outputs) == 1
np.testing.assert_allclose(outputs[0], np.array([[11.0, 22.0, 33.0]], dtype=np.float32))
def test_io_binding_preallocated_output_buffer():
session = ort.InferenceSession(MODEL_BYTES, providers=["CPUExecutionProvider"])
io_binding = session.io_binding()
x_val = np.array([[3.0, 5.0, 7.0]], dtype=np.float32)
w_val = np.array([[2.0, 4.0, 6.0]], dtype=np.float32)
y_out = np.zeros((1, 3), dtype=np.float32)
io_binding.bind_cpu_input("X", x_val)
io_binding.bind_cpu_input("W", w_val)
io_binding.bind_output(
name="Y",
device_type="cpu",
device_id=0,
element_type=np.float32,
shape=y_out.shape,
buffer_ptr=y_out.ctypes.data,
)
session.run_with_iobinding(io_binding)
np.testing.assert_allclose(y_out, np.array([[5.0, 9.0, 13.0]], dtype=np.float32))
def test_io_binding_get_outputs_ortvalue():
session = ort.InferenceSession(MODEL_BYTES, providers=["CPUExecutionProvider"])
io_binding = session.io_binding()
x_val = np.array([[4.0, 5.0, 6.0]], dtype=np.float32)
w_val = np.array([[1.0, 1.0, 1.0]], dtype=np.float32)
io_binding.bind_cpu_input("X", x_val)
io_binding.bind_cpu_input("W", w_val)
io_binding.bind_output("Y")
session.run_with_iobinding(io_binding)
ort_outputs = io_binding.get_outputs()
assert len(ort_outputs) == 1
np.testing.assert_allclose(ort_outputs[0].numpy(), np.array([[5.0, 6.0, 7.0]], dtype=np.float32))
def test_io_binding_clear_and_missing_inputs_raise():
session = ort.InferenceSession(MODEL_BYTES, providers=["CPUExecutionProvider"])
io_binding = session.io_binding()
x_val = np.array([[1.0, 2.0, 3.0]], dtype=np.float32)
io_binding.bind_cpu_input("X", x_val)
io_binding.bind_output("Y")
try:
session.run_with_iobinding(io_binding)
assert False, "run_with_iobinding should have raised when required input W was not bound"
except Exception as exc:
assert isinstance(exc, Exception)
io_binding.clear_binding_inputs()
io_binding.clear_binding_outputs()
def main():
test_io_binding_creation()
test_io_binding_cpu_input_and_output()
test_io_binding_preallocated_output_buffer()
test_io_binding_get_outputs_ortvalue()
test_io_binding_clear_and_missing_inputs_raise()
print("All onnxruntime.IOBinding contract assertions passed.")
if __name__ == "__main__":
main()
オリジンシーダー
匿名