Expose class constant through attr and setattr in object (#29219)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29219

We added class constant in previous PRs, this PR allows access to
class constant in the object API

Test Plan:
build/bin/test_jit
python test/test_jit.py

Imported from OSS

Differential Revision: D18846851

fbshipit-source-id: 888a6517d5f747d1f8ced283c0c2c30b2f6c72c6
This commit is contained in:
Jerry Zhang
2020-01-04 11:07:37 -08:00
committed by Facebook Github Bot
parent 6f62c311a1
commit ebe69236d1
6 changed files with 98 additions and 16 deletions
+1 -1
View File
@@ -416,7 +416,7 @@ TEST(SerializeTest, IValue) {
input_archive.read("value", ivalue_out);
ASSERT_EQ(ivalue_out.toInt(), 1);
ASSERT_THROWS_WITH(input_archive.read("bad_key", ivalue_out), "does not have an attribute with name");
ASSERT_THROWS_WITH(input_archive.read("bad_key", ivalue_out), "does not have a field with name");
}
// NOTE: if a `Module` contains unserializable submodules (e.g. `nn::Functional`),