Rerun C++ SDK
Loading...
Searching...
No Matches
tensor_data.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/components/tensor_data.fbs".
3
4#pragma once
5
6#include "../datatypes/tensor_data.hpp"
7#include "../result.hpp"
8
9#include <cstdint>
10#include <memory>
11#include <utility>
12
13namespace rerun::components {
14 /// **Component**: An N-dimensional array of numbers.
15 ///
16 /// The number of dimensions and their respective lengths is specified by the `shape` field.
17 /// The dimensions are ordered from outermost to innermost. For example, in the common case of
18 /// a 2D RGB Image, the shape would be `[height, width, channel]`.
19 ///
20 /// These dimensions are combined with an index to look up values from the `buffer` field,
21 /// which stores a contiguous array of typed values.
22 struct TensorData {
24
25 public: // START of extensions from tensor_data_ext.cpp:
26 /// New tensor data from shape and tensor buffer.
27 ///
28 /// \param shape Shape of the tensor.
29 /// \param buffer The tensor buffer containing the tensor's data.
33 )
34 : data(rerun::datatypes::TensorData(std::move(shape), std::move(buffer))) {}
35
36 /// New tensor data from dimensions and pointer to tensor data.
37 ///
38 /// Type must be one of the types supported by `rerun::datatypes::TensorData`.
39 /// \param shape Shape of the tensor. Determines the number of elements expected to be in `data_`.
40 /// \param data_ Target of the pointer must outlive the archetype.
41 template <typename TElement>
42 explicit TensorData(Collection<datatypes::TensorDimension> shape, const TElement* data_)
43 : data(rerun::datatypes::TensorData(std::move(shape), data_)) {}
44
45 // END of extensions from tensor_data_ext.cpp, start of generated code:
46
47 public:
48 TensorData() = default;
49
50 TensorData(rerun::datatypes::TensorData data_) : data(std::move(data_)) {}
51
53 data = std::move(data_);
54 return *this;
55 }
56
57 /// Cast to the underlying TensorData datatype
59 return data;
60 }
61 };
62} // namespace rerun::components
63
64namespace rerun {
65 static_assert(sizeof(rerun::datatypes::TensorData) == sizeof(components::TensorData));
66
67 /// \private
68 template <>
69 struct Loggable<components::TensorData> {
70 static constexpr const char Name[] = "rerun.components.TensorData";
71
72 /// Returns the arrow data type this type corresponds to.
73 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
74 return Loggable<rerun::datatypes::TensorData>::arrow_datatype();
75 }
76
77 /// Serializes an array of `rerun::components::TensorData` into an arrow array.
78 static Result<std::shared_ptr<arrow::Array>> to_arrow(
79 const components::TensorData* instances, size_t num_instances
80 ) {
81 if (num_instances == 0) {
82 return Loggable<rerun::datatypes::TensorData>::to_arrow(nullptr, 0);
83 } else if (instances == nullptr) {
84 return rerun::Error(
85 ErrorCode::UnexpectedNullArgument,
86 "Passed array instances is null when num_elements> 0."
87 );
88 } else {
89 return Loggable<rerun::datatypes::TensorData>::to_arrow(
90 &instances->data,
91 num_instances
92 );
93 }
94 }
95 };
96} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: An N-dimensional array of numbers.
Definition tensor_data.hpp:22
TensorData(Collection< datatypes::TensorDimension > shape, const TElement *data_)
New tensor data from dimensions and pointer to tensor data.
Definition tensor_data.hpp:42
TensorData(rerun::Collection< rerun::datatypes::TensorDimension > shape, rerun::datatypes::TensorBuffer buffer)
New tensor data from shape and tensor buffer.
Definition tensor_data.hpp:30
Datatype: The underlying storage for archetypes::Tensor.
Definition tensor_buffer.hpp:98
Datatype: An N-dimensional array of numbers.
Definition tensor_data.hpp:29