Identifier for a tensor within a step. first == operation_name, second == output_index Note: does not own backing storage for name.
| 31 | // first == operation_name, second == output_index |
| 32 | // Note: does not own backing storage for name. |
| 33 | struct TensorId : public std::pair<StringPiece, int> { |
| 34 | typedef std::pair<StringPiece, int> Base; |
| 35 | |
| 36 | // Inherit the set of constructors. |
| 37 | using Base::pair; |
| 38 | |
| 39 | // NOTE(skyewm): this is required on some platforms. I'm not sure why the |
| 40 | // using statement above isn't always sufficient. |
| 41 | TensorId() : Base() {} |
| 42 | TensorId(const SafeTensorId& id); |
| 43 | |
| 44 | const StringPiece node() const { return first; } |
| 45 | int index() const { return second; } |
| 46 | |
| 47 | string ToString() const { |
| 48 | if (second == Graph::kControlSlot) return strings::StrCat("^", first); |
| 49 | return strings::StrCat(first, ":", second); |
| 50 | } |
| 51 | |
| 52 | struct Hasher { |
| 53 | public: |
| 54 | std::size_t operator()(const TensorId& x) const { |
| 55 | return Hash32(x.first.data(), x.first.size(), x.second); |
| 56 | } |
| 57 | }; |
| 58 | }; |
| 59 | |
| 60 | TensorId ParseTensorName(const string& name); |
| 61 | TensorId ParseTensorName(StringPiece name); |
no outgoing calls