MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / ComputeTypeResolver

Class ComputeTypeResolver

python/cpp/utils.h:28–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26 using EndToken = std::variant<std::string, std::vector<std::string>, std::vector<size_t>>;
27
28 class ComputeTypeResolver {
29 private:
30 const std::string _device;
31
32 public:
33 ComputeTypeResolver(std::string device)
34 : _device(std::move(device)) {
35 }
36
37 ComputeType
38 operator()(const std::string& compute_type) const {
39 return str_to_compute_type(compute_type);
40 }
41
42 ComputeType
43 operator()(const std::unordered_map<std::string, std::string>& compute_type) const {
44 auto it = compute_type.find(_device);
45 if (it == compute_type.end())
46 return ComputeType::DEFAULT;
47 return operator()(it->second);
48 }
49 };
50
51 class DeviceIndexResolver {
52 public:

Callers 1

ReplicaPoolHelperMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected