pytorch
90c65b81 - Define `repr()` on IValues (#32232)

Commit
4 years ago
Define `repr()` on IValues (#32232) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/32232 Previously, we were using `operator<<` as the default way of printing IValue constants during serialization. The semantics of `operator<<` were ill-defined; and this bit us in particular with strings and lack of quoting. This PR defines the role of `operator<<`: much like Python `str()`, it is intended to produce a human-readable-ish representation for debugging purposes. This PR also defines a new `repr()` function on IValue that is intended to produce a valid Python expression that can be used to recreate an object with the same value. `repr()` is not defined on all IValue kinds (notably tensors!) for this reason. Test Plan: Imported from OSS Differential Revision: D19417036 Pulled By: suo fbshipit-source-id: c102d509eaf95a28b6a62280bc99ca6f09603de5
Author
suo suo
Parents
Loading