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

Method Compute

en_ops/e_softmax.cc:87–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected