提交 46be0990 编写于 作者: S Sergei Lebedev 提交者: TensorFlower Gardener

Added benchmarks for tf.convert_to_tensor and tf.constant performance issues

PiperOrigin-RevId: 257596912
上级 a1501b00
......@@ -935,6 +935,26 @@ class MicroBenchmarks(test.Benchmark):
self._run(fn, 10000)
def benchmark_convert_3x_list_to_tensor(self):
xs = [1, 2, 3]
self._run(lambda: ops.convert_to_tensor(xs), 1000)
def benchmark_convert_3x_array_to_tensor(self):
xs = np.array([1, 2, 3], dtype=np.int32)
self._run(lambda: ops.convert_to_tensor(xs), 1000)
def benchmark_constant_40x2_list_to_tensor(self):
xs = [[0] * 2] * 40
self._run(lambda: constant_op.constant(xs), 1000)
def benchmark_constant_40x2_array_to_tensor(self):
xs = np.array([[0] * 2] * 40, dtype=np.int32)
self._run(lambda: constant_op.constant(xs), 1000)
def benchmark_constant_40x_list_of_2x_arrays_to_tensor(self):
xs = [np.array([0] * 2, dtype=np.int32)] * 40
self._run(lambda: constant_op.constant(xs), 1000)
def _benchmarkFunctionWithResourceInputs(self, num_resources, num_iters):
@def_function.function
def add_all(*args):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册