201 assert(std::string(argv[1]) ==
"-d");
202 assert(std::string(argv[2]) ==
"0.001");
204 H5::H5File lhs{argv[3], H5F_ACC_RDONLY};
205 H5::H5File rhs{argv[4], H5F_ACC_RDONLY};
207 ExitcodeTracker exitcode_tracker;
210 mux.attach(&exitcode_tracker);
222 int64_t value_count = -1;
224 uint32_t lhs_value_count =
static_cast<uint32_t
>(lhs_value_grp.getNumObjs());
225 uint32_t rhs_value_count =
static_cast<uint32_t
>(rhs_value_grp.getNumObjs());
227 if (lhs_value_count != rhs_value_count)
229 ErrorDetail<ErrorCode::CountMismatch> error{};
234 value_count = std::max<int64_t>(lhs_value_count, rhs_value_count);
236 assert(value_count >= 0);
239 for (int64_t n = 0; n < value_count; ++n)
242 const std::string dataset_name = std::to_string(n);
244 auto lhs_dataset = lhs_value_grp.openDataSet(dataset_name);
245 auto rhs_dataset = rhs_value_grp.openDataSet(dataset_name);
247 auto lhs_dtype = to_internal_dtype(lhs_dataset.getDataType());
248 auto rhs_dtype = to_internal_dtype(rhs_dataset.getDataType());
251 assert(rhs_dtype == DataType::FLOAT32);
252 assert(lhs_dtype == DataType::FLOAT32);
254 if (lhs_dtype != rhs_dtype)
256 ErrorDetail<ErrorCode::TypeMismatch> error{};
261 auto lhs_shape = to_internal_shape(lhs_dataset.getSpace());
262 auto rhs_shape = to_internal_shape(rhs_dataset.getSpace());
264 if (!(lhs_shape == rhs_shape))
266 ErrorDetail<ErrorCode::ShapeMismatch> error{};
271 assert(lhs_shape == rhs_shape);
272 assert(lhs_dtype == rhs_dtype);
273 const auto &shape = lhs_shape;
274 const auto &dtype = lhs_dtype;
278 case DataType::FLOAT32:
280 auto lhs_vector = as_float_vector(lhs_dataset);
281 auto rhs_vector = as_float_vector(rhs_dataset);
283 assert(lhs_vector.size() == rhs_vector.size());
285 LexicalLayout layout;
287 for (TensorIndexEnumerator e{shape}; e.valid(); e.advance())
289 const auto &ind = e.current();
290 auto lhs_value = lhs_vector.at(layout.offset(shape, ind));
291 auto rhs_value = rhs_vector.at(layout.offset(shape, ind));
294 if (std::abs(lhs_value - rhs_value) >= 0.001f)
296 ErrorDetail<ErrorCode::ValueMismatch> error{};
305 throw std::runtime_error{
"Not supported, yet"};
312 return exitcode_tracker.exitcode();
int entry(int argc, char **argv)
Dump IR for given arguments.