Skip to content

Minor fixes around the Arm testing framework #5976

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions backends/arm/test/runner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,10 @@ def prep_data_for_save(
data_np = np.array(data.detach(), order="C").astype(np.float32)

if is_quantized:
assert (
quant_param.node_name in input_name
), "These quantization params do not match the input tensor name"
assert quant_param.node_name in input_name, (
f"The quantization params name '{quant_param.node_name}' does not "
f"match the input tensor name '{input_name}'."
)
data_np = (
((data_np / np.float32(quant_param.scale)) + quant_param.zp)
.round()
Expand Down
6 changes: 5 additions & 1 deletion backends/arm/test/tester/arm_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(
model: torch.nn.Module,
example_inputs: Tuple[torch.Tensor],
compile_spec: List[CompileSpec] = None,
tosa_ref_model_path: str | None = None,
):
"""
Args:
Expand All @@ -160,7 +161,10 @@ def __init__(

# Initiate runner_util
intermediate_path = get_intermediate_path(compile_spec)
self.runner_util = RunnerUtil(intermediate_path=intermediate_path)
self.runner_util = RunnerUtil(
intermediate_path=intermediate_path,
tosa_ref_model_path=tosa_ref_model_path,
)

self.compile_spec = compile_spec
super().__init__(model, example_inputs)
Expand Down
60 changes: 30 additions & 30 deletions backends/arm/tosa_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@
import torch


UNSUPPORTED_DTYPES = (
torch.float64,
torch.double,
torch.complex64,
torch.cfloat,
torch.complex128,
torch.cdouble,
torch.uint8,
torch.int64,
torch.long,
)

DTYPE_MAP = {
torch.float32: ts.DType.FP32,
torch.float: ts.DType.FP32,
torch.float16: ts.DType.FP16,
torch.half: ts.DType.FP16,
torch.bfloat16: ts.DType.BF16,
torch.int8: ts.DType.INT8,
torch.int16: ts.DType.INT16,
torch.short: ts.DType.INT16,
torch.int32: ts.DType.INT32,
torch.int: ts.DType.INT32,
torch.bool: ts.DType.BOOL,
}


def map_dtype(data_type):
unsupported = (
torch.float64,
torch.double,
torch.complex64,
torch.cfloat,
torch.complex128,
torch.cdouble,
torch.uint8,
torch.int64,
torch.long,
)

dmap = {
torch.float32: ts.DType.FP32,
torch.float: ts.DType.FP32,
torch.float16: ts.DType.FP16,
torch.half: ts.DType.FP16,
torch.bfloat16: ts.DType.BF16,
torch.int8: ts.DType.INT8,
torch.int16: ts.DType.INT16,
torch.short: ts.DType.INT16,
torch.int32: ts.DType.INT32,
torch.int: ts.DType.INT32,
torch.bool: ts.DType.BOOL,
}

assert unsupported.count(data_type) == 0, "Unsupported type"
rtype = dmap.get(data_type)
assert rtype is not None, "Unknown type"
return rtype
assert data_type not in UNSUPPORTED_DTYPES, f"Unsupported type: {data_type}"
assert data_type in DTYPE_MAP, f"Unknown type: {data_type}"
return DTYPE_MAP[data_type]


# Returns the shape and type of a node
Expand Down
Loading