MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / EMaximumOp

Class EMaximumOp

en_ops/e_maximum.cc:37–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 .Output("output2: float");
36
37class EMaximumOp : public OpKernel
38{
39public:
40 explicit EMaximumOp(OpKernelConstruction *context) : OpKernel(context)
41 {
42 OP_REQUIRES_OK(context, context->GetAttr("eid_low", &eid_low_));
43 OP_REQUIRES_OK(context, context->GetAttr("eid_high", &eid_high_));
44 OP_REQUIRES_OK(context, context->GetAttr("times", &times_));
45 lib = dlopen("/home/zhangyan/jhrsgx/privacy_test/privacy_tf/sgx_tf_ops/sgx.so", RTLD_LAZY);
46 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
47 }
48 void Compute(OpKernelContext *context) override
49 {
50 const Tensor &input1 = context->input(0);
51 auto input1_flat = input1.flat<float>();
52
53 const Tensor &input2 = context->input(1);
54 auto input2_flat = input2.flat<float>();
55
56 const TensorShape &input_shape = input1.shape();
57
58 Tensor *output = NULL;
59 OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output));
60 auto output_flat = output->flat<float>();
61 int N = input1_flat.size() / times_;
62
63 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
64 typedef void (*function)(unsigned long int eid, float *input1, float *input2, int N, float *output);
65 dlerror();
66 function maximum_kernel = (function)dlsym(lib, "maximum");
67 const char *dlsym_error = dlerror();
68 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of maximum failed: ", dlsym_error));
69 maximum_kernel(eid_, (float *)input1_flat.data(), (float *)input2_flat.data(), N, (float *)output_flat.data());
70 };
71
72private:
73 void *lib;
74 int64 eid_low_;
75 int64 eid_high_;
76 int64 times_;
77};
78REGISTER_KERNEL_BUILDER(Name("EMaximum").Device(DEVICE_CPU), EMaximumOp);
79
80class EMaximumGradOp : public OpKernel

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected