apeforest commented on a change in pull request #17449: Implemented large tensor flag for opperf testing URL: https://github.com/apache/incubator-mxnet/pull/17449#discussion_r373707500
##########
File path: benchmark/opperf/nd_operations/nn_conv_operators.py
##########
@@ -60,131 +81,286 @@ def run_pooling_operators_benchmarks(ctx=mx.cpu(),
dtype='float32', profiler='na
pool2d_benchmark_res = []
for pool_type in pool_types:
for global_pool in global_pool_types:
- for pool1d_data in [(32, 3, 256), (32, 3, 64)]:
- pool1d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Pooling")],
- run_backward=True,
- dtype=dtype,
- ctx=ctx,
- profiler=profiler,
- inputs=[{"data":
pool1d_data,
-
"kernel": 3,
-
"pool_type": pool_type,
-
"global_pool": global_pool,
-
"stride": 1,
- "pad": 1}
- ],
- warmup=warmup,
- runs=runs)
- for pool2d_data in [(32, 3, 256, 256), (32, 3, 64, 64)]:
- pool2d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Pooling")],
- run_backward=True,
- dtype=dtype,
- ctx=ctx,
- profiler=profiler,
- inputs=[{"data":
pool2d_data,
-
"kernel": (3, 3),
-
"pool_type": pool_type,
-
"global_pool": global_pool,
-
"stride": (1, 1),
- "pad":
(0, 0)}
- ],
- warmup=warmup,
- runs=runs)
+ if large_tensor == 'on':
+ for pool1d_data in [(1, 1, 2**32), (2**31, 1, 3)]:
+ pool1d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Pooling")],
+
run_backward=True,
+ dtype=dtype,
+ ctx=ctx,
+
profiler=profiler,
+
inputs=[{"data": pool1d_data,
+
"kernel": 3,
+
"pool_type": pool_type,
+
"global_pool": global_pool,
+
"stride": 1,
+
"pad": 1}
+ ],
+ warmup=warmup,
+ runs=runs)
+ for pool2d_data in [(2**29, 1, 3, 3), (2**28, 1, 4, 4)]:
+ pool2d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Pooling")],
+
run_backward=True,
+ dtype=dtype,
+ ctx=ctx,
+
profiler=profiler,
+
inputs=[{"data": pool2d_data,
+
"kernel": (3, 3),
+
"pool_type": pool_type,
+
"global_pool": global_pool,
+
"stride": (1, 1),
+
"pad": (0, 0)}
+ ],
+ warmup=warmup,
+ runs=runs)
+ else:
+ for pool1d_data in [(32, 3, 256), (32, 3, 64)]:
+ pool1d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Pooling")],
+
run_backward=True,
+ dtype=dtype,
+ ctx=ctx,
+
profiler=profiler,
+
inputs=[{"data": pool1d_data,
+
"kernel": 3,
+
"pool_type": pool_type,
+
"global_pool": global_pool,
+
"stride": 1,
+
"pad": 1}
+ ],
+ warmup=warmup,
+ runs=runs)
+ for pool2d_data in [(32, 3, 256, 256), (32, 3, 64, 64)]:
+ pool2d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Pooling")],
+
run_backward=True,
+ dtype=dtype,
+ ctx=ctx,
+
profiler=profiler,
+
inputs=[{"data": pool2d_data,
+
"kernel": (3, 3),
+
"pool_type": pool_type,
+
"global_pool": global_pool,
+
"stride": (1, 1),
+
"pad": (0, 0)}
+ ],
+ warmup=warmup,
+ runs=runs)
# Prepare combined results
mx_pooling_op_results = merge_map_list(pool1d_benchmark_res +
pool2d_benchmark_res)
return mx_pooling_op_results
-def run_convolution_operators_benchmarks(ctx=mx.cpu(), dtype='float32',
profiler='native', warmup=25, runs=100):
- # Conv1D Benchmarks
+def run_convolution_operators_benchmarks(ctx=mx.cpu(), dtype='float32',
profiler='native', large_tensor='off', warmup=25, runs=100):
+ """Runs benchmarks with the given context, precision (dtype), and input
data size (large_tensor) for all the convolution
+ operators in MXNet.
+
+ Parameters
+ ----------
+ ctx: mx.ctx
+ Context to run benchmarks
+ dtype: str, default 'float32'
+ Precision to use for benchmarks
+ large_tensor: str, default 'off'
+ Tensor size to use for tests
+ warmup: int, default 25
+ Number of times to run for warmup
+ runs: int, default 100
+ Number of runs to capture benchmark results
+
+ Returns
+ -------
+ Dictionary of results. Key -> Name of the operator, Value -> Benchmark
results.
+
+ """
conv1d_benchmark_res = []
- for conv_data in [(32, 3, 256), (32, 3, 64)]:
- conv1d_benchmark_res += run_performance_test([getattr(MX_OP_MODULE,
"Convolution")],
- run_backward=True,
- dtype=dtype,
- ctx=ctx,
- profiler=profiler,
- inputs=[{"data":
conv_data,
- "weight": (64,
3, 3),
- "bias": (64,),
- "kernel": (3,),
- "stride": (1,),
- "dilate": (1,),
- "pad": (0,),
- "num_filter": 64,
- "layout": 'NCW'}
- ],
- warmup=warmup,
- runs=runs)
- # Conv2D Benchmarks
conv2d_benchmark_res = []
- for conv_data in [(32, 3, 256, 256), (32, 3, 64, 64)]:
- conv2d_benchmark_res += run_performance_test([getattr(MX_OP_MODULE,
"Convolution")],
- run_backward=True,
- dtype=dtype,
- ctx=ctx,
- profiler=profiler,
- inputs=[{"data":
conv_data,
- "weight": (64,
3, 3, 3),
- "bias": (64,),
- "kernel": (3, 3),
- "stride": (1, 1),
- "dilate": (1, 1),
- "pad": (0, 0),
- "num_filter": 64,
- "layout": 'NCHW'}
- ],
- warmup=warmup,
- runs=runs)
+ if large_tensor == 'on':
+ # Conv1D Benchmarks
+ for conv_data in [(2**30, 1, 4), (2**31, 1, 3)]:
+ conv1d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Convolution")],
+ run_backward=True,
+ dtype=dtype,
+ ctx=ctx,
+ profiler=profiler,
+ inputs=[{"data":
conv_data,
+ "weight":
(1, 1, 3),
+ "bias": (1,),
+ "kernel":
(3,),
+ "stride":
(1,),
+ "dilate":
(1,),
+ "pad": (0,),
+
"num_filter": 1,
+ "layout":
'NCW'}
+ ],
+ warmup=warmup,
+ runs=runs)
+ # Conv2D Benchmarks
+ for conv_data in [(2**29, 1, 3, 3), (2**28, 1, 4, 4)]:
+ conv2d_benchmark_res +=
run_performance_test([getattr(MX_OP_MODULE, "Convolution")],
+ run_backward=True,
+ dtype=dtype,
+ ctx=ctx,
+ profiler=profiler,
+ inputs=[{"data":
conv_data,
+ "weight":
(1, 1, 3, 3),
+ "bias": (1,),
+ "kernel":
(3, 3),
+ "stride":
(1, 1),
+ "dilate":
(1, 1),
+ "pad": (0,
0),
+
"num_filter": 1,
+ "layout":
'NCHW'}
+ ],
+ warmup=warmup,
+ runs=runs)
+ else:
Review comment:
It seems the only difference between the if and else branch is the `inputs`
argument. Can we only generate different inputs in the if/else branch and pass
them to the same operator function?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
