24 #ifndef TVM_RUNTIME_PROFILING_H_ 25 #define TVM_RUNTIME_PROFILING_H_ 35 #include <unordered_map> 55 virtual void Start() = 0;
60 virtual void Stop() = 0;
75 static constexpr
const char*
_type_key =
"TimerNode";
153 namespace profiling {
164 static constexpr
const char*
_type_key =
"runtime.profiling.DeviceWrapper";
214 String AsTable(
bool sort =
true,
bool aggregate =
true,
bool compute_col_sums =
true)
const;
249 static constexpr
const char*
_type_key =
"runtime.profiling.Report";
311 static constexpr
const char*
_type_key =
"runtime.profiling.MetricCollector";
370 explicit Profiler(std::vector<Device> devs, std::vector<MetricCollector> metric_collectors);
392 std::unordered_map<std::string, ObjectRef> extra_metrics = {});
397 void StopCall(std::unordered_map<std::string, ObjectRef> extra_metrics = {});
410 std::vector<Device> devs_;
411 bool is_running_{
false};
412 std::vector<CallFrame> calls_;
413 std::stack<CallFrame> in_flight_;
414 std::vector<MetricCollector> collectors_;
428 static constexpr
const char*
_type_key =
"runtime.profiling.Duration";
443 static constexpr
const char*
_type_key =
"runtime.profiling.Percent";
458 static constexpr
const char*
_type_key =
"runtime.profiling.Count";
484 #endif // TVM_RUNTIME_PROFILING_H_ Definition: profiling.h:448
double microseconds
Definition: profiling.h:421
Definition: profiling.h:418
static constexpr const char * _type_key
Definition: profiling.h:75
bool IsRunning() const
Check if the profiler is currently running.
Definition: profiling.h:407
virtual int64_t SyncAndGetElapsedNanos()=0
Synchronize timer state and return elapsed time between Start and Stop.
CountNode(int64_t a)
Definition: profiling.h:456
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
Device dev
Definition: profiling.h:324
DeviceWrapperNode(Device device)
Definition: profiling.h:162
std::vector< std::pair< MetricCollector, ObjectRef > > extra_collectors
Definition: profiling.h:334
double percent
Definition: profiling.h:436
virtual void Start()=0
Start the timer.
Map< String, Map< String, ObjectRef > > device_metrics
Metrics collected for the entire run of the model on a per-device basis.
Definition: profiling.h:194
base class of all object containers.
Definition: object.h:165
Timer DefaultTimer(Device dev)
Default timer if one does not exist for the device.
Managed NDArray. The array is backed by reference counted blocks.
Definition: ndarray.h:59
Interface for user defined profiling metric collection.
Definition: profiling.h:288
#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:737
virtual void Stop()=0
Stop the timer.
Wrapper for MetricCollectorNode.
Definition: profiling.h:316
DurationNode(double a)
Definition: profiling.h:426
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
std::unordered_map< std::string, ObjectRef > extra_metrics
Definition: profiling.h:330
Array< Map< String, ObjectRef > > calls
A list of function calls and the metrics recorded for that call.
Definition: profiling.h:186
Timer timer
Definition: profiling.h:328
Base class for all implementations.
Definition: profiling.h:49
Reference to string objects.
Definition: string.h:129
Data collected from a profiling run. Includes per-call metrics and per-device metrics.
Definition: profiling.h:177
Abstract device memory management API.
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1608
DLDevice Device
Definition: ndarray.h:43
Definition: profiling.h:253
Base class of all object reference.
Definition: object.h:504
Definition: profiling.h:322
TVM_DECLARE_BASE_OBJECT_INFO(TimerNode, Object)
Definition: profiling.h:433
A managed object in the TVM runtime.
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:664
Device device
Definition: profiling.h:159
int64_t value
Definition: profiling.h:451
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
Definition: map.h:1235
Wrapper for Device because Device is not passable across the PackedFunc interface.
Definition: profiling.h:157
virtual ~TimerNode()
Definition: profiling.h:73
virtual ~MetricCollectorNode()
Definition: profiling.h:309
Wrapper for Device.
Definition: profiling.h:169
Definition: profiling.h:356
#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:721
String ShapeString(const std::vector< int64_t > &shape, DLDataType dtype)
String representation of a shape encoded as a vector.
String name
Definition: profiling.h:326
Type-erased function used across TVM API.
Timer for a specific device.
Definition: profiling.h:85
This file defines the TVM global function registry.
DeviceWrapper(Device dev)
Definition: profiling.h:171
PercentNode(double a)
Definition: profiling.h:441