Skip to content
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

Propagate Allocator through expression layer #90

Open
ryanmrichard opened this issue Jul 11, 2022 · 0 comments
Open

Propagate Allocator through expression layer #90

ryanmrichard opened this issue Jul 11, 2022 · 0 comments

Comments

@ryanmrichard
Copy link
Member

Issue Description

Similar idea to #89, but this time we're adding Expression::allocator. I'm not 100% sure what the signature for Expression::allocator should be, but my guess is:

Allocator allocator(const_annotation_type out_labels, const_shape_reference out_shape);

i.e., it takes the labels and shape for temporary tensor the expression is being assigned to and returns the allocator (I think the shape is needed to work out tilings, for example).

This requires modifying the body of methods like Add::tensor_ along the lines of:

// Get the labels for the three tensors
const auto a_labels  = exp_a.labels(lhs_labels);
const auto b_labels  = exp_b.labels(lhs_labels);
const auto& c_labels = lhs_labels;

// Get the shapes for the three tensors
auto a_shape = exp_a.shape(a_labels);
auto b_shape = exp_b.shape(b_labels);
Shape c_shape;
a_shape.add(a_labels, c_labels, c_shape, b_labels, b_shape);

// Get the allocators for the three tensors
auto a_alloc = exp_a.allocator(a_labels, a_shape);
auto b_alloc = exp_b.allocator(b_labels, b_shape);
Allocator c_alloc;
a_alloc.add(a_labels, c_labels, c_alloc, b_labels, b_alloc);
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

No branches or pull requests

1 participant