-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VitisAI] Add profiler interface for vitisai (#23032)
### Description <!-- Describe your changes. --> Add common interfaces for vitis ep profiler. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Vitis ep can collect and record api and kernel timestamps in file when onnxruntime '-p' is enabled.
- Loading branch information
1 parent
2ff66b8
commit a4eb8f2
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "vitisai_profiler.h" | ||
|
||
namespace onnxruntime { | ||
namespace profiling { | ||
|
||
#if defined(USE_VITISAI) | ||
|
||
bool VitisaiProfiler::StartProfiling(TimePoint tp) { | ||
return true; | ||
} | ||
|
||
void VitisaiProfiler::EndProfiling(TimePoint tp, Events& events) { | ||
auto time_point = | ||
std::chrono::duration_cast<std::chrono::microseconds>(tp.time_since_epoch()).count(); | ||
|
||
std::vector<EventInfo> api_events; | ||
std::vector<EventInfo> kernel_events; | ||
profiler_collect(api_events, kernel_events); | ||
|
||
std::unordered_map<std::string, std::string> event_args; | ||
|
||
for (auto& a : api_events) { | ||
events.emplace_back(EventCategory::API_EVENT, | ||
std::get<1>(a), // pid | ||
std::get<2>(a), // tid | ||
std::get<0>(a), // name | ||
std::get<3>(a) - time_point, // timestamp | ||
std::get<4>(a), // duration | ||
event_args); | ||
} | ||
|
||
for (auto& k : kernel_events) { | ||
events.emplace_back(EventCategory::KERNEL_EVENT, | ||
std::get<1>(k), | ||
std::get<2>(k), | ||
std::get<0>(k), | ||
std::get<3>(k) - time_point, | ||
std::get<4>(k), | ||
event_args); | ||
} | ||
} | ||
|
||
#endif | ||
|
||
} // namespace profiling | ||
} // namespace onnxruntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "core/providers/vitisai/include/vaip/global_api.h" | ||
|
||
namespace onnxruntime { | ||
namespace profiling { | ||
|
||
#if defined(USE_VITISAI) | ||
class VitisaiProfiler final : public EpProfiler { | ||
public: | ||
VitisaiProfiler() = default; | ||
ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(VitisaiProfiler); | ||
~VitisaiProfiler() {} | ||
bool StartProfiling(TimePoint) override; | ||
void EndProfiling(TimePoint, Events&) override; | ||
void Start(uint64_t) override{}; | ||
void Stop(uint64_t) override{}; | ||
}; | ||
#endif | ||
|
||
} // namespace profiling | ||
} // namespace onnxruntime |