Skip to content

Instantly share code, notes, and snippets.

@Piyush3dB
Created June 1, 2017 13:04
Show Gist options
  • Save Piyush3dB/97540a551d4e1f2fc662ca354789177c to your computer and use it in GitHub Desktop.
Save Piyush3dB/97540a551d4e1f2fc662ca354789177c to your computer and use it in GitHub Desktop.
Operator Registration in NNVM
struct pair intPair;
int firstInt;
int secndInt;
const struct string attrStr;
struct allocator attrStrAlloc;
const struct string descStr;
struct allocator descStrAlloc;
const struct string opName;
struct allocator opNameAlloc;
struct Registry * registryHandle;
struct Op & operatorHandle;
struct Op & operatorHandle;
struct Op & operatorHandle;
struct Op & operatorHandle;
firstInt = 0;
secndInt = 0;
intPair = std::make_pair<int, int> (&secndInt, &firstInt);
std::allocator<char>::allocator (&attrStrAlloc);
std::basic_string<char>::basic_string (&attrStr, "inplace_pair", &attrStrAlloc);
std::allocator<char>::allocator (&descStrAlloc);
std::basic_string<char>::basic_string (&descStr, "add two data together", &descStrAlloc);
std::allocator<char>::allocator (&opNameAlloc);
std::basic_string<char>::basic_string (&opName, "add", &opNameAlloc);
registryHandle = dmlc::Registry<nnvm::Op>::Get ();
operatorHandle = dmlc::Registry<nnvm::Op>::__REGISTER_OR_GET__ (registryHandle, &opName);
operatorHandle = nnvm::Op::describe (operatorHandle, &descStr);
operatorHandle = nnvm::Op::set_num_inputs (operatorHandle, 2);
operatorHandle = nnvm::Op::set_attr<std::pair<int, int> > (operatorHandle, &attrStr, &intPair, 10);
std::basic_string<char>::~basic_string (&opName);
std::allocator<char>::~allocator (&opNameAlloc);
std::basic_string<char>::~basic_string (&descStr);
std::allocator<char>::~allocator (&descStrAlloc);
std::basic_string<char>::~basic_string (&attrStr);
std::allocator<char>::~allocator (&attrStrAlloc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment