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

Method test_seqlen_fp32

tests/bert/th_bert_unit_test.py:120–138  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

118 self.assertTrue(max_diff < self.threshold[args_dict['data_type']])
119
120 def test_seqlen_fp32(self):
121 args_dict = copy.deepcopy(self.common_args_dict)
122
123 for seqlen in [32, 130, 511, 1024, 1536]:
124 args_dict['seq_len'] = seqlen
125 if seqlen == 1536:
126 args_dict['layer_num'] = 6
127
128 threshold_tmp = {'fp32': 1e-4, 'fp16': 4e-2, 'bf16': 5e-2} # The error of encoder on this test is larger
129
130 os.system("./bin/bert_gemm {} {} {} {} {} 0 > .tmp.gemm.log && cat gemm_config.in".format(args_dict['batch_size'], args_dict['seq_len'],
131 args_dict['head_num'], args_dict['head_size'],
132 args_dict['data_type'] == 'fp16'))
133 max_diff = bert_example(args_dict)
134 sys.stdout.flush()
135 self.assertTrue(max_diff < threshold_tmp[args_dict['data_type']])
136 max_diff = encoder_example(args_dict)
137 sys.stdout.flush()
138 self.assertTrue(max_diff < threshold_tmp[args_dict['data_type']])
139
140 def test_seqlen_fp16(self):
141 args_dict = copy.deepcopy(self.common_args_dict)

Callers

nothing calls this directly

Calls 2

bert_exampleFunction · 0.90
encoder_exampleFunction · 0.90

Tested by

no test coverage detected