Open3D (C++ API)  0.19.0
Loading...
Searching...
No Matches
TensorKey.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2024 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8#pragma once
9
10#include <optional>
11
13
14namespace open3d {
15namespace core {
16
17// Avoids circular include.
18class Tensor;
19
20// Same as std::nullopt. Provides a similar Python slicing API.
21constexpr std::nullopt_t None = std::nullopt;
22
27class TensorKey {
28public:
38 static TensorKey Index(int64_t index);
39
51 static TensorKey Slice(std::optional<int64_t> start,
52 std::optional<int64_t> stop,
53 std::optional<int64_t> step);
54
66 static TensorKey IndexTensor(const Tensor& index_tensor);
67
70
72 TensorKeyMode GetMode() const;
73
75 std::string ToString() const;
76
77public:
80 int64_t GetIndex() const;
81
84 int64_t GetStart() const;
85
88 int64_t GetStop() const;
89
92 int64_t GetStep() const;
93
105 TensorKey InstantiateDimSize(int64_t dim_size) const;
106
109 Tensor GetIndexTensor() const;
110
111private:
112 class Impl;
113 class IndexImpl;
114 class SliceImpl;
115 class IndexTensorImpl;
116 std::shared_ptr<Impl> impl_;
117 TensorKey(const std::shared_ptr<Impl>& impl);
118};
119
120} // namespace core
121} // namespace open3d
Definition Tensor.h:32
TensorKey is used to represent single index, slice or advanced indexing on a Tensor.
Definition TensorKey.h:27
int64_t GetStart() const
Definition TensorKey.cpp:165
std::string ToString() const
Convert TensorKey to a string representation.
Definition TensorKey.cpp:141
int64_t GetIndex() const
Definition TensorKey.cpp:157
Tensor GetIndexTensor() const
Definition TensorKey.cpp:195
int64_t GetStop() const
Definition TensorKey.cpp:172
TensorKeyMode
Definition TensorKey.h:68
TensorKeyMode GetMode() const
Returns TensorKey mode.
Definition TensorKey.cpp:139
~TensorKey()
Definition TensorKey.h:69
TensorKey InstantiateDimSize(int64_t dim_size) const
Definition TensorKey.cpp:186
int64_t GetStep() const
Definition TensorKey.cpp:179
constexpr std::nullopt_t None
Definition TensorKey.h:21
Definition PinholeCameraIntrinsic.cpp:16