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/object.h>
28
29namespace tvm {
30namespace runtime {
31
38class TimerObj : public ffi::Object {
39 public:
44 virtual void Start() = 0;
49 virtual void Stop() = 0;
60 virtual int64_t SyncAndGetElapsedNanos() = 0;
61
62 virtual ~TimerObj() {}
63
64 static constexpr const bool _type_mutable = true;
65 TVM_FFI_DECLARE_OBJECT_INFO("runtime.Timer", TimerObj, ffi::Object);
66};
67
74class Timer : public ffi::ObjectRef {
75 public:
76 explicit Timer(ffi::UnsafeInit tag, ffi::ObjectPtr<TimerObj> n) : ffi::ObjectRef(tag) {
77 data_ = std::move(n);
78 }
79
81};
82
83} // namespace runtime
84} // namespace tvm
85
86#endif // TVM_RUNTIME_TIMER_H_
Base class for all timer implementations.
Definition timer.h:38
TVM_FFI_DECLARE_OBJECT_INFO("runtime.Timer", TimerObj, ffi::Object)
virtual void Stop()=0
Stop the timer.
static constexpr const bool _type_mutable
Definition timer.h:64
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:62
Timer for a specific device.
Definition timer.h:74
Timer(ffi::UnsafeInit tag, ffi::ObjectPtr< TimerObj > n)
Definition timer.h:76
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Timer, ffi::ObjectRef, TimerObj)
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41