Skip to content

Commit fedfd0d

Browse files
committed
[master] update printing
1 parent 5133b8d commit fedfd0d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

jacinle/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from jacinle.utils.naming import class_name, func_name, method_name, class_name_of_method
5050
from jacinle.utils.network import get_local_addr
5151
from jacinle.utils.numeric import safe_sum, mean, std, rms, prod, divup
52-
from jacinle.utils.printing import indent_text, stprint, stformat, kvprint, kvformat, print_to_string
52+
from jacinle.utils.printing import indent_text, stprint, stformat, kvprint, kvformat, print_to_string, print_to
5353
from jacinle.utils.tqdm import get_current_tqdm, tqdm, tqdm_pbar, tqdm_gofor, tqdm_zip
5454

5555
from jacinle import io

jacinle/utils/printing.py

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import numpy as np
1414
import collections
15+
import contextlib
1516

1617
import threading
1718
from .registry import LockRegistry
@@ -194,6 +195,13 @@ def print_to_string(target='STDOUT'):
194195
return PrintToStringContext(target, need_lock=True)
195196

196197

198+
@contextlib.contextmanager
199+
def print_to(print_func, target='STDOUT'):
200+
with PrintToStringContext(target, need_lock=True) as ctx:
201+
yield
202+
print_func(ctx.get())
203+
204+
197205
def print2format(print_func):
198206
def format_func(*args, **kwargs):
199207
f = io.StringIO()

jactorch/nn/cnn/functional.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ConvPaddingMode(JacEnum):
2222
DEFAULT = 'default'
2323
VALID = 'valid'
2424
SAME = 'same'
25+
TENSORFLOW = 'tensorflow'
2526

2627

2728
class ConvBorderMode(JacEnum):

0 commit comments

Comments
 (0)