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

Method Compute

en_ops/e_leakyrelu.cc:90–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
89 }
90 void Compute(OpKernelContext *context) override
91 {
92
93 const Tensor &grad = context->input(0);
94 const Tensor &input = context->input(1);
95
96 auto grad_flat = grad.flat<float>();
97 auto input_flat = input.flat<float>();
98
99 const TensorShape &input_shape = input.shape();
100
101 Tensor *output = NULL;
102 OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output));
103 auto output_flat = output->flat<float>();
104
105 const int N = input_flat.size() / times_;
106
107 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
108 typedef void (*function)(unsigned long int eid, float *input, float *grad, int N, float *output, float alpha);
109 dlerror();
110 function leakyrelu_grad_kernel = (function)dlsym(lib, "leakyrelu_grad");
111 const char *dlsym_error = dlerror();
112 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of leakyrelu_grad failed: ", dlsym_error));
113 leakyrelu_grad_kernel(eid_, (float *)input_flat.data(), (float *)grad_flat.data(), N, (float *)output_flat.data(), alpha_);
114 };
115
116private:
117 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected