Skip to content

Reimplementing dtr with generic overloading.#62

Open
MarisaKirisame wants to merge 35 commits into21-3-2-origfrom
generic
Open

Reimplementing dtr with generic overloading.#62
MarisaKirisame wants to merge 35 commits into21-3-2-origfrom
generic

Conversation

@MarisaKirisame
Copy link
Collaborator

Fixes #{issue number}

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?
Copy link
Collaborator

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.
Copy link
Collaborator

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>
Copy link
Collaborator Author

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()) {
Copy link
Collaborator Author

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();
Copy link
Collaborator Author

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants