-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path__init__.py
More file actions
105 lines (92 loc) · 3.21 KB
/
__init__.py
File metadata and controls
105 lines (92 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
"""Accordo: Automated side-by-side correctness validation for GPU kernels.
Public API:
- ValidationConfig: Configuration for kernel validation
- KernelArg: Structured kernel argument representation
- Snapshot: Captured kernel argument data from binary execution
- ValidationResult: Result of validation with detailed metrics
- ArrayMismatch: Information about array validation failures
- Accordo: Main validator class for kernel validation
- Exceptions: AccordoError, AccordoBuildError, AccordoTimeoutError, etc.
Quick Example (one-off validation):
>>> from accordo import Accordo
>>> config = Accordo.Config(
... kernel_name="my_kernel",
... kernel_args=[
... Accordo.KernelArg(name="result", type="double*"),
... Accordo.KernelArg(name="input", type="const double*"),
... ],
... tolerance=1e-6
... )
>>> validator = Accordo(config)
>>> result = validator.validate(
... reference_binary=["./app_ref"],
... optimized_binary=["./app_opt"],
... working_directory=".",
... baseline_time_ms=10.0
... )
Efficient Example (multiple optimizations vs same reference):
>>> # Capture reference once (returns Snapshot object)
>>> ref_snapshot = validator.capture_snapshot(
... binary=["./app_ref"],
... working_directory=".",
... timeout_seconds=30
... )
>>> print(ref_snapshot) # Snapshot(binary='./app_ref', arrays=3, execution_time_ms=12.50)
>>>
>>> # Compare multiple optimizations
>>> for opt_binary in optimized_binaries:
... opt_snapshot = validator.capture_snapshot(
... binary=opt_binary,
... working_directory=".",
... timeout_seconds=60
... )
... result = validator.compare_snapshots(ref_snapshot, opt_snapshot)
"""
# Public API exports
from .config import KernelArg, ValidationConfig
from .exceptions import (
AccordoBuildError,
AccordoError,
AccordoProcessError,
AccordoTimeoutError,
AccordoValidationError,
)
from .result import ArrayMismatch, ValidationResult
from .snapshot import Snapshot
from .validator import Accordo as _Accordo
# Version
__version__ = "0.2.0"
# Nest all classes under Accordo namespace
class Accordo(_Accordo):
"""Main Accordo validator with nested classes for clean API.
All Accordo components are accessible as Accordo.ClassName:
- Accordo.Config (ValidationConfig)
- Accordo.KernelArg
- Accordo.Snapshot
- Accordo.Result (ValidationResult)
- Accordo.ArrayMismatch
- Accordo.Error (AccordoError)
- Accordo.BuildError (AccordoBuildError)
- Accordo.TimeoutError (AccordoTimeoutError)
- Accordo.ProcessError (AccordoProcessError)
- Accordo.ValidationError (AccordoValidationError)
"""
# Configuration
Config = ValidationConfig
KernelArg = KernelArg
# Data structures
Snapshot = Snapshot
Result = ValidationResult
ArrayMismatch = ArrayMismatch
# Exceptions
Error = AccordoError
BuildError = AccordoBuildError
TimeoutError = AccordoTimeoutError
ProcessError = AccordoProcessError
ValidationError = AccordoValidationError
# Public API
__all__ = [
"Accordo",
]