Skip to content

Instantly share code, notes, and snippets.

@jamesr66a
Last active September 26, 2018 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesr66a/d8f2a1503a085e62b2973c138b9e8016 to your computer and use it in GitHub Desktop.
Save jamesr66a/d8f2a1503a085e62b2973c138b9e8016 to your computer and use it in GitHub Desktop.
Attributes:
op_kind: "Aten"
node_kind "aten::foo(Tensor a, int b, Tensor[] c) -> Tensor"
class AtenOp {
AtenOp() {
Graph g;
schema_ = SchemaParser(node_kind).parseDeclaration();
for argument in schema.arguments:
g.addInput(argument.type)
Node * n = g.addNode(node_kind, g.inputs());
operation = getOperatorForNode(n);
}
IValue convertToIValue(string, caffe2blob) { ... }
IValue convertToCaffe2(string, IValue) { ... }
void run() {
Stack s;
for arg in schema_.arguments {
s.push_back(convertToIValue(arg.type, input(i));
}
operation(s);
for ret in schema_.returns {
Output(i) = convertToCaffe2(ret.type, stack[i]);
}
}
private:
Operation operation;
FunctionSchema schema_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment