MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / get_array_interface

Function get_array_interface

python/cpp/storage_view.cc:87–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85 }
86
87 static py::dict get_array_interface(const StorageView& view) {
88 py::tuple shape(view.rank());
89 for (size_t i = 0; i < shape.size(); ++i)
90 shape[i] = view.dim(i);
91
92 return py::dict(
93 "shape"_a=shape,
94 "typestr"_a=dtype_to_typestr(view.dtype()),
95 "data"_a=py::make_tuple((uintptr_t)view.buffer(), false),
96 "version"_a=3);
97 }
98
99 void register_storage_view(py::module& m) {
100 py::enum_<DataType>(m, "DataType")

Callers 1

register_storage_viewFunction · 0.85

Calls 6

dtype_to_typestrFunction · 0.85
rankMethod · 0.80
dimMethod · 0.80
bufferMethod · 0.80
sizeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected