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 Dot operation #196

Merged
merged 17 commits into from
Dec 23, 2020
Merged

CKKSTensor Dot operation #196

merged 17 commits into from
Dec 23, 2020

Conversation

youben11
Copy link
Member

@youben11 youben11 commented Dec 20, 2020

Description

This PR adds the dot operation between a CKKSTensor and another, or a PlainTensor. The shapes supported now are 1D-1D (inner product) and 2D-2D (matrix multiplication).

TODO

  • Fix API
  • Parallel computation?

Fixes #176

How has this been tested?

  • Added tests

Checklist

@youben11 youben11 added the Type: New Feature ➕ Introduction of a completely new addition to the codebase label Dec 20, 2020
@youben11 youben11 added this to the CKKSTensor milestone Dec 20, 2020
@youben11 youben11 requested a review from bcebere December 22, 2020 13:24
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.

Great work!
just a few observations

shared_ptr<CKKSTensor> matmul(const shared_ptr<CKKSTensor> other) {
return this->copy()->matmul_inplace(other);
}
shared_ptr<CKKSTensor> matmul_inplace(const shared_ptr<CKKSTensor> other);
Copy link
Member

Choose a reason for hiding this comment

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

There is something similar in the encrypted_vector interface. Maybe move them to the encrypted_tensor interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

True! This will require removing the n_jobs parameter from matmul, which I can't remember why I chose to put it there... I will open another PR for the API change after this one.

tenseal/cpp/tensors/ckkstensor.cpp Show resolved Hide resolved
tenseal/cpp/tensors/ckkstensor.cpp Show resolved Hide resolved
@youben11 youben11 changed the title [WIP] CKKSTensor Dot operation CKKSTensor Dot operation Dec 23, 2020
@youben11 youben11 requested a review from bcebere December 23, 2020 16:35
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.

Awesome work! LGTM

}
return true;
};

Copy link
Member

Choose a reason for hiding this comment

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

we should somehow reuse the workers code, it is a lot of duplication here.
but for another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I literally did a copy/paste here. I will open two refactor issues that I've found useful to work on

@youben11 youben11 merged commit ea8f04f into master Dec 23, 2020
@delete-merged-branch delete-merged-branch bot deleted the ckks_tensor_dot branch December 23, 2020 17:04
pierreeliseeflory pushed a commit to pierreeliseeflory/TenSEAL that referenced this pull request Apr 27, 2022
* first skeleton for dot operation

* matmul

* lint

* tests

* fix: create acc ct based on result param_id

* lint

* rename test func

* fix indexing

* redef API for dot

dot_product* is now just dot*

* lint

* plain dot

* comments

* bind plain dot

* parallel matmul

* fix: to_sum should be scoped in the worker_func only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Dot product for CKKSTensor
2 participants