Beispiel
onnxruntime 1.28.0: OrtValue
Verifiziertes Beispiel für pypi onnxruntime 1.28.0: OrtValue. Der Vertrag lief auf python 3.12 · linux debian/x64 · docker und bestand.
sha256:4932484bb0f902eed191a61a97518dc88318a0523af59bfcf6e5adb02d442f6e
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip 24
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify onnxruntime.OrtValue in pkg:pypi/onnxruntime@1.28.0
- Pakete
- Symbole
-
- onnxruntime.OrtValue
- Umgebung
- python 3.12
- Erstellt
- 2026-09-07T04:16:18Z
Contract
- OrtValue.ortvalue_from_numpy wraps NumPy array into tensor OrtValue preserving shape, dtype, and device
- OrtValue.numpy extracts underlying NumPy array matching original array data and type
- OrtValue.data_type identifies tensor element types including float, double, int32, int64, and bool
- OrtValue.ortvalue_from_shape_and_type allocates uninitialized tensor buffer of specified shape and element type
- IOBinding.bind_ortvalue_input binds OrtValue instances directly to session graph inputs
- IOBinding.get_outputs returns OrtValue instances containing model execution results
Dateien
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
Quelltext
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.OrtValue 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.OrtValue
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:bd04b4fa95f734239cb0344b4d4ea60bab3c56ea1a7f4730675046ae7c9faf28","constraints":{"executionContext":"python"},"contract":["OrtValue.ortvalue_from_numpy wraps NumPy array into tensor OrtValue preserving shape, dtype, and device","OrtValue.numpy extracts underlying NumPy array matching original array data and type","OrtValue.data_type identifies tensor element types including float, double, int32, int64, and bool","OrtValue.ortvalue_from_shape_and_type allocates uninitialized tensor buffer of specified shape and element type","IOBinding.bind_ortvalue_input binds OrtValue instances directly to session graph inputs","IOBinding.get_outputs returns OrtValue instances containing model execution results"],"goal":"verify onnxruntime.OrtValue in pkg:pypi/onnxruntime@1.28.0","kind":"HOW","packages":["pkg:pypi/onnxruntime@1.28.0"],"schemaVersion":1,"symbols":["onnxruntime.OrtValue"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/onnxruntime@1.28.0"],"schemaVersion":1,"subject":"pkg:pypi/onnxruntime@1.28.0","symbols":["onnxruntime.OrtValue"],"verifierAdapter":"python@1"}
[project]
name = "verify-onnxruntime-ortvalue"
version = "0.1.0"
dependencies = [
"flatbuffers==25.12.19",
"numpy==2.5.2",
"onnxruntime==1.28.0",
"packaging==26.3",
"protobuf==7.36.0",
]
flatbuffers==25.12.19
numpy==2.5.2
onnxruntime==1.28.0
packaging==26.3
protobuf==7.36.0
{
"schemaVersion": 1,
"goal": "verify onnxruntime.OrtValue in pkg:pypi/onnxruntime@1.28.0",
"kind": "HOW",
"packages": [
"pkg:pypi/onnxruntime@1.28.0"
],
"symbols": [
"onnxruntime.OrtValue"
]
}
import numpy as np
import onnxruntime as ort
# A minimal, valid 106-byte Add model (Y = X + W) with shape [?, 3] float32
MODEL_BYTES = bytes.fromhex(
"080d120a6373782d73616d706c653a540a0e0a01580a0157120159220341646412096164645f"
"67726170685a110a0158120c0a0a080112060a000a0208035a110a0157120c0a0a080112060a"
"000a02080362110a0159120c0a0a080112060a000a02080342040a00100e"
)
def test_ortvalue_from_numpy():
arr = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], dtype=np.float32)
ort_val = ort.OrtValue.ortvalue_from_numpy(arr)
assert ort_val.is_tensor() is True
assert ort_val.shape() == [2, 3]
assert ort_val.data_type() == "tensor(float)"
assert ort_val.device_name().lower() == "cpu"
np.testing.assert_allclose(ort_val.numpy(), arr)
def test_ortvalue_data_types():
# int64
arr_i64 = np.array([10, 20, 30], dtype=np.int64)
ort_i64 = ort.OrtValue.ortvalue_from_numpy(arr_i64)
assert ort_i64.data_type() == "tensor(int64)"
assert ort_i64.shape() == [3]
np.testing.assert_array_equal(ort_i64.numpy(), arr_i64)
# int32
arr_i32 = np.array([[1, 2], [3, 4]], dtype=np.int32)
ort_i32 = ort.OrtValue.ortvalue_from_numpy(arr_i32)
assert ort_i32.data_type() == "tensor(int32)"
assert ort_i32.shape() == [2, 2]
np.testing.assert_array_equal(ort_i32.numpy(), arr_i32)
# bool
arr_bool = np.array([True, False, True], dtype=bool)
ort_bool = ort.OrtValue.ortvalue_from_numpy(arr_bool)
assert ort_bool.data_type() == "tensor(bool)"
np.testing.assert_array_equal(ort_bool.numpy(), arr_bool)
# float64
arr_f64 = np.array([1.5, 2.5, 3.5], dtype=np.float64)
ort_f64 = ort.OrtValue.ortvalue_from_numpy(arr_f64)
assert ort_f64.data_type() == "tensor(double)"
np.testing.assert_allclose(ort_f64.numpy(), arr_f64)
def test_ortvalue_from_shape_and_type():
shape = [3, 4]
ort_val = ort.OrtValue.ortvalue_from_shape_and_type(shape, np.float32)
assert ort_val.is_tensor() is True
assert ort_val.shape() == shape
assert ort_val.data_type() == "tensor(float)"
assert ort_val.numpy().shape == tuple(shape)
def test_ortvalue_in_session_iobinding():
session = ort.InferenceSession(MODEL_BYTES, providers=["CPUExecutionProvider"])
io_binding = session.io_binding()
x_arr = np.array([[1.0, 2.0, 3.0]], dtype=np.float32)
w_arr = np.array([[10.0, 20.0, 30.0]], dtype=np.float32)
x_ort = ort.OrtValue.ortvalue_from_numpy(x_arr)
w_ort = ort.OrtValue.ortvalue_from_numpy(w_arr)
io_binding.bind_ortvalue_input("X", x_ort)
io_binding.bind_ortvalue_input("W", w_ort)
io_binding.bind_output("Y")
session.run_with_iobinding(io_binding)
outputs = io_binding.get_outputs()
assert len(outputs) == 1
out_ort = outputs[0]
assert isinstance(out_ort, ort.OrtValue)
assert out_ort.is_tensor() is True
assert out_ort.shape() == [1, 3]
assert out_ort.data_type() == "tensor(float)"
np.testing.assert_allclose(out_ort.numpy(), np.array([[11.0, 22.0, 33.0]], dtype=np.float32))
def main():
test_ortvalue_from_numpy()
test_ortvalue_data_types()
test_ortvalue_from_shape_and_type()
test_ortvalue_in_session_iobinding()
print("All onnxruntime.OrtValue contract assertions passed.")
if __name__ == "__main__":
main()
Ursprungs-Seeder
anonym