Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance the Go-Report card #130 #135

Merged
merged 4 commits into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ doc/introduction/introduction
.DS_Store
*.wasm
*.onnx
/onnx-go.iml
/.idea/
20 changes: 10 additions & 10 deletions attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ func TestToOperationAttributes(t *testing.T) {
AttributeProto_GRAPHS AttributeProto_AttributeType = 10
*/
attrs, err := toOperationAttributes([]*pb.AttributeProto{
&pb.AttributeProto{
{
Name: "floats",
Type: pb.AttributeProto_FLOATS,
Floats: []float32{1, 2},
},
&pb.AttributeProto{
{
Name: "float",
Type: pb.AttributeProto_FLOAT,
F: 1,
},
&pb.AttributeProto{
{
Name: "int",
Type: pb.AttributeProto_INT,
I: 1,
},
&pb.AttributeProto{
{
Name: "ints",
Type: pb.AttributeProto_INTS,
Ints: []int64{1, 2},
},
&pb.AttributeProto{
{
Name: "string",
Type: pb.AttributeProto_STRING,
S: []byte("a"),
},
&pb.AttributeProto{
{
Name: "strings",
Type: pb.AttributeProto_STRINGS,
Strings: [][]byte{[]byte("a"), []byte("b")},
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestToOperationAttributes(t *testing.T) {

func TestToOperationAttributes_NotImplemented(t *testing.T) {
_, err := toOperationAttributes([]*pb.AttributeProto{
&pb.AttributeProto{
{
Type: pb.AttributeProto_GRAPH,
},
})
Expand All @@ -131,7 +131,7 @@ func TestToOperationAttributes_NotImplemented(t *testing.T) {
t.Fail()
}
_, err = toOperationAttributes([]*pb.AttributeProto{
&pb.AttributeProto{
{
Type: pb.AttributeProto_TENSORS,
},
})
Expand All @@ -140,7 +140,7 @@ func TestToOperationAttributes_NotImplemented(t *testing.T) {
t.Fail()
}
_, err = toOperationAttributes([]*pb.AttributeProto{
&pb.AttributeProto{
{
Type: pb.AttributeProto_GRAPHS,
},
})
Expand All @@ -149,7 +149,7 @@ func TestToOperationAttributes_NotImplemented(t *testing.T) {
t.Fail()
}
_, err = toOperationAttributes([]*pb.AttributeProto{
&pb.AttributeProto{
{
Type: pb.AttributeProto_AttributeType(-1),
},
})
Expand Down
24 changes: 22 additions & 2 deletions backend/simple/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func (n *Node) Attributes() []encoding.Attribute {
}
value = fmt.Sprintf(`"%v"`, value)
return []encoding.Attribute{
encoding.Attribute{
{
Key: "shape",
Value: "Mrecord",
},
encoding.Attribute{
{
Key: "label",
Value: value,
},
Expand Down Expand Up @@ -120,49 +120,69 @@ func NewSimpleGraph() *Graph {
}
}

// SetWeightedEdge adds a weighted edge from one node to another. If the nodes do not exist, they are added
// and are set to the nodes of the edge otherwise.
// It will panic if the IDs of the e.From and e.To are equal.
func (g *Graph) SetWeightedEdge(e graph.WeightedEdge) {
g.g.SetWeightedEdge(e)

}

// NewWeightedEdge returns a new weighted edge from the source to the destination node.
func (g *Graph) NewWeightedEdge(from, to graph.Node, w float64) graph.WeightedEdge {
return g.g.NewWeightedEdge(from, to, w)

}

// AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.
func (g *Graph) AddNode(n graph.Node) {
g.g.AddNode(n)

}

// NewNode returns a new unique Node to be added to g. The Node's ID does
// not become valid in g until the Node is added to g.
func (g *Graph) NewNode() graph.Node {
n := g.g.NewNode()
return &Node{
id: n.ID(),
}
}

// Node returns the node with the given ID if it exists in the graph,
// and nil otherwise.
func (g *Graph) Node(id int64) graph.Node {
return g.g.Node(id)
}

// Nodes returns all the nodes in the graph.
func (g *Graph) Nodes() graph.Nodes {
return g.g.Nodes()
}

// From returns all nodes in g that can be reached directly from n.
func (g *Graph) From(id int64) graph.Nodes {
return g.g.From(id)
}

// HasEdgeBetween returns whether an edge exists between nodes x and y without
// considering direction.
func (g *Graph) HasEdgeBetween(xid, yid int64) bool {
return g.g.HasEdgeBetween(xid, yid)
}

// Edge returns the edge from u to v if such an edge exists and nil otherwise.
// The node v must be directly reachable from u as defined by the From method.
func (g *Graph) Edge(uid, vid int64) graph.Edge {
return g.g.Edge(uid, vid)
}

// HasEdgeFromTo returns whether an edge exists in the graph from u to v.
func (g *Graph) HasEdgeFromTo(uid, vid int64) bool {
return g.g.HasEdgeFromTo(uid, vid)
}

// To returns all nodes in g that can reach directly to n.
func (g *Graph) To(id int64) graph.Nodes {
return g.g.To(id)
}
Expand Down
1 change: 0 additions & 1 deletion backend/testbackend/onnx/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// Package onnxtest contains an export of the onnx test files

package onnxtest
6 changes: 3 additions & 3 deletions backend/testbackend/testreport/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (

func TestCoverage(t *testing.T) {
tests := []*testbackend.TestCase{
&testbackend.TestCase{
{
Skipped: false,
Tested: true,
},
&testbackend.TestCase{
{
Skipped: true,
Tested: true,
},
&testbackend.TestCase{
{
Skipped: true,
Tested: true,
},
Expand Down
24 changes: 0 additions & 24 deletions backend/x/gorgonnx/apigen_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (a *hadamardProd) init(o onnx.Operation) error {
return nil
}


type hadamardDiv struct{}

func init() {
Expand Down Expand Up @@ -81,7 +80,6 @@ func (a *hadamardDiv) init(o onnx.Operation) error {
return nil
}


type sub struct{}

func init() {
Expand Down Expand Up @@ -119,7 +117,6 @@ func (a *sub) init(o onnx.Operation) error {
return nil
}


type add struct{}

func init() {
Expand Down Expand Up @@ -157,7 +154,6 @@ func (a *add) init(o onnx.Operation) error {
return nil
}


type abs struct{}

func init() {
Expand Down Expand Up @@ -189,7 +185,6 @@ func (a *abs) init(o onnx.Operation) error {
return nil
}


type sign struct{}

func init() {
Expand Down Expand Up @@ -221,7 +216,6 @@ func (a *sign) init(o onnx.Operation) error {
return nil
}


type ceil struct{}

func init() {
Expand Down Expand Up @@ -253,7 +247,6 @@ func (a *ceil) init(o onnx.Operation) error {
return nil
}


type floor struct{}

func init() {
Expand Down Expand Up @@ -285,7 +278,6 @@ func (a *floor) init(o onnx.Operation) error {
return nil
}


type sin struct{}

func init() {
Expand Down Expand Up @@ -317,7 +309,6 @@ func (a *sin) init(o onnx.Operation) error {
return nil
}


type cos struct{}

func init() {
Expand Down Expand Up @@ -349,7 +340,6 @@ func (a *cos) init(o onnx.Operation) error {
return nil
}


type exp struct{}

func init() {
Expand Down Expand Up @@ -381,7 +371,6 @@ func (a *exp) init(o onnx.Operation) error {
return nil
}


type logarithm struct{}

func init() {
Expand Down Expand Up @@ -413,7 +402,6 @@ func (a *logarithm) init(o onnx.Operation) error {
return nil
}


type log2 struct{}

func init() {
Expand Down Expand Up @@ -445,7 +433,6 @@ func (a *log2) init(o onnx.Operation) error {
return nil
}


type relu struct{}

func init() {
Expand Down Expand Up @@ -477,7 +464,6 @@ func (a *relu) init(o onnx.Operation) error {
return nil
}


type neg struct{}

func init() {
Expand Down Expand Up @@ -509,7 +495,6 @@ func (a *neg) init(o onnx.Operation) error {
return nil
}


type square struct{}

func init() {
Expand Down Expand Up @@ -541,7 +526,6 @@ func (a *square) init(o onnx.Operation) error {
return nil
}


type sqrt struct{}

func init() {
Expand Down Expand Up @@ -573,7 +557,6 @@ func (a *sqrt) init(o onnx.Operation) error {
return nil
}


type inverse struct{}

func init() {
Expand Down Expand Up @@ -605,7 +588,6 @@ func (a *inverse) init(o onnx.Operation) error {
return nil
}


type cube struct{}

func init() {
Expand Down Expand Up @@ -637,7 +619,6 @@ func (a *cube) init(o onnx.Operation) error {
return nil
}


type tanh struct{}

func init() {
Expand Down Expand Up @@ -669,7 +650,6 @@ func (a *tanh) init(o onnx.Operation) error {
return nil
}


type sigmoid struct{}

func init() {
Expand Down Expand Up @@ -701,7 +681,6 @@ func (a *sigmoid) init(o onnx.Operation) error {
return nil
}


type log1p struct{}

func init() {
Expand Down Expand Up @@ -733,7 +712,6 @@ func (a *log1p) init(o onnx.Operation) error {
return nil
}


type expm1 struct{}

func init() {
Expand Down Expand Up @@ -765,7 +743,6 @@ func (a *expm1) init(o onnx.Operation) error {
return nil
}


type softplus struct{}

func init() {
Expand Down Expand Up @@ -796,4 +773,3 @@ func (a *softplus) apply(g *Graph, n ...*Node) error {
func (a *softplus) init(o onnx.Operation) error {
return nil
}

2 changes: 1 addition & 1 deletion backend/x/gorgonnx/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func ggnBroadcast(a, b *gorgonia.Node) (*gorgonia.Node, *gorgonia.Node, error) {
if sameDim(a, b) {
return a, b, nil
}
// for NCHW tensors, the first dimension may be omited and must be broadcasted
// for NCHW tensors, the first dimension may be omitted and must be broadcasted
// TODO find a smarter way to achieve this
switch {
case len(a.Shape()) == 0:
Expand Down
1 change: 1 addition & 0 deletions backend/x/gorgonnx/fizzbuzz_model_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package gorgonnx

/*
fizzBuzzOnnx is generated from:

Expand Down
Loading