Comments (10)
Hi @DuanYuFi , thanks for the question
Why the first item in the templates is the class itself? Is that a stipulation?
Yes, it's a stipulation, the pattern is from https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern, it's widely used in a number of C++ projects, like LLVM/Eigen/xtensor.
Is RingTy means this data is in ring?
Yes, you can think RingTy as SPU VM's unsigned integer, but with more clear semantic.
Is Secret means this data is secret instead of public?
Yes, you will see something like x.eltype().ias<Secret>
, which test if the value is a secret value.
s AShare emphasizes that this is an Arithmetic data? In other words, the point of it is Arithmetic instead of Share?
It means a Arithmetic shared data
, an AShare is a Secret Share, which is, of course, a Secret.
Is TypeImpl just defined the attribute of the share, and it doesn't store any real data? For example, there's a replicated secret share (x0, x1), and TypeImpl only defines attribute such as RingTy, Secret, etc. but don't store x0, x1.
Yes, type is type, value is value. Type just describes the runtime type information of values, its does not hold content of values.
Jin,
Thanks
from spu.
Thanks for your detailed answer, it solves all my questions. Thank you!
from spu.
Hi, if I want to build a field type, should I still use RingTy? I didn't find something like FieldTy.
By the way, happy Lunar Newyear to everyone :)
from spu.
Seems that according to our previous conversation:
Yes, you can think RingTy as SPU VM's unsigned integer, but with more clear semantic.
RingTy means unsigned integer, of course it could represent field element. And RingTy has an attribute Ring2k
, which has some comments
// This trait means the data is maintained in ring 2^k, it DOES NOT mean that
// data storage is k-bits.
// For example, some protocol works in Zq, but the data it manipulates on is
// [0, 2^k).
Thanks LOL, if anything incorrect, please tell me.
from spu.
Hi, if I want to build a field type, should I still use RingTy? I didn't find something like FieldTy. By the way, happy Lunar Newyear to everyone :)
Let me guess, you are trying to add a new protocol which works on Zq, but the upper layer (Hal layer) assumes all operations works on Z2k(Ring2k).
If am correct, you can simply expose the type as Z2k(Ring2k), because the upper system use this trait to interact with protocol layer. But inside your protocol, maintain Zq storage and related operations.
In the future, we may support Zq from the HAL layer, which means, HAL acts differently according to the working field. At that time, we can 'lift' Zq to //spu/core/type.h (from your protocol's local definition)
from spu.
OK, thanks for your detailed reply. You are right, I'll spend some time to comprehend。
from spu.
What's the difference between TypeObject
, FieldType
and ring2k_t (from Ring2kTrait)
?
from spu.
It seems that FieldType
is included in TypeObject
, and ring2k_t
is some struct related to FieldType
?
from spu.
TypeObject
is just a general object that represent a type, you can derive from it to represent a concrete type. i.e.
class MyPrototocolType : public TypeObject {};
But the system sometime want to know how your derived type behave like, i.e. does like behave like a Ring2k, or a boolean share? So we should add these interface to it.
class Ring2k {
FieldType field(); // return the concrete field of this ring.
};
// also inherit from Ring2k
class MyPrototocolType : public TypeObject, public Ring2k;
And finally, we use CRTP and concept model idiom to inject some other information to the classes.
class MyProtocolType : public TypeImpl<MyProtocolType, Ring2k, ...> {}
ring2k_t is totally a different thing, it's use to dispatch to static type according to dynamic type. i.e
// if you define
enum CppType {
Int32,
Int64,
};
if (ty == Int32) {
using ring2k_t = int32_t; // inject static type information here.
fn(...); // call your lambda function, and the `ring2k_t` is injected.
} else if (ty == Int64) {
...
}
Have a nice day.
from spu.
That's a detailed description. Thank you. I learned so much about computer systems, principles of compiles, etc. in this issue than what I've done all my life. I hope I can get on it well as soon as I can.
from spu.
Related Issues (20)
- 使用 SPU 计算 ANOVA F 统计量
- 使用 SPU 实现 t-SNE 算法
- [Bug]: Pickle Can't get attribute 'ObjectRef' HOT 11
- [Bug]: bazel: could not resolve the version 'latest' to an actual version number: unable to determine latest version ... HOT 10
- [Question]: unstable performance for basic operations in ABY3 HOT 4
- [Bug]: spu 使用GCC 13编译时出错 HOT 2
- [Bug]: compile failed HOT 1
- SPU的编译环境 HOT 2
- [Feature]: flax_gpt2 inference using FM32 secret sharing HOT 4
- How to get the communication volume and how to evaluate individual DNN layer? HOT 6
- [Question]: Are the plaintexts passed to AddPlainInplace in NTT form? HOT 3
- mac运行spu-psi_test中.so错误 HOT 12
- How to use SPU to evaluate private models in 2PC setting with only one machine? HOT 13
- [Bug]: One more minus sign HOT 2
- [Bug]: Package 'examples/python/ml/my_custom_file' contains errors HOT 10
- [Bug]: The critical condition judgment is wrong HOT 5
- [Bug]: Error when trying to benchmark SPU latency in 2PC setting. HOT 3
- another case where secret indexing doesn't seem to work HOT 2
- [Bug]: 8x communication compared to reported in Cheetah HOT 5
- [Operation Question] How to separate truncation and matmul operations HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spu.