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

CKKSTensor: complete dot operation #220

Merged
merged 17 commits into from
Jan 25, 2021
Merged

CKKSTensor: complete dot operation #220

merged 17 commits into from
Jan 25, 2021

Conversation

youben11
Copy link
Member

@youben11 youben11 commented Jan 21, 2021

Description

dot operations were missing 1D-2D and 2D-1D tensors because of the missing broadcasting operations. Now we have broadcasting and we can complete the dot method.

Checklist

@youben11 youben11 added Type: Improvement 📈 Performance improvement not introducing a new feature or requiring a major refactor Type: New Feature ➕ Introduction of a completely new addition to the codebase labels Jan 21, 2021
@youben11 youben11 added this to the CKKSTensor milestone Jan 21, 2021
@youben11 youben11 requested review from bcebere and removed request for bcebere January 24, 2021 16:25
// TODO: better implement broadcasting for mul first then would be
// implemented similar to 1D-1D
throw invalid_argument("1D-2D dot isn't implemented yet");
if (this_shape[0] != other_shape[0])
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't valid for

this_shape[0] == other_shape[1]

?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need the vector size to match the first dimension of the matrix to perform the dot product

Copy link
Member

@bcebere bcebere left a comment

Choose a reason for hiding this comment

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

LGTM! just one question

Copy link
Member

@bcebere bcebere left a comment

Choose a reason for hiding this comment

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

LGTM! just some observations

throw invalid_argument("can't perform dot: dimension mismatch");
// TODO: remove boradcast when implemented in _mul
auto other_copy = other->copy();
other_copy->_data.reshape_inplace(
Copy link
Member

Choose a reason for hiding this comment

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

This could be directly

auto other_copy = other->reshape( ...

throw invalid_argument("2D-1D dot isn't implemented yet");
if (this_shape[1] != other_shape[0])
throw invalid_argument("can't perform dot: dimension mismatch");
// TODO: remove boradcast when implemented in _mul
Copy link
Member

Choose a reason for hiding this comment

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

small typo

if (this_shape[1] != other_shape[0])
throw invalid_argument("can't perform dot: dimension mismatch");
// TODO: remove boradcast when implemented in _mul
auto other_copy = other;
Copy link
Member

Choose a reason for hiding this comment

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

maybe

auto other_copy = other.reshape(...

directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

other here is a const and can't call reshape directly, just kept this, but the rest is updated

@youben11 youben11 merged commit 7e0895c into master Jan 25, 2021
@delete-merged-branch delete-merged-branch bot deleted the complete-dot branch January 25, 2021 17:37
pierreeliseeflory pushed a commit to pierreeliseeflory/TenSEAL that referenced this pull request Apr 27, 2022
* add 1D-2D dot

* fix

* reshape before broadcast

* fix: return

* ignore protobuf changes

* 2D-1D dot

* separate dot ops again

* lint

* fix: pass the copy

* typos and updates

* lint

* need to copy plain first

Co-authored-by: Bogdan Cebere <bogdan.cebere@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Improvement 📈 Performance improvement not introducing a new feature or requiring a major refactor Type: New Feature ➕ Introduction of a completely new addition to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants