Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented May 7, 2019

Stack from ghstack:

The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.

Differential Revision: D15243625

The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.
@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: cpp Related to C++ API module: internals Related to internal abstractions in c10 and ATen labels May 7, 2019
@suo suo requested a review from zdevito May 7, 2019 17:47
[jit] Convenience APIs for script objects

The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.

gh-metadata: pytorch pytorch 20226 gh/suo/36/head
return this->type_->qualname();
}

IValue ivalue::Object::getAttr(const std::string& name) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want the same api as pybind11, which uses attr

Copy link
Member Author

@suo suo May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pybind's attr returns a functor which lets you write to the object by assigning to it. I think that's probably a little overkill in this case.

I think i'll expose static getattr and setattr like the python builtins

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old API seems simpler, this makes it more like a C API. Maybe we shouldn't try to match pythons semantics here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with that. whatever is more natural for people I guess

constantTable,
nullptr);

// Incorrect arguments for constructor should throow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throooooow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn the macbook keyboard :(

suo added 3 commits May 8, 2019 00:57
[jit] Convenience APIs for script objects

The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.

gh-metadata: pytorch pytorch 20226 gh/suo/36/head
[jit] Convenience APIs for script objects

The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.

gh-metadata: pytorch pytorch 20226 gh/suo/36/head
[jit] Convenience APIs for script objects

The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.

gh-metadata: pytorch pytorch 20226 gh/suo/36/head
@zou3519 zou3519 deleted the gh/suo/36/head branch May 10, 2019 20:06
zdevito pushed a commit to zdevito/ATen that referenced this pull request May 10, 2019
Summary:
Pull Request resolved: pytorch/pytorch#20226
ghimport-source-id: 22937d72e35ec4eba38019284a368453089fe3eb

Differential Revision: D15243625

Pulled By: suo

fbshipit-source-id: 5e9fb773da244f9ef201dba524155c3b19b2b4e0
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in ce03348.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpp Related to C++ API module: internals Related to internal abstractions in c10 and ATen oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants