Skip to content

Instantly share code, notes, and snippets.

@fengb

fengb/graph.zig Secret

Created December 18, 2019 17:14
Show Gist options
  • Save fengb/e2ab6f36bd720016d5f970109dc2b395 to your computer and use it in GitHub Desktop.
Save fengb/e2ab6f36bd720016d5f970109dc2b395 to your computer and use it in GitHub Desktop.
const Add = struct {
operation: Operation,
nodes: [2]Node,
pub fn init(left: Tensor(f64, 0), right: Tensor(f64, 0)) Add {
return .{
.operation = .{ .inputs = inputs },
.nodes = [_]Node{ left, right },
};
}
pub fn inputs(operation: *const Operation) []const Node {
const self = @fieldParentPtr(Add, "operation", operation);
return &self.nodes;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment