File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,15 @@ def _preprocess( # noqa: C901
104
104
# const data directly. Path created and data written only in debug builds.
105
105
tosa_graph = ts .TosaSerializer (artifact_path )
106
106
107
- assert (
107
+ if not (
108
108
tosa_spec .version .major == ts .TOSA_VERSION_MAJOR
109
109
and tosa_spec .version .minor == ts .TOSA_VERSION_MINOR
110
- ), f"TOSA serializer version ({ ts .TOSA_VERSION_MAJOR } .{ ts .TOSA_VERSION_MINOR } ) doesn't match specification { tosa_spec } "
110
+ ):
111
+ raise RuntimeError (
112
+ f"TOSA serializer version "
113
+ f"({ ts .TOSA_VERSION_MAJOR } .{ ts .TOSA_VERSION_MINOR } ) "
114
+ f"doesn't match specification { tosa_spec } "
115
+ )
111
116
112
117
# TODO: Fix the need to lazily import this.
113
118
from executorch .backends .arm ._passes import ArmPassManager
Original file line number Diff line number Diff line change @@ -84,7 +84,8 @@ def extract_tensor_meta(meta, tosa_spec: TosaSpecification):
84
84
ValueError: If ``meta['val']`` is not a ``FakeTensor``.
85
85
86
86
"""
87
- assert meta .get ("val" ) is not None
87
+ if meta .get ("val" ) is None :
88
+ raise ValueError ("Expected node.meta['val'] to be set to a FakeTensor" )
88
89
val = meta ["val" ]
89
90
if type (val ) is tuple :
90
91
# TODO: should use first concrete representation
Original file line number Diff line number Diff line change @@ -245,7 +245,9 @@ def compute_multiplier_and_shift(
245
245
const_2_power_15_or_31 = 1 << offset
246
246
shifted_mantissa = round (mantissa * const_2_power_15_or_31 )
247
247
248
- assert shifted_mantissa <= const_2_power_15_or_31
248
+ assert (
249
+ shifted_mantissa <= const_2_power_15_or_31
250
+ ), f"Mantissa { shifted_mantissa } exceeds limit { const_2_power_15_or_31 } "
249
251
250
252
if shifted_mantissa == const_2_power_15_or_31 :
251
253
shifted_mantissa = shifted_mantissa // 2
@@ -255,7 +257,10 @@ def compute_multiplier_and_shift(
255
257
shift = offset - shift
256
258
257
259
# INT32_MAX, 2^31 - 1
258
- assert shifted_mantissa <= (const_2_power_15_or_31 - 1 )
260
+ assert shifted_mantissa <= (const_2_power_15_or_31 - 1 ), (
261
+ f"Mantissa { shifted_mantissa } exceeds signed max "
262
+ f"{ const_2_power_15_or_31 - 1 } "
263
+ )
259
264
260
265
multiplier = shifted_mantissa
261
266
You can’t perform that action at this time.
0 commit comments