예제 #1
0
파일: exp.py 프로젝트: junjiequ123/Rosetta
                         tf.exp, [[-1.01, -2.00], [-3.01, 1.3]],
                         [[0.364, 0.135], [0.049, 3.669]],
                         precision=0.2)


def Exp_4(task_id):
    return unary_op_test("Helix",
                         task_id,
                         tf.exp, [[2.02, 3.14], [+2, -0.01]],
                         [[7.538, 23.104], [7.389, 0.990]],
                         precision=0.5)


# [-1.01, -2.00],  [-3.01, 1.3],   [2.02, 3.14],    [+2, -0.01] # x
# [0.364,  0.135], [0.049, 3.669], [7.538, 23.104], [7.389, 0.990] # exp expect

# ===========================
# run test cases
# ===========================
# mt_unit_test_fw([Exp_1, Exp_1])
# mt_unit_test_fw([Exp_2, Exp_2])
# mt_unit_test_fw([Exp_1, Exp_2])
# mt_unit_test_fw([Exp_1, Exp_2, Exp_1, Exp_2])
# mt_unit_test_fw([Exp_1, Exp_1, Exp_1, Exp_2, Exp_2, Exp_2])

mt_unit_test_fw([Exp_3, Exp_3])
mt_unit_test_fw([Exp_4, Exp_4])
mt_unit_test_fw([Exp_3, Exp_4])
mt_unit_test_fw([Exp_3, Exp_4, Exp_3, Exp_4])
mt_unit_test_fw([Exp_3, Exp_3, Exp_3, Exp_4, Exp_4, Exp_4])
예제 #2
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def LogicNot_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.logical_not, [1, 1, 0, 0],
                         [0., 0., 1., 1.])


def LogicNot_2(task_id):
    return unary_op_test("Helix", task_id, tf.logical_not, [0, 1, 0],
                         [1., 0., 1.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([LogicNot_1, LogicNot_1])
mt_unit_test_fw([LogicNot_2, LogicNot_2])
mt_unit_test_fw([LogicNot_1, LogicNot_2])
mt_unit_test_fw([LogicNot_1, LogicNot_2, LogicNot_1, LogicNot_2])
mt_unit_test_fw(
    [LogicNot_1, LogicNot_1, LogicNot_1, LogicNot_2, LogicNot_2, LogicNot_2])
예제 #3
0
파일: neg.py 프로젝트: junjiequ123/Rosetta
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Neg_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.negative, [1.1], [-1.1])


def Neg_2(task_id):
    return unary_op_test("Helix", task_id, tf.negative, [-1.1, 3.3],
                         [1.1, -3.3])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Neg_1, Neg_1])
mt_unit_test_fw([Neg_2, Neg_2])
mt_unit_test_fw([Neg_1, Neg_2])
mt_unit_test_fw([Neg_1, Neg_2, Neg_1, Neg_2])
mt_unit_test_fw([Neg_1, Neg_1, Neg_1, Neg_2, Neg_2, Neg_2])
예제 #4
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test



def GreaterEqu_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.greater_equal, 
                        [1.1, 2.2, -1.1, 0.1], 
                        [1.2, -2.2, -1.0, 0.], 
                        [0., 1., 0., 1.])



def GreaterEqu_2(task_id):
    return bin_op_test("Helix", task_id, tf.greater_equal, 
                        [-1.1, 2.3, 2.2], 
                        2.2, 
                        [0., 1., 1.])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([GreaterEqu_1, GreaterEqu_1])
mt_unit_test_fw([GreaterEqu_2, GreaterEqu_2])
mt_unit_test_fw([GreaterEqu_1, GreaterEqu_2])
mt_unit_test_fw([GreaterEqu_1, GreaterEqu_2, GreaterEqu_1, GreaterEqu_2])
mt_unit_test_fw([GreaterEqu_1, GreaterEqu_1, GreaterEqu_1, GreaterEqu_2, GreaterEqu_2, GreaterEqu_2])
예제 #5
0
def Rsqrt_3(task_id):
    return unary_op_test("SecureNN", task_id, tf.rsqrt,
                         [[0.4, 0.86], [1.2, 1]],
                         [[1.581, 1.078], [0.912, 1.]])


def Rsqrt_4(task_id):
    return unary_op_test("Helix", task_id, tf.rsqrt,
                         [[1.3, 2.02], [3.14, +2], [4, 19.0]],
                         [[0.877, 0.703], [0.564, 0.707], [0.5, 0.229]])


# [[0.4, 0.86], [1.2, 1], [1.3, 2.02], [3.14, +2], [4, 19.0]] # x
# [[1.581, 1.078], [0.912, 1.], [0.877, 0.703], [0.564, 0.707], [0.5, 0.229]] # rsqrt expect
# [[0.632, 0.927], [1.095, 1.], [1.140, 1.421], [1.772, 1.414], [2., 4.358]] # sqrt expect

# ===========================
# run test cases
# ===========================
# mt_unit_test_fw([Rsqrt_1, Rsqrt_1])
# mt_unit_test_fw([Rsqrt_2, Rsqrt_2])
# mt_unit_test_fw([Rsqrt_1, Rsqrt_2])
# mt_unit_test_fw([Rsqrt_1, Rsqrt_2, Rsqrt_1, Rsqrt_2])
# mt_unit_test_fw([Rsqrt_1, Rsqrt_1, Rsqrt_1, Rsqrt_2, Rsqrt_2, Rsqrt_2])

mt_unit_test_fw([Rsqrt_3, Rsqrt_3])
mt_unit_test_fw([Rsqrt_4, Rsqrt_4])
mt_unit_test_fw([Rsqrt_3, Rsqrt_4])
mt_unit_test_fw([Rsqrt_3, Rsqrt_4, Rsqrt_3, Rsqrt_4])
mt_unit_test_fw([Rsqrt_3, Rsqrt_3, Rsqrt_3, Rsqrt_4, Rsqrt_4, Rsqrt_4])
예제 #6
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test



def Equal_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.equal, 
                        [1.1, 2.2, -1.1, 0.], 
                        [1.1, -2.2, -1.2, 0.], 
                        [1., 0., 0., 1.])


def Equal_2(task_id):
    return bin_op_test("Helix", task_id, tf.equal, 
                        [-1.1, 2.2], 
                        2.2,
                        [0., 1.])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Equal_1, Equal_1])
mt_unit_test_fw([Equal_2, Equal_2])
mt_unit_test_fw([Equal_1, Equal_2])
mt_unit_test_fw([Equal_1, Equal_2, Equal_1, Equal_2])
mt_unit_test_fw([Equal_1, Equal_1, Equal_1, Equal_2, Equal_2, Equal_2])
예제 #7
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Softmax_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.softmax, [
        9.6, 75.2, -81.3, 8.04, 2.27, -70.95, -130.95, -123.51, 137.98, 89.54
    ], [0., 0., 0., 0., 0., 0., 0., 0, 1., 0.])


def Softmax_2(task_id):
    return unary_op_test("Helix", task_id, tf.softmax, [
        9.6, 75.2, -81.3, 8.04, 2.27, -70.95, -130.95, -123.51, 137.98, 89.54
    ], [0., 0., 0., 0., 0., 0., 0., 0, 1., 0.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Softmax_1, Softmax_1])
mt_unit_test_fw([Softmax_2, Softmax_2])
mt_unit_test_fw([Softmax_1, Softmax_2])
mt_unit_test_fw([Softmax_1, Softmax_2, Softmax_1, Softmax_2])
mt_unit_test_fw(
    [Softmax_1, Softmax_1, Softmax_1, Softmax_2, Softmax_2, Softmax_2])
예제 #8
0
파일: relu.py 프로젝트: junjiequ123/Rosetta
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Relu_1(task_id):
    return unary_op_test(
        "SecureNN", task_id, tf.nn.relu,
        [0., 1., -1, 1.23638, -0.886, 4., -4., 12.0, -12., 100., -100.95],
        [0., 1., 0., 1.23638, 0., 4., 0., 12., 0, 100., 0.])


