| 398 | std::size_t shape::elements() const { return impl->elements(); } |
| 399 | |
| 400 | std::size_t shape::bytes() const |
| 401 | { |
| 402 | if(this->sub_shapes().empty()) |
| 403 | { |
| 404 | std::size_t n = 0; |
| 405 | if(type() == fp4x2_type) |
| 406 | { |
| 407 | n = sizeof(uint8_t); |
| 408 | } |
| 409 | else |
| 410 | { |
| 411 | this->visit_type([&](auto as) { n = as.size(); }); |
| 412 | } |
| 413 | return n * this->element_space(); |
| 414 | } |
| 415 | else |
| 416 | { |
| 417 | return std::accumulate(this->sub_shapes().begin(), |
| 418 | this->sub_shapes().end(), |
| 419 | std::size_t{0}, |
| 420 | [&](auto x, auto y) { return x + y.bytes(); }); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | std::size_t shape::type_size() const |
| 425 | { |