Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • parseAttrs - takes a set of key/value pairs for attributes and gives users an opportunity to validate the attributes passed to their custom operator.
    • int parseAttrs(std::map<std::string,std::string> attrs, 
      int* num_in,
      int* num_out);
    • Inputs: the map of attributes passed to the operator from the user
    • Outputs: num_in, num_out - the number of input/output arrays required for this operator
    • returns 1 if success, or zero if failure
  • inferType - performs type inference for this operator
    • int inferType(std::map<std::string,std::string> attrs, 
      std::vector<int> &intypes,
      std::vector<int> &outtypes);
    • Inputs: the map of attributes
    • Inputs/Outputs: intypes, outtypes - the list of input/output types that should be inferred. Values of of -1 should be defined by this operator as a specific type
    • returns 1 if success, or zero if failure
  • inferShape - performs shape inference for this operator
    • int inferShape(std::map<std::string,std::string> attrs, 
      std::vector<std::vector<unsigned int>> &inshapes,
      std::vector<std::vector<unsigned int>> &outshapes);
    • Inputs: the map of attributes
    • Inputs: inshapes - the shapes of the input arrays
    • Outputs: outshapes - the shapes of output arrays
  • fcompute - performs computation of this operator
    • int myFCompute(std::map<std::string,std::string> attrs, 
      std::vector<MXTensor> inputs,
      std::vector<MXTensor> outputs);
    • Inputs: the map of attributes
    • Input data: inputs, input tensors
    • Output data: outputs, output tensors

...

  • REGISTER_OP - registers the operator in the library
    • REGISTER_OP(sam)
      .setFCompute_cpu(myFCompute)
      .setParseAttrs(parseAttrs)
      .setInferType(inferType)
      .setInferShape(inferShape);
    • REGISTER_OP - macro that defines an custom operator object with given name
    • setFCompute_cpu - sets the FCompute function for CPU context
    • setFCompute_gpu - sets the FCompute function for GPU context
    • setParseAttrs - sets the parse attributes function
    • setInferType - sets the infer types function
    • setInferShape - sets the infer shapes function

...