def Relu_2(task_id):
    return unary_op_test(
        "Helix", task_id, tf.nn.relu,
        [0., 1., -1, 1.23638, -0.886, 4., -4., 12.0, -12., 100., -100.95],
        [0., 1., 0., 1.23638, 0., 4., 0., 12., 0, 100., 0.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Relu_1, Relu_1])
mt_unit_test_fw([Relu_2, Relu_2])
mt_unit_test_fw([Relu_1, Relu_2])
mt_unit_test_fw([Relu_1, Relu_2, Relu_1, Relu_2])
mt_unit_test_fw([Relu_1, Relu_1, Relu_1, Relu_2, Relu_2, Relu_2])
예제 #9
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, reduce_op_test


def ReduceMax_1(task_id):
    return reduce_op_test("SecureNN", task_id, tf.reduce_max,
                          [[1., 2., 3.], [4., 5., 6.]], [6.])


def ReduceMax_2(task_id):
    return reduce_op_test("Helix", task_id, tf.reduce_max,
                          [[-1., -2., -3.], [-4., -5., -6.]], [-1.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([ReduceMax_1, ReduceMax_1])
mt_unit_test_fw([ReduceMax_2, ReduceMax_2])
mt_unit_test_fw([ReduceMax_1, ReduceMax_2])
mt_unit_test_fw([ReduceMax_1, ReduceMax_2, ReduceMax_1, ReduceMax_2])
mt_unit_test_fw([
    ReduceMax_1, ReduceMax_1, ReduceMax_1, ReduceMax_2, ReduceMax_2,
    ReduceMax_2
])
예제 #10
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_rh_const_test


def Pow_1(task_id):
    return bin_op_rh_const_test("SecureNN", task_id, tf.pow,
                                [1.3, -2.1, -3.8, 41.43], 2.0,
                                [1.69, 4.41, 14.44, 1716.445])


def Pow_2(task_id):
    return bin_op_rh_const_test("Helix", task_id, tf.pow,
                                [1.3, -2.1, 20.0, -13.1], 2.0,
                                [1.69, 4.41, 400.0, 171.61])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Pow_1, Pow_1])
mt_unit_test_fw([Pow_2, Pow_2])
mt_unit_test_fw([Pow_1, Pow_2])
mt_unit_test_fw([Pow_1, Pow_2, Pow_1, Pow_2])
mt_unit_test_fw([Pow_1, Pow_1, Pow_1, Pow_2, Pow_2, Pow_2])
예제 #11
0
파일: sub.py 프로젝트: junjiequ123/Rosetta
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test
import latticex.rosetta as rtt



def Sub_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.subtract, 
                        [-2.2], [1.1], [-3.3])


def Sub_2(task_id):
    return bin_op_test("Helix", task_id, tf.subtract, 
                        [-1.1, 3.3], 2.2, [-3.3, 1.1])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Sub_1, Sub_1])
mt_unit_test_fw([Sub_2, Sub_2])
mt_unit_test_fw([Sub_1, Sub_2])
mt_unit_test_fw([Sub_1, Sub_2, Sub_1, Sub_2])
mt_unit_test_fw([Sub_1, Sub_1, Sub_1, Sub_2, Sub_2, Sub_2])

예제 #12
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test



def LogicAnd_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.logical_and, 
                        [1, 1, 0, 0], 
                        [0, 1, 0, 1], 
                        [0., 1., 0., 0.])



def LogicAnd_2(task_id):
    return bin_op_test("Helix", task_id, tf.logical_and, 
                        [0, 1, 0], 
                        1, 
                        [0., 1., 0.])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([LogicAnd_1, LogicAnd_1])
mt_unit_test_fw([LogicAnd_2, LogicAnd_2])
mt_unit_test_fw([LogicAnd_1, LogicAnd_2])
mt_unit_test_fw([LogicAnd_1, LogicAnd_2, LogicAnd_1, LogicAnd_2])
mt_unit_test_fw([LogicAnd_1, LogicAnd_1, LogicAnd_1, LogicAnd_2, LogicAnd_2, LogicAnd_2])
예제 #13
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Sigmoid_1(task_id):
    return unary_op_test(
        "SecureNN", task_id, tf.sigmoid,
        [0., 1., -1, 1.23638, -0.886, 4., -4., 12.0, -12., 100., -100.95],
        [0.5, 0.731, 0.269, 0.775, 0.292, 0.982, 0.018, 1., 0, 1., 0])


def Sigmoid_2(task_id):
    return unary_op_test(
        "Helix", task_id, tf.sigmoid,
        [0., 1., -1, 1.23638, -0.886, 4., -4., 12.0, -12., 100., -100.95],
        [0.5, 0.731, 0.269, 0.775, 0.292, 0.982, 0.018, 1., 0, 1., 0])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Sigmoid_1, Sigmoid_1])
mt_unit_test_fw([Sigmoid_2, Sigmoid_2])
mt_unit_test_fw([Sigmoid_1, Sigmoid_2])
mt_unit_test_fw([Sigmoid_1, Sigmoid_2, Sigmoid_1, Sigmoid_2])
mt_unit_test_fw(
    [Sigmoid_1, Sigmoid_1, Sigmoid_1, Sigmoid_2, Sigmoid_2, Sigmoid_2])
예제 #14
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Log_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.log,
                         [[1.56, 2], [3.3, 4.43], [10.0, 1.85]],
                         [[0.445, 0.693], [1.194, 1.488], [2.303, 0.615]])


def Log_2(task_id):
    return unary_op_test("Helix", task_id, tf.log,
                         [[8.2, 0.2], [0.425, 1], [5.6, 0.1]],
                         [[2.104, -1.609], [-0.856, 0], [1.723, -2.303]])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Log_1, Log_1])
mt_unit_test_fw([Log_2, Log_2])
mt_unit_test_fw([Log_1, Log_2])
mt_unit_test_fw([Log_1, Log_2, Log_1, Log_2])
mt_unit_test_fw([Log_1, Log_1, Log_1, Log_2, Log_2, Log_2])
예제 #15
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Square_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.square,
                         [[1.56, 2], [3.3, 4.43], [100.0, 1.85]],
                         [[2.4336, 4.0], [10.89, 19.625], [10000.0, 3.423]])


def Square_2(task_id):
    return unary_op_test("Helix", task_id, tf.square,
                         [[-11.26, -200], [-3.3, -4.43], [-100.0, -1.85]],
                         [[126.788, 40000], [10.89, 19.625], [10000, 3.423]])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Square_1, Square_1])
mt_unit_test_fw([Square_2, Square_2])
mt_unit_test_fw([Square_1, Square_2])
mt_unit_test_fw([Square_1, Square_2, Square_1, Square_2])
mt_unit_test_fw([Square_1, Square_1, Square_1, Square_2, Square_2, Square_2])
예제 #16
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Abs_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.abs,
                         [0., 1., -1., 65536., -65536.],
                         [0., 1., 1., 65536., 65536.])


def Abs_2(task_id):
    return unary_op_test("Helix", task_id, tf.abs,
                         [0., 1., -1., 65536., -65536.],
                         [0., 1., 1., 65536., 65536.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Abs_1, Abs_1])
mt_unit_test_fw([Abs_2, Abs_2])
mt_unit_test_fw([Abs_1, Abs_2])
mt_unit_test_fw([Abs_1, Abs_2, Abs_1, Abs_2])
mt_unit_test_fw([Abs_1, Abs_1, Abs_1, Abs_2, Abs_2, Abs_2])
예제 #17
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test



def Greater_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.greater, 
                        [1.1, 2.2, -1.1, 0.1], 
                        [1.2, -2.2, -1.0, 0.], 
                        [0., 1., 0., 1.])


def Greater_2(task_id):
    return bin_op_test("Helix", task_id, tf.greater, 
                        [-1.1, 2.3, 2.1], 
                        2.2, 
                        [0., 1., 0.])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Greater_1, Greater_1])
mt_unit_test_fw([Greater_2, Greater_2])
mt_unit_test_fw([Greater_1, Greater_2])
mt_unit_test_fw([Greater_1, Greater_2, Greater_1, Greater_2])
mt_unit_test_fw([Greater_1, Greater_1, Greater_1, Greater_2, Greater_2, Greater_2])
예제 #18
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test



