Skip to content

Commit

Permalink
[UnitTests] Removed unnecessary file creation from unit tests. (#7998)
Browse files Browse the repository at this point in the history
Some of the unit tests produced output when run, even for a successful
test.  Edited these tests to either write to a temporary directory, or
to suppress the file creation entirely.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
  • Loading branch information
Lunderberg and Lunderberg committed May 7, 2021
1 parent 4122a6a commit 51e2df1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def tune_and_check(mod, data, weight):
log_file = fp.name

# Tune tasks
tuner = auto_scheduler.TaskScheduler(tasks, task_weights)
tuner = auto_scheduler.TaskScheduler(tasks, task_weights, callbacks=[])
tune_option = auto_scheduler.TuningOptions(
num_measure_trials=1,
num_measures_per_round=1,
Expand Down
2 changes: 1 addition & 1 deletion tests/python/relay/test_auto_scheduler_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def tune_network(network, target):

# Tuning
measure_ctx = auto_scheduler.LocalRPCMeasureContext(timeout=60)
tuner = auto_scheduler.TaskScheduler(tasks, task_weights)
tuner = auto_scheduler.TaskScheduler(tasks, task_weights, callbacks=[])
tune_option = auto_scheduler.TuningOptions(
num_measure_trials=100,
num_measures_per_round=2,
Expand Down
8 changes: 5 additions & 3 deletions tests/python/unittest/test_auto_scheduler_task_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_task_scheduler_round_robin():
num_measures_per_round=1,
measure_callbacks=[auto_scheduler.RecordToFile(log_file)],
)
task_scheduler = auto_scheduler.TaskScheduler(tasks, strategy="round-robin")
task_scheduler = auto_scheduler.TaskScheduler(tasks, strategy="round-robin", callbacks=[])
task_scheduler.tune(tune_option, search_policy="sketch.random")

# Check the result of round robin
Expand All @@ -66,7 +66,7 @@ def test_task_scheduler_round_robin():

# test continuous tuning (restoring the status)
task_scheduler = auto_scheduler.TaskScheduler(
tasks, strategy="round-robin", load_log_file=log_file
tasks, strategy="round-robin", load_log_file=log_file, callbacks=[]
)
tune_option = auto_scheduler.TuningOptions(
num_measure_trials=len(tasks),
Expand Down Expand Up @@ -116,7 +116,9 @@ def objective_func(costs):
num_measures_per_round=1,
measure_callbacks=[auto_scheduler.RecordToFile(log_file)],
)
task_scheduler = auto_scheduler.TaskScheduler(tasks, objective_func=objective_func)
task_scheduler = auto_scheduler.TaskScheduler(
tasks, objective_func=objective_func, callbacks=[]
)

# Forcely rewrite the initial values.
# This can make this test more stable on the slow CI machines
Expand Down
3 changes: 1 addition & 2 deletions tests/python/unittest/test_link_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_c_link_params():
assert set(lib.params.keys()) == {"p0", "p1"} # NOTE: op folded

src = lib.lib.get_source()
lib.lib.save("test.c", "c")
lib.lib.save(temp_dir.relpath("test.c"), "c")
c_dtype = _get_c_datatype(dtype)
src_lines = src.split("\n")
param = lib.params["p0"].asnumpy().reshape(np.prod(KERNEL_SHAPE))
Expand All @@ -302,7 +302,6 @@ def test_c_link_params():
i += 1

assert cursor == np.prod(param.shape)
temp = utils.tempdir()

# Need a unique name per library to avoid dlopen caching the lib load.
lib_path = temp_dir.relpath(f"test-{dtype}-linked.so")
Expand Down

0 comments on commit 51e2df1

Please sign in to comment.