33 for (uint32_t i = 0; i < input->rank(); i++)
34 if (!input->dim(i).known())
35 throw std::runtime_error(input->name() +
" has unknown dimension");
38 throw std::runtime_error(input->name() +
" is a zero-sized input");
45 uint32_t num_elements = 1;
46 for (uint32_t i = 0; i < node->rank(); i++)
48 if (not node->dim(i).known())
49 throw std::runtime_error(
"Unknown dimension found in " + node->
name());
51 num_elements *= node->dim(i).value();
61 uint32_t elem_size =
luci::size(node->dtype());
65void readDataFromFile(
const std::string &filename, std::vector<char> &data,
size_t data_size)
67 assert(data.size() == data_size);
69 std::ifstream fs(filename, std::ifstream::binary);
71 throw std::runtime_error(
"Cannot open file \"" + filename +
"\".\n");
72 if (fs.read(data.data(), data_size).fail())
73 throw std::runtime_error(
"Failed to read data from file \"" + filename +
"\".\n");
75 throw std::runtime_error(
"Input tensor size mismatches with \"" + filename +
"\".\n");
uint32_t size(loco::DataType data_type)
Returns the size of the data type.
void checkInputDimension(const luci::CircleInput *input)
size_t getTensorSize(const luci::CircleNode *node)
void readDataFromFile(const std::string &filename, std::vector< char > &data, size_t data_size)
uint32_t numElements(const luci::CircleNode *node)
NodeName name(void) const