onnxruntime/include/onnxruntime/core/common/profiler_common.h
RandySheriffH 058108bef9
Execution Provider Profiler (#8406)
* implement cuda provider

* define profiler common

* call start after register

* add memcpy event

* add cuda correlation

* format code

* add cupti to test path

* switch to CUpti_ActivityKernel3

* reset cupti path

* fix test case

* fix trt pipeline

* add namespace

* format code

* exclude training from testing

* remove mutex
2021-09-28 13:59:52 -07:00

62 lines
No EOL
2.2 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "core/common/common.h"
#include <unordered_map>
namespace onnxruntime {
namespace profiling {
enum EventCategory {
SESSION_EVENT = 0,
NODE_EVENT,
KERNEL_EVENT,
EVENT_CATEGORY_MAX
};
// Event descriptions for the above session events.
static constexpr const char* event_categor_names_[EVENT_CATEGORY_MAX] = {
"Session",
"Node",
"Kernel"};
// Timing record for all events.
struct EventRecord {
EventRecord(EventCategory category,
int process_id,
int thread_id,
std::string event_name,
long long time_stamp,
long long duration,
std::unordered_map<std::string, std::string>&& event_args) : cat(category),
pid(process_id),
tid(thread_id),
name(std::move(event_name)),
ts(time_stamp),
dur(duration),
args(event_args) {}
EventCategory cat;
int pid;
int tid;
std::string name;
long long ts;
long long dur;
std::unordered_map<std::string, std::string> args;
};
using Events = std::vector<EventRecord>;
//Execution Provider Profiler
class EpProfiler {
public:
virtual ~EpProfiler() = default;
virtual bool StartProfiling() = 0; // called when profiling starts
virtual void EndProfiling(TimePoint start_time, Events& events) = 0; // called when profiling ends, save all captures numbers to "events"
virtual void Start(uint64_t){}; // called before op start, accept an id as argument to identify the op
virtual void Stop(uint64_t){}; // called after op stop, accept an id as argument to identify the op
};
} //namespace profiling
} //namespace onnxruntime