Represents runtime information needed to construct a dataset.
| 611 | |
| 612 | // Represents runtime information needed to construct a dataset. |
| 613 | class DatasetContext { |
| 614 | public: |
| 615 | struct Params { |
| 616 | string type_string; // op type name of this dataset. |
| 617 | string node_name; // graph node name of this dataset op, uniquely |
| 618 | // identifying the dataset in the graph. |
| 619 | }; |
| 620 | |
| 621 | explicit DatasetContext(Params params) : params_(std::move(params)) {} |
| 622 | |
| 623 | explicit DatasetContext(OpKernelContext* ctx) { |
| 624 | params_.type_string = ctx->op_kernel().type_string(); |
| 625 | params_.node_name = ctx->op_kernel().name(); |
| 626 | } |
| 627 | |
| 628 | const string& type_string() const { return params_.type_string; } |
| 629 | const string& node_name() const { return params_.node_name; } |
| 630 | |
| 631 | private: |
| 632 | Params params_; |
| 633 | }; |
| 634 | |
| 635 | // Returns the number of bytes allocated for the given tensor. |
| 636 | int64 GetAllocatedBytes(const std::vector<Tensor>& element); |