def Nequal_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.not_equal, 
                        [1.1, 2.2, -1.1, 0.], 
                        [1.1, -2.2, -1.2, 0.], 
                         [0., 1., 1., 0.])


def Nequal_2(task_id):
    return bin_op_test("Helix", task_id, tf.not_equal, 
                        [-1.1, 2.2], 
                        2.2, 
                        [1., 0.])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Nequal_1, Nequal_1])
mt_unit_test_fw([Nequal_2, Nequal_2])
mt_unit_test_fw([Nequal_1, Nequal_2])
mt_unit_test_fw([Nequal_1, Nequal_2, Nequal_1, Nequal_2])
mt_unit_test_fw([Nequal_1, Nequal_1, Nequal_1, Nequal_2, Nequal_2, Nequal_2])
예제 #19
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test


def Less_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.less, [1.1, 2.2, -1.1, 0.],
                       [1.2, -2.2, -1.0, 0.], [1., 0., 1., 0.])


def Less_2(task_id):
    return bin_op_test("Helix", task_id, tf.less, [-1.1, 2.3, 2.1], 2.2,
                       [1., 0., 1.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Less_1, Less_1])
mt_unit_test_fw([Less_2, Less_2])
mt_unit_test_fw([Less_1, Less_2])
mt_unit_test_fw([Less_1, Less_2, Less_1, Less_2])
mt_unit_test_fw([Less_1, Less_1, Less_1, Less_2, Less_2, Less_2])
예제 #20
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test



def Argmax_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.argmax,
                        [[1., 2., 3.], [2., 3., 4.], [5., 4., 3.], [8., 7., 2.]], 
                        [2, 2, 0, 0])


def Argmax_2(task_id):
    return unary_op_test("Helix", task_id, tf.argmax,
                        [[-1., -2., -3.], [-2., -3., -4.], [-5., -4., -3.], [-8., -7., -2.]], 
                        [0, 0, 2, 2])



# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Argmax_1, Argmax_1])
mt_unit_test_fw([Argmax_2, Argmax_2])
mt_unit_test_fw([Argmax_1, Argmax_2])
mt_unit_test_fw([Argmax_1, Argmax_2, Argmax_1, Argmax_2])
mt_unit_test_fw([Argmax_1, Argmax_1, Argmax_1, Argmax_2, Argmax_2, Argmax_2])

예제 #21
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test
import latticex.rosetta as rtt


def Div_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.truediv, [1.1], [2.2], [0.5])


def Div_2(task_id):
    return bin_op_test("Helix", task_id, tf.truediv, [-1.1, 3.3], 2.2,
                       [-0.5, 1.5])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Div_1, Div_1])
mt_unit_test_fw([Div_2, Div_2])
mt_unit_test_fw([Div_1, Div_2])
mt_unit_test_fw([Div_1, Div_2, Div_1, Div_2])
mt_unit_test_fw([Div_1, Div_1, Div_1, Div_2, Div_2, Div_2])
예제 #22
0
        x = tf.Variable(rtt.private_input(1, [[1, 2], [2, 3]],
                                          task_id=task_id))
        y = tf.Variable(rtt.private_input(2, [[1, 2], [2, 3]],
                                          task_id=task_id))

        # Define matmul operation
        res = tf.matmul(tf.matmul(w, x), y)
        init = tf.global_variables_initializer()
        config = tf.ConfigProto(inter_op_parallelism_threads=16,
                                intra_op_parallelism_threads=16)

        with tf.Session(task_id=task_id, config=config) as sess:
            sess.run(init)
            #rW, rb = sess.run([reveal_W, reveal_b])
            #print("init weight:{} \nbias:{}".format(rW, rb))

            #Y_pred = sess.run(reveal_Y, feed_dict={X: real_X, Y: real_Y})
            #print("Y_pred:", Y_pred)
            sess.run(res)

        print(rtt.get_perf_stats(pretty=True, task_id=task_id))
        rtt.deactivate(task_id=task_id)


