ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Linalg.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 
13 
14 namespace cloudViewer {
15 namespace core {
16 
17 void MatmulAB(benchmark::State& state, const Device& device) {
18  Tensor A = Tensor::Ones({10000, 4}, core::Float32, device);
19  Tensor B = Tensor::Ones({4, 10000}, core::Float32, device);
20 
21  Tensor output = A.Matmul(B);
22  for (auto _ : state) {
23  output = A.Matmul(B);
25  }
26 }
27 
28 BENCHMARK_CAPTURE(MatmulAB, CPU, Device("CPU:0"))
29  ->Unit(benchmark::kMillisecond);
30 
31 #ifdef BUILD_CUDA_MODULE
32 BENCHMARK_CAPTURE(MatmulAB, CUDA, Device("CUDA:0"))
33  ->Unit(benchmark::kMillisecond);
34 #endif
35 
36 } // namespace core
37 } // namespace cloudViewer
Common CUDA utilities.
Tensor Matmul(const Tensor &rhs) const
Definition: Tensor.cpp:1919
static Tensor Ones(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with ones.
Definition: Tensor.cpp:412
BENCHMARK_CAPTURE(BinaryEW, Add__CPU_Int8__100, 100, BinaryOpCode::Add, Int8, Device("CPU:0")) -> Unit(benchmark::kMillisecond)
void MatmulAB(benchmark::State &state, const Device &device)
Definition: Linalg.cpp:17
const Dtype Float32
Definition: Dtype.cpp:42
Generic file read and write utility for python interface.