Skip to content
Open
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
2 changes: 1 addition & 1 deletion python/tvm/relax/frontend/torch/fx_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ def forward(self, input):
# Use the dynamo.export() to export the PyTorch model to FX.
try:
graph_module = dynamo.export(torch_model, *input_tensors)
except:
except Exception:
raise RuntimeError("Failed to export the PyTorch model to FX.")

# Use the importer to import the PyTorch model to Relax.
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/runtime/_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def copyfrom(self, source_array):
if not isinstance(source_array, np.ndarray):
try:
source_array = np.array(source_array, dtype=self.dtype)
except:
except Exception:
raise TypeError(
f"array must be an array_like data, type {type(source_array)} is not supported"
)
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/s_tir/dlight/analysis/common_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def get_max_shared_memory_per_block(target: Target) -> int:
def get_root_block(sch: Schedule, func_name: str = "main") -> SBlockRV:
try:
block = sch.mod[func_name].body.block
except:
except Exception:
raise ValueError(
f"The function body is expected to be the root block, but got:\n"
f"{sch.mod[func_name].body}"
Expand Down
2 changes: 1 addition & 1 deletion tests/python/contrib/test_hexagon/test_run_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_run_unit_tests(hexagon_session: Session, gtest_args, unit_test_name):
"""Try running gtest unit tests and capture output and error code"""
try:
func = hexagon_session._rpc.get_function("hexagon.run_unit_tests")
except:
except Exception:
print(
"This test requires TVM Runtime to be built with a Hexagon gtest"
"version using Hexagon API cmake flag"
Comment on lines 155 to 157
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of just printing a message, it's better to use pytest.skip to explicitly mark the test as skipped. This provides clearer test results and avoids the test passing silently or failing with a subsequent NameError if func is used later. You'll need to import pytest at the top of the file.

        pytest.skip(
            "This test requires TVM Runtime to be built with a Hexagon gtest" 
            "version using Hexagon API cmake flag"
        )

Expand Down
2 changes: 1 addition & 1 deletion tests/python/relax/test_group_gemm_flashinfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def has_cutlass():
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
major, minor = pynvml.nvmlDeviceGetCudaComputeCapability(handle)
return major >= 9 # SM90+
except:
except Exception:
return False


Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/release/make_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def pr_title(number, heading):
try:
title = pr_dict[int(number)]["title"]
title = strip_header(title, heading)
except:
except Exception:
sprint("The out.pkl file is not match with csv file.")
exit(1)
Comment on lines +221 to 223
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While except Exception: is an improvement, it's good practice to be more specific about the exceptions you expect to catch. In this case, int(number) could raise a ValueError and pr_dict[...] could raise a KeyError. Catching (ValueError, KeyError) would make the error handling more precise.

Suggested change
except Exception:
sprint("The out.pkl file is not match with csv file.")
exit(1)
except (ValueError, KeyError):
sprint("The out.pkl file is not match with csv file.")
exit(1)

return title
Expand Down