for j in range(1):
    task_list = []
    for i in range(1000):
        task_list.append(test)
    mt_unit_test_fw(task_list)
    time.sleep(3)
예제 #23
0
파일: add.py 프로젝트: junjiequ123/Rosetta
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test
import latticex.rosetta as rtt



def Add_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.add, 
                        [1.1], [2.2], [3.3])


def Add_2(task_id):
    return bin_op_test("Helix", task_id, tf.add, 
                        [1.1, 3.3], [2.2], [3.3, 5.5])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Add_1, Add_1])
mt_unit_test_fw([Add_2, Add_2])
mt_unit_test_fw([Add_1, Add_2])
mt_unit_test_fw([Add_1, Add_2, Add_1, Add_2])
mt_unit_test_fw([Add_1, Add_1, Add_1, Add_2, Add_2, Add_2])

예제 #24
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, unary_op_test


def Log1p_1(task_id):
    return unary_op_test("SecureNN", task_id, tf.log1p,
                         [[1.56, 2], [3.3, 4.43], [9.5, 1.85]],
                         [[0.94, 1.099], [1.459, 1.692], [2.35, 1.047]])


def Log1p_2(task_id):
    return unary_op_test("Helix", task_id, tf.log1p,
                         [[6.6, 2.1], [4.235, 1], [5.6, 0.1]],
                         [[2.028, 1.131], [1.655, 0.693], [1.8, 0.095]])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Log1p_1, Log1p_1])
mt_unit_test_fw([Log1p_2, Log1p_2])
mt_unit_test_fw([Log1p_1, Log1p_2])
mt_unit_test_fw([Log1p_1, Log1p_2, Log1p_1, Log1p_2])
mt_unit_test_fw([Log1p_1, Log1p_1, Log1p_1, Log1p_2, Log1p_2, Log1p_2])
예제 #25
0
파일: sqrt.py 프로젝트: junjiequ123/Rosetta
# [[0.632, 0.927], [1.095, 1.], [1.140, 1.421], [1.772, 1.414], [2., 4.358]] # sqrt expect

def Sqrt_3(task_id):
    return unary_op_test("SecureNN", task_id, tf.sqrt,
                         [[0.4, 0.86], [1.2, 1]], 
                        [[0.632, 0.927], [1.095, 1.]])


def Sqrt_4(task_id):
    return unary_op_test("Helix", task_id, tf.sqrt,
                        [[1.3, 2.02], [3.14, +2], [4, 19.0]], 
                        [[1.140, 1.421], [1.772, 1.414], [2., 4.358]])   

# ===========================
# run test cases
# ===========================
# mt_unit_test_fw([Sqrt_1, Sqrt_1])
# mt_unit_test_fw([Sqrt_2, Sqrt_2])
# mt_unit_test_fw([Sqrt_1, Sqrt_2])
# mt_unit_test_fw([Sqrt_1, Sqrt_2, Sqrt_1, Sqrt_2])
# mt_unit_test_fw([Sqrt_1, Sqrt_1, Sqrt_1, Sqrt_2, Sqrt_2, Sqrt_2])


mt_unit_test_fw([Sqrt_3, Sqrt_3])
mt_unit_test_fw([Sqrt_4, Sqrt_4])
mt_unit_test_fw([Sqrt_3, Sqrt_4])
mt_unit_test_fw([Sqrt_3, Sqrt_4, Sqrt_3, Sqrt_4])
mt_unit_test_fw([Sqrt_3, Sqrt_3, Sqrt_3, Sqrt_4, Sqrt_4, Sqrt_4])


예제 #26
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test



def LogicXor_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.logical_xor, 
                        [1, 1, 0, 0], 
                        [0, 1, 0, 1], 
                        [1., 0., 0., 1.])



def LogicXor_2(task_id):
    return bin_op_test("Helix", task_id, tf.logical_xor, 
                        [0, 1, 0], 
                        1, 
                        [1., 0., 1.])
                        


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([LogicXor_1, LogicXor_1])
mt_unit_test_fw([LogicXor_2, LogicXor_2])
mt_unit_test_fw([LogicXor_1, LogicXor_2])
mt_unit_test_fw([LogicXor_1, LogicXor_2, LogicXor_1, LogicXor_2])
mt_unit_test_fw([LogicXor_1, LogicXor_1, LogicXor_1, LogicXor_2, LogicXor_2, LogicXor_2])
예제 #27
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test
import latticex.rosetta as rtt


