ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Zeros.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include <benchmark/benchmark.h>
9 
12 
13 namespace cloudViewer {
14 namespace core {
15 
16 void Zeros(benchmark::State& state, const Device& device) {
17  int64_t large_dim = (1ULL << 27) + 10;
18  SizeVector shape{2, large_dim};
19 
20  Tensor warm_up = Tensor::Zeros(shape, core::Float32, device);
21  (void)warm_up;
22  for (auto _ : state) {
23  Tensor dst = Tensor::Zeros(shape, core::Float32, device);
24  cuda::Synchronize(device);
25  }
26 }
27 
28 BENCHMARK_CAPTURE(Zeros, CPU, Device("CPU:0"))->Unit(benchmark::kMillisecond);
29 
30 #ifdef BUILD_CUDA_MODULE
31 BENCHMARK_CAPTURE(Zeros, CUDA, Device("CUDA:0"))->Unit(benchmark::kMillisecond);
32 #endif
33 
34 } // namespace core
35 } // namespace cloudViewer
Common CUDA utilities.
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Definition: Tensor.cpp:406
BENCHMARK_CAPTURE(BinaryEW, Add__CPU_Int8__100, 100, BinaryOpCode::Add, Int8, Device("CPU:0")) -> Unit(benchmark::kMillisecond)
void Zeros(benchmark::State &state, const Device &device)
Definition: Zeros.cpp:16
const Dtype Float32
Definition: Dtype.cpp:42
Generic file read and write utility for python interface.