mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[TorchScript] Support user defined classes as constants (#5062)
Summary: Pull Request resolved: https://github.com/pytorch/glow/pull/5062 Pull Request resolved: https://github.com/pytorch/pytorch/pull/45556 User defined classes can be used as constants. This is useful when freezing and removing the module from the graph. Test Plan: waitforsadcastle Reviewed By: eellison Differential Revision: D23994974 fbshipit-source-id: 5b4a5c91158aa7f22df39d71f2658afce1d29317
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3611d26a25
commit
43a9d6fb6e
@ -873,7 +873,8 @@ struct PythonPrintImpl {
|
||||
|
||||
void printConstant(TaggedStringStream& stmt, const IValue& v) {
|
||||
const auto customFormatter = [&](std::ostream& ss, const IValue& v) {
|
||||
if (v.isTensor() || containsNonASCIIString(v)) {
|
||||
if (v.isTensor() || containsNonASCIIString(v) || v.isObject()) {
|
||||
TORCH_INTERNAL_ASSERT(!v.type()->is_module());
|
||||
ss << "CONSTANTS.c" << getOrAddConstant(v);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user