MCPcopy Create free account
hub / github.com/ARM-software/armnn / RegisterDevice

Method RegisterDevice

profiling/common/src/CounterDirectory.cpp:51–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51const Device* CounterDirectory::RegisterDevice(const std::string& deviceName,
52 uint16_t cores,
53 const arm::pipe::Optional<std::string>& parentCategoryName)
54{
55 // Check that the given device name is valid
56 if (deviceName.empty() ||
57 !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(deviceName))
58 {
59 throw arm::pipe::InvalidArgumentException("Trying to register a device with an invalid name");
60 }
61
62 // Check that a device with the given name is not already registered
63 if (IsDeviceRegistered(deviceName))
64 {
65 throw arm::pipe::InvalidArgumentException(fmt::format(
66 "Trying to register a device already registered (\"{}\")",
67 deviceName));
68 }
69
70 // Check that a category with the given (optional) parent category name is already registered
71 if (parentCategoryName.has_value())
72 {
73 // Get the (optional) parent category name
74 const std::string& parentCategoryNameValue = parentCategoryName.value();
75 if (parentCategoryNameValue.empty())
76 {
77 throw arm::pipe::InvalidArgumentException(
78 fmt::format("Trying to connect a device (name: \"{}\") to an invalid "
79 "parent category (name: \"{}\")",
80 deviceName,
81 parentCategoryNameValue));
82 }
83
84 // Check that the given parent category is already registered
85 auto categoryIt = FindCategory(parentCategoryNameValue);
86 if (categoryIt == m_Categories.end())
87 {
88 throw arm::pipe::InvalidArgumentException(
89 fmt::format("Trying to connect a device (name: \"{}\") to a parent category that "
90 "is not registered (name: \"{}\")",
91 deviceName,
92 parentCategoryNameValue));
93 }
94 }
95
96 // Get the device UID
97 uint16_t deviceUid = GetNextUid();
98
99 // Create the device
100 DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, cores);
101 ARM_PIPE_ASSERT(device);
102
103 // Get the raw device pointer
104 const Device* devicePtr = device.get();
105 ARM_PIPE_ASSERT(devicePtr);
106
107 // Register the device
108 m_Devices.insert(std::make_pair(deviceUid, std::move(device)));

Callers 1

ParseDataMethod · 0.45

Calls 8

formatEnum · 0.85
GetNextUidFunction · 0.85
emptyMethod · 0.80
has_valueMethod · 0.45
valueMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected