| 90 | |
| 91 | class SoftMaxWithLoss(Benchmark): |
| 92 | def run(self): |
| 93 | op = core.CreateOperator( |
| 94 | "SoftmaxWithLoss", |
| 95 | ["X", "label"], |
| 96 | ["probs", "avgloss"], |
| 97 | ) |
| 98 | |
| 99 | for n in itertools.imap(pow, itertools.cycle([10]), range(8)): |
| 100 | for D in itertools.imap(pow, itertools.cycle([10]), range(3)): |
| 101 | X = np.random.rand(n, D).astype(np.float32) |
| 102 | label = (np.random.rand(n) * D).astype(np.int32) |
| 103 | logger.info('Running benchmark for n = {}, D= {}'.format(n, D)) |
| 104 | ret = runOpBenchmark(gpu_do, op, inputs=[X, label]) |
| 105 | self.results.append(((n, D), ret[1])) |
| 106 | |
| 107 | |
| 108 | def parse_args(): |