Skip to content

Commit 81ac3a6

Browse files
committed
fix doc and code format
1 parent 99661bd commit 81ac3a6

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

python/paddle/profiler/profiler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,14 @@ class Profiler:
326326
327327
import paddle
328328
import paddle.profiler as profiler
329-
import numpy as np
330329
331330
class RandomDataset(paddle.io.Dataset):
332331
def __init__(self, num_samples):
333332
self.num_samples = num_samples
334333
335334
def __getitem__(self, idx):
336-
image = np.random.random([100]).astype('float32')
337-
label = np.random.randint(0, 10 - 1, (1, )).astype('int64')
335+
image = paddle.rand(shape=[100], dtype='float32')
336+
label = paddle.randint(0, 10, shape=[1], dtype='int64')
338337
return image, label
339338
340339
def __len__(self):
@@ -534,7 +533,7 @@ def step(self, num_samples: Optional[int]=None):
534533
535534
Args:
536535
num_samples (int|None, optional): Specifies the batch size of every step of the model
537-
that is used to compute throughput when timer_only is True. Default: None.
536+
that is used to compute throughput when timer_only is True. Default: None.
538537
539538
Examples:
540539
.. code-block:: python
@@ -584,11 +583,12 @@ def step_info(self, unit=None):
584583
585584
Args:
586585
unit (string, optional): The unit of input data is only used When `num_samples`
587-
of `step()` is specified as a number. For example, when it is `images`, the unit
588-
of throughput is `images/s`. Default: None, the unit of throughput is `samples/s`.
586+
of `step()` is specified as a number. For example, when it is `images`, the unit
587+
of throughput is `images/s`. Default: None, the unit of throughput is `samples/s`.
589588
590589
Returns:
591590
string: A string representing the statistic.
591+
592592
Examples:
593593
.. code-block:: python
594594
:name: code-example-timer2

python/paddle/profiler/timer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class TimerHook(Hook):
175175
A hook for recording real-time performance and the summary
176176
performance of total steps.
177177
"""
178+
178179
def __init__(self):
179180
self.start_time = timeit.default_timer()
180181
self.start_reader = timeit.default_timer()
@@ -409,7 +410,7 @@ def check_if_need_record(self, reader):
409410
self.current_event.need_record = True
410411
self.hooks['timer_hook'].start_time = timeit.default_timer()
411412

412-
413+
413414
_benchmark_ = Benchmark()
414415

415416

0 commit comments

Comments
 (0)