MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / tensor_is_contiguous

Function tensor_is_contiguous

examples/quantize-stats/quantize-stats.cpp:134–142  ·  view source on GitHub ↗

copied from ggml.h - verify that we can access this as a flat array

Source from the content-addressed store, hash-verified

132
133// copied from ggml.h - verify that we can access this as a flat array
134static bool tensor_is_contiguous(const struct ggml_tensor * tensor) {
135 static_assert(GGML_MAX_DIMS == 4, "GGML_MAX_DIMS is not 4 - update this function");
136
137 return
138 tensor->nb[0] == ggml_type_size(tensor->type) &&
139 tensor->nb[1] == (tensor->nb[0]*tensor->ne[0])/ggml_blck_size(tensor->type) &&
140 tensor->nb[2] == tensor->nb[1]*tensor->ne[1] &&
141 tensor->nb[3] == tensor->nb[2]*tensor->ne[2];
142}
143
144static void test_roundtrip_on_chunk(
145 const ggml_tensor * layer, int64_t offset, int64_t chunk_size, const ggml_type_traits_t & qfns, bool use_reference,

Callers 1

test_roundtrip_on_layerFunction · 0.70

Calls 2

ggml_type_sizeFunction · 0.50
ggml_blck_sizeFunction · 0.50

Tested by 1

test_roundtrip_on_layerFunction · 0.56