-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplementing dtr with generic overloading. #62
base: 21-3-2-orig
Are you sure you want to change the base?
Conversation
TORCH_CHECK(count == make_raw_result.outputs.size()); | ||
} | ||
|
||
// todo: i can also use a torch library impl instead of calling fallback explicitly. should i do that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah just use torch library impl, that's what it's for
std::vector<bool> checkpoint_reversed_ivalue_in_mutable; | ||
// but should we really reverse stuff? there is a peek() function which doesnt. | ||
// ezyang seems to want to replace stack impl from std::vector to some sort of list, | ||
// so slower peek() though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't reverse it. Stack is always going to be contiguous memory. You can iterate the other direction to avoid reversing.
|
||
// map over the tensor in the ivalue. | ||
// weird stuff. seems like i cant write a generic function over all list :( | ||
template<typename F> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimization: use fallback for all other then istensorlist/istensor/istensoroptionlist
std::vector<bool> checkpoint_tensors_in_mutable; | ||
auto it = checkpoint_reversed_ivalue_in.rbegin(); | ||
auto mit = checkpoint_reversed_ivalue_in_mutable.rbegin(); | ||
while (it != checkpoint_reversed_ivalue_in.rend()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove reverse - much simpler
// the only way to construct/destruct an IValue should be map_ivalue. | ||
void CheckpointFallback(const c10::OperatorHandle& op, torch::jit::Stack* stack) { | ||
size_t before_size = stack->size(); | ||
auto s = op.schema(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only call op.schema() once
Fixes #{issue number}