| 16 | } |
| 17 | |
| 18 | std::shared_ptr<Array> |
| 19 | check_key(const Sample& input, const std::string& key, ArrayType type) { |
| 20 | auto it = input.find(key); |
| 21 | if (it == input.end()) { |
| 22 | throw std::runtime_error("key <" + key + "> expected"); |
| 23 | } |
| 24 | auto value = it->second; |
| 25 | if (type != ArrayType::Any && value->type() != type) { |
| 26 | throw std::runtime_error("invalid Array type"); |
| 27 | } |
| 28 | return value; |
| 29 | } |
| 30 | } // namespace sample |
| 31 | } // namespace data |
| 32 | } // namespace mlx |