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

Class ESigmoidOp

en_ops/e_sigmoid.cc:33–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected