ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Reduction.h
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 #pragma once
9 
10 #include <Helper.h>
11 #include <Logging.h>
12 
13 #include <unordered_set>
14 
17 
18 namespace cloudViewer {
19 namespace core {
20 namespace kernel {
21 
22 enum class ReductionOpCode {
23  Sum,
24  Prod,
25  Min,
26  Max,
27  ArgMin,
28  ArgMax,
29  All,
30  Any,
31 };
32 
33 static const std::unordered_set<ReductionOpCode, utility::hash_enum_class>
39 };
40 static const std::unordered_set<ReductionOpCode, utility::hash_enum_class>
44 };
45 static const std::unordered_set<ReductionOpCode, utility::hash_enum_class>
49 };
50 
51 void Reduction(const Tensor& src,
52  Tensor& dst,
53  const SizeVector& dims,
54  bool keepdim,
55  ReductionOpCode op_code);
56 
57 void ReductionCPU(const Tensor& src,
58  Tensor& dst,
59  const SizeVector& dims,
60  bool keepdim,
61  ReductionOpCode op_code);
62 
63 #ifdef BUILD_SYCL_MODULE
64 void ReductionSYCL(const Tensor& src,
65  Tensor& dst,
66  const SizeVector& dims,
67  bool keepdim,
68  ReductionOpCode op_code);
69 #endif
70 
71 #ifdef BUILD_CUDA_MODULE
72 void ReductionCUDA(const Tensor& src,
73  Tensor& dst,
74  const SizeVector& dims,
75  bool keepdim,
76  ReductionOpCode op_code);
77 #endif
78 
79 } // namespace kernel
80 } // namespace core
81 } // namespace cloudViewer
Helper functions for the ml ops.
void ReductionSYCL(const Tensor &src, Tensor &dst, const SizeVector &dims, bool keepdim, ReductionOpCode op_code)
static const std::unordered_set< ReductionOpCode, utility::hash_enum_class > s_arg_reduce_ops
Definition: Reduction.h:41
void ReductionCPU(const Tensor &src, Tensor &dst, const SizeVector &dims, bool keepdim, ReductionOpCode op_code)
static const std::unordered_set< ReductionOpCode, utility::hash_enum_class > s_regular_reduce_ops
Definition: Reduction.h:34
void Reduction(const Tensor &src, Tensor &dst, const SizeVector &dims, bool keepdim, ReductionOpCode op_code)
Definition: Reduction.cpp:16
static const std::unordered_set< ReductionOpCode, utility::hash_enum_class > s_boolean_reduce_ops
Definition: Reduction.h:46
Generic file read and write utility for python interface.