MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / fill_layer_data

Method fill_layer_data

tests/AssetsLibrary.h:1028–1061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026
1027template <typename T>
1028void AssetsLibrary::fill_layer_data(T &&tensor, std::string name) const
1029{
1030#ifdef _WIN32
1031 const std::string path_separator("\\");
1032#else /* _WIN32 */
1033 const std::string path_separator("/");
1034#endif /* _WIN32 */
1035 const std::string path = _library_path + path_separator + name;
1036
1037 // Open file
1038 std::ifstream stream(path, std::ios::in | std::ios::binary);
1039 if (!stream.good())
1040 {
1041 throw framework::FileNotFound("Could not load npy file: " + path);
1042 }
1043
1044 validate_npy_header(stream, tensor.data_type(), tensor.shape());
1045
1046 // Read data
1047 if (tensor.padding().empty())
1048 {
1049 // If tensor has no padding read directly from stream.
1050 stream.read(reinterpret_cast<char *>(tensor.data()), tensor.size());
1051 }
1052 else
1053 {
1054 // If tensor has padding accessing tensor elements through execution window.
1055 Window window;
1056 window.use_tensor_dimensions(tensor.shape());
1057
1058 execute_window_loop(window, [&](const Coordinates &id)
1059 { stream.read(reinterpret_cast<char *>(tensor(id)), tensor.element_size()); });
1060 }
1061}
1062
1063template <typename T, typename D>
1064void AssetsLibrary::fill_tensor_value(T &&tensor, D value) const

Callers

nothing calls this directly

Calls 10

FileNotFoundClass · 0.85
validate_npy_headerFunction · 0.85
readMethod · 0.80
data_typeMethod · 0.45
shapeMethod · 0.45
emptyMethod · 0.45
paddingMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
element_sizeMethod · 0.45

Tested by

no test coverage detected