Rerun C++ SDK
Loading...
Searching...
No Matches
tensor_data.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/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 arrow {
14 class Array;
15 class DataType;
16 class StructBuilder;
17} // namespace arrow
18
19namespace rerun::components {
20 /// **Component**: A multi-dimensional `Tensor` with optionally named arguments.
21 struct TensorData {
23
24 public:
25 // Extensions to generated type defined in 'tensor_data_ext.cpp'
26
27 /// New tensor data from shape and tensor buffer.
28 ///
29 /// \param shape Shape of the tensor.
30 /// \param buffer The tensor buffer containing the tensor's data.
34 )
35 : data(rerun::datatypes::TensorData(std::move(shape), std::move(buffer))) {}
36
37 /// New tensor data from dimensions and pointer to tensor data.
38 ///
39 /// Type must be one of the types supported by `rerun::datatypes::TensorData`.
40 /// \param shape Shape of the tensor. Determines the number of elements expected to be in `data_`.
41 /// \param data_ Target of the pointer must outlive the archetype.
42 template <typename TElement>
43 explicit TensorData(Collection<datatypes::TensorDimension> shape, const TElement* data_)
44 : data(rerun::datatypes::TensorData(std::move(shape), data_)) {}
45
46 public:
47 TensorData() = default;
48
49 TensorData(rerun::datatypes::TensorData data_) : data(std::move(data_)) {}
50
52 data = std::move(data_);
53 return *this;
54 }
55
56 /// Cast to the underlying TensorData datatype
58 return data;
59 }
60 };
61} // namespace rerun::components
62
63namespace rerun {
64 template <typename T>
65 struct Loggable;
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
75 /// Fills an arrow array builder with an array of this type.
76 static rerun::Error fill_arrow_array_builder(
77 arrow::StructBuilder* builder, const components::TensorData* elements,
78 size_t num_elements
79 );
80
81 /// Serializes an array of `rerun::components::TensorData` into an arrow array.
82 static Result<std::shared_ptr<arrow::Array>> to_arrow(
83 const components::TensorData* instances, size_t num_instances
84 );
85 };
86} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:47
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:87
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:69
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Component: A multi-dimensional Tensor with optionally named arguments.
Definition tensor_data.hpp:21
TensorData(Collection< datatypes::TensorDimension > shape, const TElement *data_)
New tensor data from dimensions and pointer to tensor data.
Definition tensor_data.hpp:43
TensorData(rerun::Collection< rerun::datatypes::TensorDimension > shape, rerun::datatypes::TensorBuffer buffer)
New tensor data from shape and tensor buffer.
Definition tensor_data.hpp:31
Datatype: The underlying storage for a Tensor.
Definition tensor_buffer.hpp:93
Datatype: A multi-dimensional Tensor of data.
Definition tensor_data.hpp:29