| 242 | ] |
| 243 | |
| 244 | def benchmarkQROp(self): |
| 245 | for shape_ in self.shapes: |
| 246 | with ops.Graph().as_default(), \ |
| 247 | session.Session(config=benchmark.benchmark_config()) as sess, \ |
| 248 | ops.device("/cpu:0"): |
| 249 | matrix_value = np.random.uniform( |
| 250 | low=-1.0, high=1.0, size=shape_).astype(np.float32) |
| 251 | matrix = variables.Variable(matrix_value) |
| 252 | q, r = linalg_ops.qr(matrix) |
| 253 | variables.global_variables_initializer().run() |
| 254 | self.run_op_benchmark( |
| 255 | sess, |
| 256 | control_flow_ops.group(q, r), |
| 257 | min_iters=25, |
| 258 | name="QR_cpu_{shape}".format(shape=shape_)) |
| 259 | |
| 260 | if test.is_gpu_available(True): |
| 261 | with ops.Graph().as_default(), \ |
| 262 | session.Session(config=benchmark.benchmark_config()) as sess, \ |
| 263 | ops.device("/device:GPU:0"): |
| 264 | matrix_value = np.random.uniform( |
| 265 | low=-1.0, high=1.0, size=shape_).astype(np.float32) |
| 266 | matrix = variables.Variable(matrix_value) |
| 267 | q, r = linalg_ops.qr(matrix) |
| 268 | variables.global_variables_initializer().run() |
| 269 | self.run_op_benchmark( |
| 270 | sess, |
| 271 | control_flow_ops.group(q, r), |
| 272 | min_iters=25, |
| 273 | name="QR_gpu_{shape}".format(shape=shape_)) |
| 274 | |
| 275 | |
| 276 | if __name__ == "__main__": |