Skip to content

Commit

Permalink
Remove compress_to_fp16=False from examples (#2682)
Browse files Browse the repository at this point in the history
### Changes

Removed `compress_to_fp16=False` from `save_model` functions in
examples.

### Reason for changes

Using this parameter when saving OpenVINO model is no longer required

### Tests

Changes were tested via pytest, using example tests in project. While
testing, some errors occured, but all of them were about wrong
development environment settings. Setting up the invironment took most
of the time.
  • Loading branch information
truhinnm authored May 24, 2024
1 parent 4d7fd56 commit 936533e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def transform_fn(data_item):
# nncf.quantize_with_accuracy_control(...) keeps the most impactful operations within
# the model in the original precision to achieve the specified model accuracy.
int8_ir_path = f"{ROOT}/stfpm_int8.xml"
ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False)
ov.save_model(ov_quantized_model, int8_ir_path)
print(f"[2/7] Save INT8 model: {int8_ir_path}")
int8_size = get_model_size(int8_ir_path, verbose=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def transform_fn(data_item):
fp32_model_size = get_model_size(fp32_ir_path, verbose=True)

int8_ir_path = ROOT / "mobilenet_v2_int8.xml"
ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False)
ov.save_model(ov_quantized_model, int8_ir_path)
print(f"[2/7] Save INT8 model: {int8_ir_path}")
int8_model_size = get_model_size(int8_ir_path, verbose=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def main():
# Quantize mode in OpenVINO representation
quantized_model = quantize(ov_model, data_loader, validator)
quantized_model_path = Path(f"{ROOT}/{MODEL_NAME}_openvino_model/{MODEL_NAME}_quantized.xml")
ov.save_model(quantized_model, str(quantized_model_path), compress_to_fp16=False)
ov.save_model(quantized_model, str(quantized_model_path))

# Validate FP32 model
fp_stats, total_images, total_objects = validate(ov_model, tqdm(data_loader), validator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def main():
quantized_model = quantize_ac(ov_model, data_loader, validator)

quantized_model_path = Path(f"{ROOT}/{MODEL_NAME}_openvino_model/{MODEL_NAME}_quantized.xml")
ov.save_model(quantized_model, str(quantized_model_path), compress_to_fp16=False)
ov.save_model(quantized_model, str(quantized_model_path))

# Validate FP32 model
fp_stats, total_images, total_objects = validate(ov_model, tqdm(data_loader), validator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def transform_fn(data_item):
fp32_model_size = get_model_size(fp32_ir_path, verbose=True)

int8_ir_path = f"{ROOT}/mobilenet_v2_int8.xml"
ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False)
ov.save_model(ov_quantized_model, int8_ir_path)
print(f"[2/7] Save INT8 model: {int8_ir_path}")
int8_model_size = get_model_size(int8_ir_path, verbose=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def transform_fn(data_item: Tuple[torch.Tensor, int], device: torch.device) -> t
fp32_model_size = get_model_size(fp32_ir_path, verbose=True)

int8_ir_path = ROOT / "mobilenet_v2_int8.xml"
ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False)
ov.save_model(ov_quantized_model, int8_ir_path)
print(f"[2/7] Save INT8 model: {int8_ir_path}")
int8_model_size = get_model_size(int8_ir_path, verbose=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def main():
fp32_model_size = get_model_size(fp32_ir_path, verbose=True)

int8_ir_path = f"{ROOT}/ssd300_vgg16_int8.xml"
ov.save_model(ov_quantized_model, int8_ir_path, compress_to_fp16=False)
ov.save_model(ov_quantized_model, int8_ir_path)
print(f"[2/7] Save INT8 model: {int8_ir_path}")
int8_model_size = get_model_size(int8_ir_path, verbose=True)

Expand Down

0 comments on commit 936533e

Please sign in to comment.