New example and updated ai-hun upload order (#4)
Co-authored-by: samirodr <sami.rodrigue@slalom.com> Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
@@ -28,30 +28,19 @@ def _dataset_entries(inputs: dict[str, Any]) -> dict[str, list[Any]]:
|
||||
|
||||
|
||||
def submit_compile_job(
|
||||
model: Any,
|
||||
model: Model,
|
||||
device: Device,
|
||||
input_specs: dict[str, tuple[tuple[int, ...], str]],
|
||||
target_runtime: str,
|
||||
options: str | None = None,
|
||||
job_name: str | None = None,
|
||||
model_name: str | None = None,
|
||||
) -> ModelJobResult:
|
||||
compile_options = f"--target_runtime {target_runtime}"
|
||||
if options:
|
||||
compile_options = f"{compile_options} {options}"
|
||||
|
||||
model_arg = model
|
||||
if isinstance(model, Path):
|
||||
model_arg = str(model)
|
||||
elif isinstance(model, str):
|
||||
candidate = Path(model)
|
||||
model_arg = model if candidate.exists() or candidate.suffix else hub.get_model(model)
|
||||
|
||||
if model_name and isinstance(model_arg, str) and Path(model_arg).exists():
|
||||
model_arg = hub.upload_model(model_arg, name=model_name)
|
||||
|
||||
job = hub.submit_compile_job(
|
||||
model=model_arg,
|
||||
model=model,
|
||||
device=device,
|
||||
name=job_name,
|
||||
input_specs=input_specs,
|
||||
@@ -64,14 +53,14 @@ def submit_compile_job(
|
||||
|
||||
|
||||
def submit_inference_job(
|
||||
model_id: str,
|
||||
model: Model,
|
||||
device: Device,
|
||||
inputs: dict[str, Any],
|
||||
output_dir: str | Path,
|
||||
job_name: str | None = None,
|
||||
) -> InferenceJobResult:
|
||||
job = hub.submit_inference_job(
|
||||
model=hub.get_model(model_id),
|
||||
model=model,
|
||||
device=device,
|
||||
inputs=_dataset_entries(inputs),
|
||||
name=job_name,
|
||||
@@ -83,13 +72,13 @@ def submit_inference_job(
|
||||
|
||||
|
||||
def submit_profile_job(
|
||||
model_id: str,
|
||||
model: Model,
|
||||
device: Device,
|
||||
options: str | None = None,
|
||||
job_name: str | None = None,
|
||||
) -> ProfileJobResult:
|
||||
job = hub.submit_profile_job(
|
||||
model=hub.get_model(model_id),
|
||||
model=model,
|
||||
device=device,
|
||||
name=job_name,
|
||||
options=options or "",
|
||||
@@ -98,17 +87,13 @@ def submit_profile_job(
|
||||
|
||||
|
||||
def submit_quantize_job(
|
||||
model: str | Path,
|
||||
model: Model,
|
||||
calibration_data: dict[str, Any],
|
||||
options: str | None = None,
|
||||
job_name: str | None = None,
|
||||
model_name: str | None = None,
|
||||
) -> ModelJobResult:
|
||||
model_arg = str(model)
|
||||
if model_name and Path(model_arg).exists():
|
||||
model_arg = hub.upload_model(model_arg, name=model_name)
|
||||
job = hub.submit_quantize_job(
|
||||
model=model_arg,
|
||||
model=model,
|
||||
calibration_data=_dataset_entries(calibration_data),
|
||||
weights_dtype=QuantizeDtype.INT8,
|
||||
activations_dtype=QuantizeDtype.INT8,
|
||||
|
||||
Reference in New Issue
Block a user