Skip to content

Commit 98bcbc1

Browse files
committed
Added Function.Builder and Function.Shape methods.
1 parent 36ac40e commit 98bcbc1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

compute/xla/function.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ func (f *Function) Parent() compute.Function {
4343
return f.parent
4444
}
4545

46+
// Builder returns the builder for this function.
47+
func (f *Function) Builder() compute.Builder {
48+
return f.builder
49+
}
50+
51+
// Shape returns the shape of a value in the function.
52+
func (f *Function) Shape(v compute.Value) (shapes.Shape, error) {
53+
var s shapes.Shape
54+
n, ok := v.(*Node)
55+
if !ok {
56+
return s, errors.Errorf("value is not a Node for a XLA backend, instead got a %T", v)
57+
}
58+
if err := f.CheckValid(); err != nil {
59+
return s, err
60+
}
61+
return n.shape, nil
62+
}
63+
4664
// Closure creates a new closure function, within this function.
4765
func (f *Function) Closure() (compute.Function, error) {
4866
if err := f.CheckValid(); err != nil {

0 commit comments

Comments
 (0)