zxybazh commented on PR #11486:
URL: https://github.com/apache/tvm/pull/11486#issuecomment-1152869144
An alternate way could be creating a preemptive interface that instead of
counting time based solely on scopes, each timer would only count time elapsed
in this scope and not in any other timer that created before this scope ends.
For example if we want to count func A & B's time cost, and func A calls B
in the scope than we might have to implement it as:
```
Func A () {
{
TVMTimeScope(XXX::A);
…
}
call Func B;
{
TVMTimeScope(XXX::A);
…
}
}
Func B () {
TVMTimeScope(XXX::B);
…
}
```
With preemptive timer we can simple implement as
```
Func A () {
TVMTimeScope(XXX::A);
…
call Func B;
…
}
Func B () {
TVMTimeScope(XXX::B);
…
}
```
Implementation won’t be super hard, we only need to store current timestamps
in a separate stack (I think we cannot reuse the context management timestamp
stack because our method will change the semantics of profiler context).
The disadvantage is this method introduces some amgiuation in how profiler
works and needs an extra stack.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]