ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
BinaryEW.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 
16 
17 namespace cloudViewer {
18 namespace core {
19 namespace kernel {
20 
21 enum class BinaryEWOpCode {
22  Add,
23  Sub,
24  Mul,
25  Div,
26  Maximum,
27  Minimum,
28  LogicalAnd,
29  LogicalOr,
30  LogicalXor,
31  Gt,
32  Lt,
33  Ge,
34  Le,
35  Eq,
36  Ne,
37 };
38 
39 extern const std::unordered_set<BinaryEWOpCode, utility::hash_enum_class>
41 
42 void BinaryEW(const Tensor& lhs,
43  const Tensor& rhs,
44  Tensor& dst,
45  BinaryEWOpCode op_code);
46 
47 void BinaryEWCPU(const Tensor& lhs,
48  const Tensor& rhs,
49  Tensor& dst,
50  BinaryEWOpCode op_code);
51 
52 #ifdef BUILD_SYCL_MODULE
53 void BinaryEWSYCL(const Tensor& lhs,
54  const Tensor& rhs,
55  Tensor& dst,
56  BinaryEWOpCode op_code);
57 #endif
58 
59 #ifdef BUILD_CUDA_MODULE
60 void BinaryEWCUDA(const Tensor& lhs,
61  const Tensor& rhs,
62  Tensor& dst,
63  BinaryEWOpCode op_code);
64 #endif
65 
66 } // namespace kernel
67 } // namespace core
68 } // namespace cloudViewer
cloudViewer::core::BinaryEW
void BinaryEW(benchmark::State &state, int size, BinaryOpCode op_code, const Dtype &dtype, const Device &device)
Definition: BinaryEW.cpp:103
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::core::Tensor::GetDtype
Dtype GetDtype() const
Definition: Tensor.h:1164
ShapeUtil.h
Indexer.h
CUDAUtils.h
Common CUDA utilities.
cloudViewer::core::kernel::BinaryEWOpCode::Div
@ Div
cloudViewer::core::shape_util::BroadcastedShape
SizeVector BroadcastedShape(const SizeVector &l_shape, const SizeVector &r_shape)
Returns the broadcasted shape of two shapes.
Definition: ShapeUtil.cpp:56
cloudViewer::core::Tensor::GetLength
int64_t GetLength() const
Definition: Tensor.h:1125
Arange.h
cloudViewer::core::Tensor::GetShape
SizeVector GetShape() const
Definition: Tensor.h:1127
cloudViewer::core::MakeOperation
static std::function< Tensor(const Tensor &, const Tensor &)> MakeOperation(BinaryOpCode op)
Definition: BinaryEW.cpp:38
cloudViewer::core::BinaryOpCode::LogicalAnd
@ LogicalAnd
cloudViewer::core::kernel::ArangeCPU
void ArangeCPU(const Tensor &start, const Tensor &stop, const Tensor &step, Tensor &dst)
Definition: ArangeCPU.cpp:17
cloudViewer::core::IsDevice::IsCUDA
bool IsCUDA() const
Definition: Device.h:99
cloudViewer::core::BinaryOpCode::LogicalXor
@ LogicalXor
cloudViewer::core::kernel::BinaryEWOpCode::Maximum
@ Maximum
cloudViewer::core::kernel::BinaryEWOpCode::LogicalXor
@ LogicalXor
cloudViewer::core::kernel::BinaryEWOpCode::Minimum
@ Minimum
cloudViewer::core::BinaryOpCode::LogicalOr
@ LogicalOr
cloudViewer::core::kernel::BinaryEWCPU
void BinaryEWCPU(const Tensor &lhs, const Tensor &rhs, Tensor &dst, BinaryEWOpCode op_code)
Definition: BinaryEWCPU.cpp:154
cloudViewer::core::Tensor
Definition: Tensor.h:32
ENUM_BM_TENSOR
#define ENUM_BM_TENSOR(FN, OP)
Definition: BinaryEW.cpp:164
SYCLContext.h
SYCL queue manager.
cloudViewer::core::BinaryOpCode::Ge
@ Ge
cloudViewer::core::kernel::BinaryEWOpCode::Gt
@ Gt
cloudViewer::core::BinaryOpCode
BinaryOpCode
Definition: BinaryEW.cpp:22
cloudViewer::core::Dtype
Definition: Dtype.h:21
cloudViewer::core::Device::ToString
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition: Device.cpp:89
result
core::Tensor result
Definition: VtkUtils.cpp:76
size
int size
Definition: FileIOFactory.cpp:130
ParallelFor.h
Logging.h
cloudViewer::core::BinaryOpCode::Mul
@ Mul
cloudViewer::core::kernel::BinaryEWOpCode
BinaryEWOpCode
Definition: BinaryEW.h:21
cloudViewer::core::BinaryOpCode::Gt
@ Gt
Dispatch.h
cloudViewer::core::Device
Definition: Device.h:18
cloudViewer::core::kernel::BinaryEWSYCL
void BinaryEWSYCL(const Tensor &lhs, const Tensor &rhs, Tensor &dst, BinaryEWOpCode op_code)
Definition: BinaryEWSYCL.cpp:116
core
cloudViewer::core::Tensor::GetDevice
Device GetDevice() const override
Definition: Tensor.cpp:1435
cloudViewer::core::SizeVector
Definition: SizeVector.h:70
cloudViewer::core::kernel::BinaryEWOpCode::Sub
@ Sub
cloudViewer::core::kernel::BinaryEWOpCode::Ge
@ Ge
cloudViewer::benchmarks::Rand
core::Tensor Rand(const core::SizeVector &shape, size_t seed, const std::pair< core::Scalar, core::Scalar > &range, core::Dtype dtype, const core::Device &device)
Returns a Tensor with random values within the range range .
Definition: Rand.cpp:23
cloudViewer::core::BinaryOpCode::Le
@ Le
cloudViewer::core::kernel::BinaryEWOpCode::Eq
@ Eq
LogError
#define LogError(...)
Definition: Logging.h:60
DISPATCH_DTYPE_TO_TEMPLATE
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:31
cloudViewer::core::sy::SYCLContext::GetInstance
static SYCLContext & GetInstance()
Get singleton instance.
Definition: SYCLContext.cpp:25
cloudViewer::core::BinaryOpCode::Lt
@ Lt
cloudViewer::core::kernel::BinaryEWOpCode::Ne
@ Ne
cloudViewer::core::kernel::s_boolean_binary_ew_op_codes
const std::unordered_set< BinaryEWOpCode, utility::hash_enum_class > s_boolean_binary_ew_op_codes
Definition: BinaryEW.cpp:22
cloudViewer::core::IsDevice::IsCPU
bool IsCPU() const
Definition: Device.h:95
cloudViewer::core::kernel::BinaryEWOpCode::Mul
@ Mul
cloudViewer::core::Tensor::Item
T Item() const
Definition: Tensor.h:618
cloudViewer::core::kernel::BinaryEWOpCode::Add
@ Add
cloudViewer::core::BinaryOpCode::Div
@ Div
Rand.h
Tensor.h
cloudViewer::core::BinaryOpCode::Eq
@ Eq
ENUM_BM_TENSOR_WTIH_BOOL
#define ENUM_BM_TENSOR_WTIH_BOOL(FN, OP)
Definition: BinaryEW.cpp:172
cloudViewer::core::IsDevice::IsSYCL
bool IsSYCL() const
Definition: Device.h:103
cloudViewer::core::kernel::BinaryEW
void BinaryEW(const Tensor &lhs, const Tensor &rhs, Tensor &dst, BinaryEWOpCode op_code)
Definition: BinaryEW.cpp:30
cloudViewer::core::ParallelFor
void ParallelFor(const Device &device, int64_t n, const func_t &func)
Definition: ParallelFor.h:111
cloudViewer::core::BinaryOpCode::Add
@ Add
cloudViewer::core::kernel::BinaryEWOpCode::Le
@ Le
cloudViewer::core::Tensor::LogicalXor
Tensor LogicalXor(const Tensor &value) const
Definition: Tensor.cpp:1520
cloudViewer::core::cuda::Synchronize
void Synchronize()
Definition: CUDAUtils.cpp:59
BinaryEW.h
cloudViewer::core::sy::SYCLContext::GetDefaultQueue
sycl::queue GetDefaultQueue(const Device &device)
Get the default SYCL queue given an CloudViewer device.
Definition: SYCLContext.cpp:43
cloudViewer::core::kernel::BinaryEWOpCode::LogicalOr
@ LogicalOr
cloudViewer::core::BinaryOpCode::Sub
@ Sub
cloudViewer::core::kernel::ArangeSYCL
void ArangeSYCL(const Tensor &start, const Tensor &stop, const Tensor &step, Tensor &dst)
Definition: ArangeSYCL.cpp:17
cloudViewer::core::Tensor::GetDataPtr
T * GetDataPtr()
Definition: Tensor.h:1144
cloudViewer::core::BinaryOpCode::Neq
@ Neq
cloudViewer::core::kernel::BinaryEWOpCode::Lt
@ Lt
cloudViewer::core::kernel::BinaryEWOpCode::LogicalAnd
@ LogicalAnd