mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-29 08:41:22 +00:00
scripts: fix crash when --tool is not set (#15133)
This commit is contained in:
@@ -315,12 +315,13 @@ class LlamaBenchData:
|
|||||||
|
|
||||||
|
|
||||||
class LlamaBenchDataSQLite3(LlamaBenchData):
|
class LlamaBenchDataSQLite3(LlamaBenchData):
|
||||||
connection: sqlite3.Connection
|
connection: Optional[sqlite3.Connection] = None
|
||||||
cursor: sqlite3.Cursor
|
cursor: sqlite3.Cursor
|
||||||
table_name: str
|
table_name: str
|
||||||
|
|
||||||
def __init__(self, tool: str = "llama-bench"):
|
def __init__(self, tool: str = "llama-bench"):
|
||||||
super().__init__(tool)
|
super().__init__(tool)
|
||||||
|
if self.connection is None:
|
||||||
self.connection = sqlite3.connect(":memory:")
|
self.connection = sqlite3.connect(":memory:")
|
||||||
self.cursor = self.connection.cursor()
|
self.cursor = self.connection.cursor()
|
||||||
|
|
||||||
@@ -397,9 +398,6 @@ class LlamaBenchDataSQLite3(LlamaBenchData):
|
|||||||
|
|
||||||
class LlamaBenchDataSQLite3File(LlamaBenchDataSQLite3):
|
class LlamaBenchDataSQLite3File(LlamaBenchDataSQLite3):
|
||||||
def __init__(self, data_file: str, tool: Any):
|
def __init__(self, data_file: str, tool: Any):
|
||||||
super().__init__(tool)
|
|
||||||
|
|
||||||
self.connection.close()
|
|
||||||
self.connection = sqlite3.connect(data_file)
|
self.connection = sqlite3.connect(data_file)
|
||||||
self.cursor = self.connection.cursor()
|
self.cursor = self.connection.cursor()
|
||||||
|
|
||||||
@@ -411,27 +409,28 @@ class LlamaBenchDataSQLite3File(LlamaBenchDataSQLite3):
|
|||||||
if tool is None:
|
if tool is None:
|
||||||
if "llama_bench" in table_names:
|
if "llama_bench" in table_names:
|
||||||
self.table_name = "llama_bench"
|
self.table_name = "llama_bench"
|
||||||
self.tool = "llama-bench"
|
tool = "llama-bench"
|
||||||
elif "test_backend_ops" in table_names:
|
elif "test_backend_ops" in table_names:
|
||||||
self.table_name = "test_backend_ops"
|
self.table_name = "test_backend_ops"
|
||||||
self.tool = "test-backend-ops"
|
tool = "test-backend-ops"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f"No suitable table found in database. Available tables: {table_names}")
|
raise RuntimeError(f"No suitable table found in database. Available tables: {table_names}")
|
||||||
elif tool == "llama-bench":
|
elif tool == "llama-bench":
|
||||||
if "llama_bench" in table_names:
|
if "llama_bench" in table_names:
|
||||||
self.table_name = "llama_bench"
|
self.table_name = "llama_bench"
|
||||||
self.tool = "llama-bench"
|
tool = "llama-bench"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Table 'test' not found for tool 'llama-bench'. Available tables: {table_names}")
|
raise RuntimeError(f"Table 'test' not found for tool 'llama-bench'. Available tables: {table_names}")
|
||||||
elif tool == "test-backend-ops":
|
elif tool == "test-backend-ops":
|
||||||
if "test_backend_ops" in table_names:
|
if "test_backend_ops" in table_names:
|
||||||
self.table_name = "test_backend_ops"
|
self.table_name = "test_backend_ops"
|
||||||
self.tool = "test-backend-ops"
|
tool = "test-backend-ops"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Table 'test_backend_ops' not found for tool 'test-backend-ops'. Available tables: {table_names}")
|
raise RuntimeError(f"Table 'test_backend_ops' not found for tool 'test-backend-ops'. Available tables: {table_names}")
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Unknown tool: {tool}")
|
raise RuntimeError(f"Unknown tool: {tool}")
|
||||||
|
|
||||||
|
super().__init__(tool)
|
||||||
self._builds_init()
|
self._builds_init()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -653,6 +652,8 @@ if not bench_data:
|
|||||||
if not bench_data.builds:
|
if not bench_data.builds:
|
||||||
raise RuntimeError(f"{input_file} does not contain any builds.")
|
raise RuntimeError(f"{input_file} does not contain any builds.")
|
||||||
|
|
||||||
|
tool = bench_data.tool # May have chosen a default if tool was None.
|
||||||
|
|
||||||
|
|
||||||
hexsha8_baseline = name_baseline = None
|
hexsha8_baseline = name_baseline = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user