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

Class ESoftmaxOp

en_ops/e_softmax.cc:34–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected