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

Class ELessEqualOp

en_ops/e_less_equal.cc:27–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected