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

Function load_trained_data

utils/Utils.h:697–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695 */
696template <typename T>
697void load_trained_data(T &tensor, const std::string &filename)
698{
699 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&tensor, 1, DataType::F32);
700
701 std::ifstream fs;
702
703 try
704 {
705 fs.exceptions(std::ofstream::failbit | std::ofstream::badbit | std::ofstream::eofbit);
706 // Open file
707 fs.open(filename, std::ios::in | std::ios::binary);
708
709 if (!fs.good())
710 {
711 throw std::runtime_error("Could not load binary data: " + filename);
712 }
713
714 // Map buffer if creating a CLTensor
715 map(tensor, true);
716
717 Window window;
718
719 window.set(arm_compute::Window::DimX, arm_compute::Window::Dimension(0, 1, 1));
720
721 for (unsigned int d = 1; d < tensor.info()->num_dimensions(); ++d)
722 {
723 window.set(d, Window::Dimension(0, tensor.info()->tensor_shape()[d], 1));
724 }
725
726 arm_compute::Iterator in(&tensor, window);
727
728 execute_window_loop(
729 window,
730 [&](const Coordinates &)
731 {
732 fs.read(reinterpret_cast<std::fstream::char_type *>(in.ptr()),
733 tensor.info()->tensor_shape()[0] * tensor.info()->element_size());
734 },
735 in);
736
737 // Unmap buffer if creating a CLTensor
738 unmap(tensor);
739 }
740 catch (const std::ofstream::failure &e)
741 {
742 ARM_COMPUTE_ERROR_VAR("Writing %s: (%s)", filename.c_str(), e.what());
743 }
744}
745
746template <typename T, typename TensorType>
747void fill_tensor_value(TensorType &tensor, T value)

Callers

nothing calls this directly

Calls 11

mapFunction · 0.85
unmapFunction · 0.85
readMethod · 0.80
DimensionClass · 0.50
openMethod · 0.45
setMethod · 0.45
num_dimensionsMethod · 0.45
infoMethod · 0.45
ptrMethod · 0.45
element_sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected