Skip to content

Commit

Permalink
I forgot to hit save
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Fowers <jeremy.fowers@amd.com>
  • Loading branch information
jeremyfowers committed Dec 4, 2023
1 parent 7188eaf commit afd81b9
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions src/turnkeyml/build/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,63 +622,6 @@ def fire(self, state: build.State):
return state


<<<<<<< HEAD
class QuantizeONNXModel(stage.Stage):
"""
Stage that takes an ONNX model and a dataset of quantization samples as inputs,
and performs static post-training quantization to the model to int8 precision.
Expected inputs:
- state.model is a path to the ONNX model
- state.quantization_dataset is a dataset that is used for static quantization
Outputs:
- A *_quantized.onnx file => the quantized onnx model.
"""

def __init__(self):
super().__init__(
unique_name="quantize_onnx",
monitor_message="Quantizing ONNX model",
)

def fire(self, state: build.State):
input_path = state.intermediate_results[0]
output_path = quantized_onnx_file(state)

quant_helpers.quantize(
input_file=input_path,
data=state.quantization_samples,
output_file=output_path,
)

# Check that the converted model is still valid
success_msg = "\tSuccess quantizing ONNX model to int8"
fail_msg = "\tFailed quantizing ONNX model to int8"

if check_model(output_path, success_msg, fail_msg):
state.intermediate_results = [output_path]

stats = fs.Stats(
state.cache_dir, state.config.build_name, state.evaluation_id
)
stats.save_model_eval_stat(
fs.Keys.ONNX_FILE,
output_path,
)
else:
msg = f"""
Attempted to use {state.quantization_dataset} to statically quantize
model to int8 datatype, however this operation was not successful.
More information may be available in the log file at **{self.logfile_path}**
"""
raise exp.StageError(msg)

return state


=======
>>>>>>> canary
class SuccessStage(stage.Stage):
"""
Stage that sets state.build_status = build.Status.SUCCESSFUL_BUILD,
Expand Down

0 comments on commit afd81b9

Please sign in to comment.