mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Cherry-pick of https://github.com/facebookresearch/torch_ucc/pull/95. I recommend waiting until https://github.com/pytorch/pytorch/pull/81583 is merged first, so the CI is checking if this PR compiles correctly. Marking this as a draft for now, will change to "ready for review" once https://github.com/pytorch/pytorch/pull/81583 merged. Pull Request resolved: https://github.com/pytorch/pytorch/pull/81791 Approved by: https://github.com/kwen2501
36 lines
921 B
C++
36 lines
921 B
C++
#include <gtest/gtest.h>
|
|
#include <torch/csrc/distributed/c10d/UCCUtils.hpp>
|
|
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
using namespace c10d;
|
|
|
|
TEST(ProcessGroupUCCTest, testTrim) {
|
|
std::vector<std::pair<std::string, std::string>> tests = {
|
|
{" allreduce ", "allreduce"},
|
|
{"\tallgather", "allgather"},
|
|
{"send\n", "send"},
|
|
};
|
|
for (auto entry : tests) {
|
|
ASSERT_EQ(trim(entry.first), entry.second);
|
|
}
|
|
}
|
|
|
|
TEST(ProcessGroupUCCTest, testToLower) {
|
|
std::vector<std::pair<std::string, std::string>> tests = {
|
|
{"AllReduce", "allreduce"},
|
|
{"ALLGATHER", "allgather"},
|
|
{"send", "send"},
|
|
};
|
|
for (auto entry : tests) {
|
|
ASSERT_EQ(tolower(entry.first), entry.second);
|
|
}
|
|
}
|
|
|
|
TEST(ProcessGroupUCCTest, testParseList) {
|
|
std::string input = "\tAllReduce, ALLGATHER, send\n";
|
|
std::vector<std::string> expect{"allreduce", "allgather", "send"};
|
|
ASSERT_EQ(parse_list(input), expect);
|
|
}
|