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

Method Compute

en_ops/e_reduce_max_one.cc:99–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
98 }
99 void Compute(OpKernelContext *context) override
100 {
101
102 const Tensor &grad = context->input(0);
103 const Tensor &input = context->input(1);
104
105 auto grad_flat = grad.flat<float>();
106 auto input_flat = input.flat<float>();
107
108 const TensorShape &input_shape = input.shape();
109
110 Tensor *output = NULL;
111 OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output));
112 auto output_flat = output->flat<float>();
113
114 int N = input_flat.size() / times_;
115 int M = input_shape.dim_size(0) / times_;
116 int C = input_shape.dim_size(1);
117 int L = input_shape.dim_size(2);
118
119 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
120 typedef void (*function)(unsigned long int eid, float *input, float *grad, int N, int M, int C, int L, float *output);
121 dlerror();
122 function reducemax_one_grad_kernel = (function)dlsym(lib, "reducemax_one_grad");
123 const char *dlsym_error = dlerror();
124 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of reducemax_one_grad failed: ", dlsym_error));
125 reducemax_one_grad_kernel(eid_, (float *)input_flat.data(), (float *)grad_flat.data(), N, M, C, L, (float *)output_flat.data());
126 };
127
128private:
129 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected