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

Function garrow_tensor_get_shape

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

* garrow_tensor_get_shape: * @tensor: A #GArrowTensor. * @n_dimensions: (out): The number of dimensions. * * Returns: (array length=n_dimensions) (transfer full): * The shape of the tensor. * * It should be freed with g_free() when no longer needed. * * Since: 0.3.0 */

Source from the content-addressed store, hash-verified

286 * Since: 0.3.0
287 */
288gint64 *
289garrow_tensor_get_shape(GArrowTensor *tensor, gint *n_dimensions)
290{
291 auto arrow_tensor = garrow_tensor_get_raw(tensor);
292 auto arrow_shape = arrow_tensor->shape();
293 auto n_dimensions_raw = arrow_shape.size();
294 auto shape = static_cast<gint64 *>(g_malloc_n(sizeof(gint64), n_dimensions_raw));
295 for (gsize i = 0; i < n_dimensions_raw; ++i) {
296 shape[i] = arrow_shape[i];
297 }
298 *n_dimensions = static_cast<gint>(n_dimensions_raw);
299 return shape;
300}
301
302/**
303 * garrow_tensor_get_strides:

Callers

nothing calls this directly

Calls 3

garrow_tensor_get_rawFunction · 0.85
shapeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected