-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
#include "pycb_utils.h" | ||
#include <memory> | ||
|
||
namespace turbomind { | ||
|
||
thread_local std::shared_ptr<int> _current; | ||
thread_local std::shared_ptr<int> _total; | ||
|
||
void set_batch_info(int current, int total) | ||
{ | ||
if (!_current) { | ||
_current = std::make_shared<int>(); | ||
_total = std::make_shared<int>(); | ||
} | ||
*_current = current; | ||
*_total = total; | ||
} | ||
|
||
int is_first_in_batch() | ||
{ | ||
return *_current == 0; | ||
} | ||
|
||
int is_last_in_batch() | ||
{ | ||
return *_current == (*_total - 1); | ||
} | ||
|
||
} // namespace turbomind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include <cstdio> | ||
|
||
namespace turbomind { | ||
|
||
void set_batch_info(int current, int total); | ||
|
||
int is_first_in_batch(); | ||
|
||
int is_last_in_batch(); | ||
|
||
} // namespace turbomind |