Skip to content

Fix type handling for output types from TOSA reference model #6660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions backends/arm/test/runner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,21 @@ def run_tosa_ref_model(
), "There are no quantization parameters, check output parameters"
tosa_ref_output = (tosa_ref_output - quant_param.zp) * quant_param.scale

if tosa_ref_output.dtype == np.double:
tosa_ref_output = tosa_ref_output.astype("float32")

# tosa_output is a numpy array, convert to torch tensor for comparison
tosa_ref_outputs.append(torch.from_numpy(tosa_ref_output.astype("float32")))
tosa_ref_outputs.append(torch.from_numpy(tosa_ref_output))

return tosa_ref_outputs


def prep_data_for_save(
data, is_quantized: bool, input_name: str, quant_param: QuantizationParams
):
data_np = np.array(data.detach(), order="C").astype(np.float32)
data_np = np.array(data.detach(), order="C").astype(
f"{data.dtype}".replace("torch.", "")
)

if is_quantized:
assert quant_param.node_name in input_name, (
Expand Down
Loading