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

Class EEmbTransferOp

en_ops/e_emb_transfer.cc:44–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 .Output("output: float");
43
44class EEmbTransferOp : public OpKernel
45{
46public:
47 explicit EEmbTransferOp(OpKernelConstruction *context) : OpKernel(context)
48 {
49 OP_REQUIRES_OK(context, context->GetAttr("eid_low", &eid_low_));
50 OP_REQUIRES_OK(context, context->GetAttr("eid_high", &eid_high_));
51 lib = dlopen("/home/zhangyan/jhrsgx/privacy_test/privacy_tf/sgx_tf_ops/sgx.so", RTLD_LAZY);
52 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
53 }
54 void Compute(OpKernelContext *context) override
55 {
56
57 const Tensor &input = context->input(0);
58 auto input_flat = input.flat<float>();
59
60 const TensorShape &input_shape = input.shape();
61 Tensor *output = NULL;
62 TensorShape output_shape;
63 output_shape.AddDim(input_shape.dim_size(0) * 10);
64 output_shape.AddDim(input_shape.dim_size(1) - 1);
65 OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));
66 auto output_flat = output->flat<float>();
67 int M = input_shape.dim_size(0);
68 int C = input_shape.dim_size(1);
69 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
70 typedef void (*function)(unsigned long int eid, float *input, float *output, int M, int C);
71 dlerror();
72 function emb_transfer_kernel = (function)dlsym(lib, "emb_transfer");
73 const char *dlsym_error = dlerror();
74 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of emb_transfer failed: ", dlsym_error));
75 emb_transfer_kernel(eid_, (float *)input_flat.data(), (float *)output_flat.data(), M, C);
76 };
77
78private:
79 void *lib;
80 int64 eid_low_;
81 int64 eid_high_;
82};
83REGISTER_KERNEL_BUILDER(Name("EEmbTransfer").Device(DEVICE_CPU), EEmbTransferOp);
84
85class EEmbTransferGradOp : public OpKernel

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected