30 #include <unordered_map> 49 class TensorMap :
public std::unordered_map<std::string, core::Tensor> {
53 :
std::unordered_map<
std::string, core::Tensor>(),
54 primary_key_(primary_key) {}
63 template <
class InputIt>
64 TensorMap(
const std::string& primary_key, InputIt first, InputIt last)
65 :
std::unordered_map<
std::string, core::Tensor>(first, last),
66 primary_key_(primary_key) {
67 AssertPrimaryKeyInMapOrEmpty();
71 const std::unordered_map<std::string, core::Tensor>& tensor_map)
72 :
TensorMap(primary_key, tensor_map.begin(), tensor_map.end()) {}
75 std::initializer_list<value_type> init)
76 :
std::unordered_map<
std::string, core::Tensor>(init),
77 primary_key_(primary_key) {
78 AssertPrimaryKeyInMapOrEmpty();
83 :
std::unordered_map<
std::string, core::Tensor>(other),
84 primary_key_(other.primary_key_) {
85 AssertPrimaryKeyInMapOrEmpty();
90 :
std::unordered_map<
std::string, core::Tensor>(other),
91 primary_key_(other.primary_key_) {
92 AssertPrimaryKeyInMapOrEmpty();
115 void AssertPrimaryKeyInMapOrEmpty()
const;
118 int64_t GetPrimarySize()
const {
return at(primary_key_).GetLength(); }
122 return at(primary_key_).GetDevice();
126 std::string primary_key_;
void LogError(const char *format, const Args &... args)
Definition: Console.h:176
Definition: Optional.h:912
TensorMap(const std::string &primary_key, std::initializer_list< value_type > init)
Definition: TensorMap.h:74
TensorMap()
Definition: TensorMap.h:59
TensorMap(const std::string &primary_key, InputIt first, InputIt last)
Definition: TensorMap.h:64
TensorMap(const std::string &primary_key)
Create empty TensorMap and set primary key.
Definition: TensorMap.h:52
TensorMap & operator=(const TensorMap &)=default
bool Contains(const std::string &key) const
Definition: TensorMap.h:110
int count
Definition: FilePCD.cpp:61
Definition: PinholeCameraIntrinsic.cpp:35
TensorMap(const std::string &primary_key, const std::unordered_map< std::string, core::Tensor > &tensor_map)
Definition: TensorMap.h:70
TensorMap(const TensorMap &other)
Copy constructor performs a "shallow" copy of the Tensors.
Definition: TensorMap.h:82
std::string GetPrimaryKey() const
Returns the primary key of the TensorMap.
Definition: TensorMap.h:100
void AssertSizeSynchronized() const
Assert IsSizeSynchronized().
Definition: TensorMap.cpp:58
bool IsSizeSynchronized() const
Returns true if all tensors in the map have the same size.
Definition: TensorMap.cpp:41
TensorMap(TensorMap &&other)
Move constructor performs a "shallow" copy of the Tensors.
Definition: TensorMap.h:89
Definition: TensorMap.h:49