Go: Bugfix in generated functions for operations.
Fixes #6799 Change: 144288761
This commit is contained in:
parent
77f5f5e13e
commit
2abef5cebb
@ -41,7 +41,6 @@ func Const(scope *Scope, value interface{}) (output tf.Output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scope.AddOperation(tf.OpSpec{
|
return scope.AddOperation(tf.OpSpec{
|
||||||
Name: scope.opName("Const"),
|
|
||||||
Type: "Const",
|
Type: "Const",
|
||||||
Attrs: map[string]interface{}{
|
Attrs: map[string]interface{}{
|
||||||
"dtype": t.DataType(),
|
"dtype": t.DataType(),
|
||||||
|
@ -60,11 +60,19 @@ func (s *Scope) Finalize() (*tf.Graph, error) {
|
|||||||
|
|
||||||
// AddOperation adds the operation to the Graph managed by s.
|
// AddOperation adds the operation to the Graph managed by s.
|
||||||
//
|
//
|
||||||
// See Graph.AddOperation.
|
// If there is a name prefix associated with s (such as if s was created
|
||||||
|
// by a call to SubScope), then this prefix will be applied to the name
|
||||||
|
// of the operation being added. See also Graph.AddOperation.
|
||||||
func (s *Scope) AddOperation(args tf.OpSpec) *tf.Operation {
|
func (s *Scope) AddOperation(args tf.OpSpec) *tf.Operation {
|
||||||
if s.Err() != nil {
|
if s.Err() != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if args.Name == "" {
|
||||||
|
args.Name = args.Type
|
||||||
|
}
|
||||||
|
if s.namespace != "" {
|
||||||
|
args.Name = s.namespace + "/" + args.Name
|
||||||
|
}
|
||||||
op, err := s.graph.AddOperation(args)
|
op, err := s.graph.AddOperation(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.UpdateErr(args.Type, err)
|
s.UpdateErr(args.Type, err)
|
||||||
|
@ -84,6 +84,15 @@ func TestScopeFinalize(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMultipleGeneratedOps(t *testing.T) {
|
||||||
|
s := NewScope()
|
||||||
|
Placeholder(s.SubScope("x"), tf.Float)
|
||||||
|
Placeholder(s.SubScope("y"), tf.Float)
|
||||||
|
if _, err := s.Finalize(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Example() {
|
func Example() {
|
||||||
// This example creates a Graph that multiplies a constant matrix with
|
// This example creates a Graph that multiplies a constant matrix with
|
||||||
// a matrix to be provided during graph execution (via
|
// a matrix to be provided during graph execution (via
|
||||||
|
Loading…
x
Reference in New Issue
Block a user