tvm
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
24#ifndef TVM_RUNTIME_TIMER_H_
25#define TVM_RUNTIME_TIMER_H_
26
27#include <tvm/ffi/function.h>
28#include <tvm/runtime/base.h>
30#include <tvm/runtime/tensor.h>
31
32namespace tvm {
33namespace runtime {
34
41class TimerObj : public ffi::Object {
42 public:
47 virtual void Start() = 0;
52 virtual void Stop() = 0;
63 virtual int64_t SyncAndGetElapsedNanos() = 0;
64
65 virtual ~TimerObj() {}
66
67 static constexpr const bool _type_mutable = true;
68 TVM_FFI_DECLARE_OBJECT_INFO("runtime.TimerNode", TimerObj, ffi::Object);
69};
70
77class Timer : public ffi::ObjectRef {
78 public:
135
136 explicit Timer(ffi::UnsafeInit tag, ffi::ObjectPtr<TimerObj> n) : ffi::ObjectRef(tag) {
137 data_ = std::move(n);
138 }
139
141};
142
190ffi::Function WrapTimeEvaluator(ffi::Function f, Device dev, int number, int repeat,
191 int min_repeat_ms, int limit_zero_time_iterations,
192 int cooldown_interval_ms, int repeats_to_cooldown,
193 int cache_flush_bytes = 0, ffi::Function f_preproc = nullptr);
194
195} // namespace runtime
196} // namespace tvm
197
198#endif // TVM_RUNTIME_TIMER_H_
Base class for all timer implementations.
Definition timer.h:41
virtual void Stop()=0
Stop the timer.
static constexpr const bool _type_mutable
Definition timer.h:67
TVM_FFI_DECLARE_OBJECT_INFO("runtime.TimerNode", TimerObj, ffi::Object)
virtual int64_t SyncAndGetElapsedNanos()=0
Synchronize timer state and return elapsed time between Start and Stop.
virtual void Start()=0
Start the timer.
virtual ~TimerObj()
Definition timer.h:65
Timer for a specific device.
Definition timer.h:77
Timer(ffi::UnsafeInit tag, ffi::ObjectPtr< TimerObj > n)
Definition timer.h:136
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Timer, ffi::ObjectRef, TimerObj)
static TVM_RUNTIME_DLL Timer Start(Device dev)
Get a device specific timer.
Abstract device memory management API.
ffi::Function WrapTimeEvaluator(ffi::Function f, Device dev, int number, int repeat, int min_repeat_ms, int limit_zero_time_iterations, int cooldown_interval_ms, int repeats_to_cooldown, int cache_flush_bytes=0, ffi::Function f_preproc=nullptr)
Wrap a timer function to measure the time cost of a given packed function.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
DLDevice Device
Definition device_api.h:45
#define TVM_RUNTIME_DLL
Definition base.h:100
Device-independent tensor allocation, copies, views and serialization.