MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / time_test

Function time_test

examples/tensorflow/bert/utils/common.py:75–88  ·  view source on GitHub ↗
(sess, tensor, iterations=100, warmup=True)

Source from the content-addressed store, hash-verified

73 return tf.truncated_normal_initializer(stddev=initializer_range, dtype=data_type)
74
75def time_test(sess, tensor, iterations=100, warmup=True):
76 # return in ms
77
78 # warmup
79 if warmup == True:
80 for i in range(iterations):
81 sess.run(tensor)
82
83 t1 = datetime.now()
84 for i in range(iterations):
85 sess.run(tensor)
86 t2 = datetime.now()
87 time_sum = (t2 - t1).total_seconds()
88 return time_sum * 1000 / iterations
89
90def cross_check(name, tf_val, op_val, atol_threshold):
91 abs_diff = np.fabs(tf_val - op_val)

Callers 4

encoder_exampleFunction · 0.90
runFunction · 0.90
bert_exampleFunction · 0.90
runFunction · 0.90

Calls 1

runMethod · 0.45

Tested by

no test coverage detected