Skip to content

Commit 17b8cbb

Browse files
Bycobmergify[bot]
authored andcommitted
fix(torch): metrics naming for multiple test sets
1 parent b2157fd commit 17b8cbb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/backends/torch/torchlib.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,11 @@ namespace dd
12091209
std::vector<std::string> meas_names = meas_obj.list_keys();
12101210
for (auto name : meas_names)
12111211
{
1212-
std::string metric_name
1213-
= name + "_test" + std::to_string(i);
1212+
std::string metric_name;
1213+
if (i == 0)
1214+
metric_name = name;
1215+
else
1216+
metric_name = name + "_test" + std::to_string(i - 1);
12141217

12151218
if (name != "cmdiag" && name != "cmfull"
12161219
&& name != "clacc" && name != "cliou"

tests/ut-torchapi.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,14 @@ TEST(torchapi, service_train_resume)
929929
}
930930

931931
// remove files
932+
ASSERT_TRUE(fileops::file_exists(resnet50_train_repo + "best_model.txt"));
933+
remove((resnet50_train_repo + "best_model.txt").c_str());
934+
ASSERT_TRUE(
935+
fileops::file_exists(resnet50_train_repo + "best_model_test_0.txt"));
936+
remove((resnet50_train_repo + "best_model_test_0.txt").c_str());
937+
ASSERT_FALSE(
938+
fileops::file_exists(resnet50_train_repo + "best_model_test_1.txt"));
939+
932940
std::unordered_set<std::string> lfiles;
933941
fileops::list_directory(resnet50_train_repo, true, false, false, lfiles);
934942
for (std::string ff : lfiles)

0 commit comments

Comments
 (0)