def Matmul_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.matmul,
                       [[1.1, 2.2], [3.3, 4.4]], [[5.5, 6.6], [7.7, 8.8]],
                       [[22.99, 26.62], [52.03, 60.5]])


def Matmul_2(task_id):
    return bin_op_test("Helix", task_id, tf.matmul,
                       [[1.32, 0.5, -3.4], [0.63, 0.081, -1.3]],
                       [[-0.2, 0.93], [-12, 4.3], [1.123, -0.53]],
                       [[-10.08, 5.178], [-2.558, 1.6232]])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([Matmul_1, Matmul_1])
mt_unit_test_fw([Matmul_2, Matmul_2])
mt_unit_test_fw([Matmul_1, Matmul_2])
mt_unit_test_fw([Matmul_1, Matmul_2, Matmul_1, Matmul_2])
mt_unit_test_fw([Matmul_1, Matmul_1, Matmul_1, Matmul_2, Matmul_2, Matmul_2])
예제 #28
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, reduce_op_test


def ReduceMean_1(task_id):
    return reduce_op_test("SecureNN", task_id, tf.reduce_mean,
                          [[1., 2., 3.], [4., 5., 6.]], [3.5])


def ReduceMean_2(task_id):
    return reduce_op_test("Helix", task_id, tf.reduce_mean,
                          [[-1., -2., -3.], [-4., -5., -6.]], [-3.5])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([ReduceMean_1, ReduceMean_1])
mt_unit_test_fw([ReduceMean_2, ReduceMean_2])
mt_unit_test_fw([ReduceMean_1, ReduceMean_2])
mt_unit_test_fw([ReduceMean_1, ReduceMean_2, ReduceMean_1, ReduceMean_2])
mt_unit_test_fw([
    ReduceMean_1, ReduceMean_1, ReduceMean_1, ReduceMean_2, ReduceMean_2,
    ReduceMean_2
])
예제 #29
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, bin_op_test


def LessEq_1(task_id):
    return bin_op_test("SecureNN", task_id, tf.less_equal,
                       [1.1, 2.2, -1.1, 0.1], [1.1, -2.2, -1.0, 0.],
                       [1., 0., 1., 0.])


def LessEq_2(task_id):
    return bin_op_test("Helix", task_id, tf.less_equal, [-1.1, 2.3, 2.1], 2.2,
                       [1., 0., 1.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([LessEq_1, LessEq_1])
mt_unit_test_fw([LessEq_2, LessEq_2])
mt_unit_test_fw([LessEq_1, LessEq_2])
mt_unit_test_fw([LessEq_1, LessEq_2, LessEq_1, LessEq_2])
mt_unit_test_fw([LessEq_1, LessEq_1, LessEq_1, LessEq_2, LessEq_2, LessEq_2])
예제 #30
0
import tensorflow as tf
import numpy as np
from test_fw import mt_unit_test_fw, reduce_op_test


def ReduceSum_1(task_id):
    return reduce_op_test("SecureNN", task_id, tf.reduce_sum,
                          [[1., 2., 3.], [4., 5., 6.]], [21.])


def ReduceSum_2(task_id):
    return reduce_op_test("Helix", task_id, tf.reduce_sum,
                          [[-1., -2., -3.], [-4., -5., -6.]], [-21.])


# ===========================
# run test cases
# ===========================
mt_unit_test_fw([ReduceSum_1, ReduceSum_1])
mt_unit_test_fw([ReduceSum_2, ReduceSum_2])
mt_unit_test_fw([ReduceSum_1, ReduceSum_2])
mt_unit_test_fw([ReduceSum_1, ReduceSum_2, ReduceSum_1, ReduceSum_2])
mt_unit_test_fw([
    ReduceSum_1, ReduceSum_1, ReduceSum_1, ReduceSum_2, ReduceSum_2,
    ReduceSum_2
])