MCPcopy Create free account
hub / github.com/apache/arrow / garrow_tensor_new

Function garrow_tensor_new

c_glib/arrow-glib/tensor.cpp:171–202  ·  view source on GitHub ↗

* garrow_tensor_new: * @data_type: A #GArrowDataType that indicates each element type * in the tensor. * @data: A #GArrowBuffer that contains tensor data. * @shape: (array length=n_dimensions): A list of dimension sizes. * @n_dimensions: The number of dimensions. * @strides: (array length=n_strides) (nullable): A list of the number of * bytes in each dimension. * @n_strides: The number

Source from the content-addressed store, hash-verified

169 * Since: 0.3.0
170 */
171GArrowTensor *
172garrow_tensor_new(GArrowDataType *data_type,
173 GArrowBuffer *data,
174 gint64 *shape,
175 gsize n_dimensions,
176 gint64 *strides,
177 gsize n_strides,
178 gchar **dimension_names,
179 gsize n_dimension_names)
180{
181 auto arrow_data_type = garrow_data_type_get_raw(data_type);
182 auto arrow_data = garrow_buffer_get_raw(data);
183 std::vector<int64_t> arrow_shape;
184 for (gsize i = 0; i < n_dimensions; ++i) {
185 arrow_shape.push_back(shape[i]);
186 }
187 std::vector<int64_t> arrow_strides;
188 for (gsize i = 0; i < n_strides; ++i) {
189 arrow_strides.push_back(strides[i]);
190 }
191 std::vector<std::string> arrow_dimension_names;
192 for (gsize i = 0; i < n_dimension_names; ++i) {
193 arrow_dimension_names.push_back(dimension_names[i]);
194 }
195 auto arrow_tensor = std::make_shared<arrow::Tensor>(arrow_data_type,
196 arrow_data,
197 arrow_shape,
198 arrow_strides,
199 arrow_dimension_names);
200 auto tensor = garrow_tensor_new_raw_buffer(&arrow_tensor, data);
201 return tensor;
202}
203
204/**
205 * garrow_tensor_equal:

Callers

nothing calls this directly

Calls 4

garrow_data_type_get_rawFunction · 0.85
garrow_buffer_get_rawFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected