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
104104 # const data directly. Path created and data written only in debug builds.
105105 tosa_graph = ts .TosaSerializer (artifact_path )
106106
107- assert (
107+ if not (
108108 tosa_spec .version .major == ts .TOSA_VERSION_MAJOR
109109 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+ )
111116
112117 # TODO: Fix the need to lazily import this.
113118 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):
8484 ValueError: If ``meta['val']`` is not a ``FakeTensor``.
8585
8686 """
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" )
8889 val = meta ["val" ]
8990 if type (val ) is tuple :
9091 # 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(
245245 const_2_power_15_or_31 = 1 << offset
246246 shifted_mantissa = round (mantissa * const_2_power_15_or_31 )
247247
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 } "
249251
250252 if shifted_mantissa == const_2_power_15_or_31 :
251253 shifted_mantissa = shifted_mantissa // 2
@@ -255,7 +257,10 @@ def compute_multiplier_and_shift(
255257 shift = offset - shift
256258
257259 # 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+ )
259264
260265 multiplier = shifted_mantissa
261266
You can’t perform that action at this time.
0 commit comments