MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / __get_strides

Function __get_strides

external/ggml/examples/python/ggml/utils.py:129–129  ·  view source on GitHub ↗
(x: TensorLike)

Source from the content-addressed store, hash-verified

127def __get_type(tensor: TensorLike): return __dtype_to_type(tensor.dtype) if isinstance(tensor, np.ndarray) else tensor.type
128def __get_shape(x: TensorLike): return x.shape if isinstance(x, np.ndarray) else tuple([x.ne[i] for i in range(x.n_dims)])
129def __get_strides(x: TensorLike): return x.strides if isinstance(x, np.ndarray) else tuple([x.nb[i] for i in range(x.n_dims)])
130def __get_data(x: TensorLike) -> ffi.CData: return ffi.from_buffer(x) if isinstance(x, np.ndarray) else lib.ggml_get_data(x)
131def __get_nbytes(tensor: TensorLike): return tensor.nbytes if isinstance(tensor, np.ndarray) else lib.ggml_nbytes(tensor)
132def __get_nelements(tensor: TensorLike): return tensor.size if isinstance(tensor, np.ndarray) else lib.ggml_nelements(tensor)

Callers 1

__expect_same_layoutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected