| 502 | uint32_t position{0}; |
| 503 | |
| 504 | explicit ArrayDesc(Shape shape, Dtype dtype); |
| 505 | |
| 506 | explicit ArrayDesc( |
| 507 | Shape shape, |
| 508 | Dtype dtype, |
| 509 | std::shared_ptr<Primitive> primitive, |
| 510 | std::vector<array> inputs); |
| 511 | |
| 512 | ~ArrayDesc(); |
| 513 | |
| 514 | private: |
| 515 | // Initialize size, strides, and other metadata |
| 516 | void init(); |
| 517 | }; |
| 518 | |
| 519 | // The ArrayDesc contains the details of the materialized array including the |
| 520 | // shape, strides, the data type. It also includes |
| 521 | // the primitive which knows how to compute the array's data from its inputs |
| 522 | // and the list of array's inputs for the primitive. |
| 523 | std::shared_ptr<ArrayDesc> array_desc_; |
| 524 | }; |
| 525 | |
| 526 | template <typename T> |
| 527 | array::array(T val, Dtype dtype /* = TypeToDtype<T>() */) |
| 528 | : array_desc_(std::make_shared<ArrayDesc>(Shape{}, dtype)) { |
| 529 | init(&val); |
| 530 | } |
| 531 | |
| 532 | template <typename It> |
| 533 | array::array( |