gliner2-5-multi-coreml / tests /test_extraction_routing.py
alexwengg's picture
Add validated W8 extraction packages and ANE profiling for multi
c6e4872 verified
Raw History Blame Contribute Delete
824 Bytes
"""Schema routing for the quantized multilingual extraction runtime."""
from gliner2 import Schema
from extraction_runtime import CoreMLAdaptiveBoundaryExtractor
def record_schema(mode: str):
schema = Schema()
schema.structure("employment", mode=mode).field("person", dtype="str").field("company", dtype="str")
return schema
def test_latent_record_uses_fp32():
assert CoreMLAdaptiveBoundaryExtractor.selected_precision(record_schema("latent")) == "fp32"
def test_other_selected_schemas_use_fp16():
assert CoreMLAdaptiveBoundaryExtractor.selected_precision(Schema().entities(["person"])) == "fp16"
assert CoreMLAdaptiveBoundaryExtractor.selected_precision(record_schema("natural")) == "fp16"
assert CoreMLAdaptiveBoundaryExtractor.selected_precision(record_schema("anchorless")) == "fp16"