tvm
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>
29 #include <tvm/runtime/device_api.h>
30 #include <tvm/runtime/tensor.h>
31 
32 namespace tvm {
33 namespace runtime {
34 
41 class TimerNode : public ffi::Object {
42  public:
47  virtual void Start() = 0;
52  virtual void Stop() = 0;
63  virtual int64_t SyncAndGetElapsedNanos() = 0;
64 
65  virtual ~TimerNode() {}
66 
67  static constexpr const bool _type_mutable = true;
68  TVM_FFI_DECLARE_OBJECT_INFO("runtime.TimerNode", TimerNode, ffi::Object);
69 };
70 
77 class Timer : public ffi::ObjectRef {
78  public:
135 
137 };
138 
187  int min_repeat_ms, int limit_zero_time_iterations,
188  int cooldown_interval_ms, int repeats_to_cooldown,
189  int cache_flush_bytes = 0, ffi::Function f_preproc = nullptr);
190 
191 } // namespace runtime
192 } // namespace tvm
193 
194 #endif // TVM_RUNTIME_TIMER_H_
Base class for all timer implementations.
Definition: timer.h:41
virtual int64_t SyncAndGetElapsedNanos()=0
Synchronize timer state and return elapsed time between Start and Stop.
virtual void Stop()=0
Stop the timer.
virtual void Start()=0
Start the timer.
static constexpr const bool _type_mutable
Definition: timer.h:67
virtual ~TimerNode()
Definition: timer.h:65
TVM_FFI_DECLARE_OBJECT_INFO("runtime.TimerNode", TimerNode, ffi::Object)
Timer for a specific device.
Definition: timer.h:77
static TVM_RUNTIME_DLL Timer Start(Device dev)
Get a device specific timer.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Timer, ffi::ObjectRef, TimerNode)
Abstract device memory management API.
tvm::relax::Function Function
Definition: transform.h:38
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.
Tensor repeat(const Tensor &x, int repeats, int axis, std::string name="T_repeat", std::string tag=kBroadcast)
Creates an operation to repeat elements of an array.
Definition: transform.h:1370
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37
DLDevice Device
Definition: device_api.h:43
#define TVM_RUNTIME_DLL
Definition: base.h:88
A device-independent managed Tensor abstraction.