@@ -153,10 +153,10 @@ impl Graph {
153
153
154
154
/// Returns the graph definition as a protobuf.
155
155
pub fn graph_def ( & self ) -> Result < Vec < u8 > > {
156
- let status = Status :: new ( ) ;
156
+ let mut status = Status :: new ( ) ;
157
157
unsafe {
158
158
let c_buffer = tf:: TF_NewBuffer ( ) ;
159
- tf:: TF_GraphToGraphDef ( self . gimpl . inner , c_buffer, status. inner ) ;
159
+ tf:: TF_GraphToGraphDef ( self . gimpl . inner , c_buffer, status. inner ( ) ) ;
160
160
if status. is_ok ( ) {
161
161
Ok ( Buffer :: from_c ( c_buffer, true ) . into ( ) )
162
162
} else {
@@ -173,9 +173,9 @@ impl Graph {
173
173
/// Returns an error if:
174
174
/// * `output` is not in `graph`.
175
175
pub fn num_dims ( & self , output : Output ) -> Result < c_int > {
176
- let status = Status :: new ( ) ;
176
+ let mut status = Status :: new ( ) ;
177
177
unsafe {
178
- let val = tf:: TF_GraphGetTensorNumDims ( self . gimpl . inner , output. to_c ( ) , status. inner ) ;
178
+ let val = tf:: TF_GraphGetTensorNumDims ( self . gimpl . inner , output. to_c ( ) , status. inner ( ) ) ;
179
179
if status. is_ok ( ) { Ok ( val) } else { Err ( status) }
180
180
}
181
181
}
@@ -185,7 +185,7 @@ impl Graph {
185
185
/// Returns an error if:
186
186
/// * `output` is not in `graph`.
187
187
pub fn tensor_shape ( & self , output : Output ) -> Result < Shape > {
188
- let status = Status :: new ( ) ;
188
+ let mut status = Status :: new ( ) ;
189
189
let n = try!( self . num_dims ( output) ) ;
190
190
if n == -1 {
191
191
return Ok ( Shape ( None ) ) ;
@@ -196,7 +196,7 @@ impl Graph {
196
196
output. to_c ( ) ,
197
197
dims. as_mut_ptr ( ) ,
198
198
dims. len ( ) as c_int ,
199
- status. inner ) ;
199
+ status. inner ( ) ) ;
200
200
if status. is_ok ( ) {
201
201
dims. set_len ( n as usize ) ;
202
202
Ok ( Shape ( Some ( dims. iter ( ) . map ( |x| if * x < 0 { None } else { Some ( * x) } ) . collect ( ) ) ) )
@@ -212,10 +212,13 @@ impl Graph {
212
212
options : & ImportGraphDefOptions )
213
213
-> Result < ( ) > {
214
214
let buf = Buffer :: from ( graph_def) ;
215
- let status = Status :: new ( ) ;
215
+ let mut status = Status :: new ( ) ;
216
216
unsafe {
217
- tf:: TF_GraphImportGraphDef ( self . gimpl . inner , buf. inner ( ) , options. inner , status. inner ) ;
218
- status. as_result ( )
217
+ tf:: TF_GraphImportGraphDef ( self . gimpl . inner ,
218
+ buf. inner ( ) ,
219
+ options. inner ,
220
+ status. inner ( ) ) ;
221
+ status. into_result ( )
219
222
}
220
223
}
221
224
}
@@ -310,9 +313,9 @@ impl Operation {
310
313
#[ allow( missing_docs) ]
311
314
pub fn output_list_length ( & self , arg_name : & str ) -> Result < usize > {
312
315
let c_arg_name = try!( CString :: new ( arg_name) ) ;
313
- let status = Status :: new ( ) ;
316
+ let mut status = Status :: new ( ) ;
314
317
let length = unsafe {
315
- tf:: TF_OperationOutputListLength ( self . inner , c_arg_name. as_ptr ( ) , status. inner )
318
+ tf:: TF_OperationOutputListLength ( self . inner , c_arg_name. as_ptr ( ) , status. inner ( ) )
316
319
} ;
317
320
if status. is_ok ( ) {
318
321
Ok ( length as usize )
@@ -340,9 +343,9 @@ impl Operation {
340
343
#[ allow( missing_docs) ]
341
344
pub fn input_list_length ( & self , arg_name : & str ) -> Result < usize > {
342
345
let c_arg_name = try!( CString :: new ( arg_name) ) ;
343
- let status = Status :: new ( ) ;
346
+ let mut status = Status :: new ( ) ;
344
347
let length = unsafe {
345
- tf:: TF_OperationInputListLength ( self . inner , c_arg_name. as_ptr ( ) , status. inner )
348
+ tf:: TF_OperationInputListLength ( self . inner , c_arg_name. as_ptr ( ) , status. inner ( ) )
346
349
} ;
347
350
if status. is_ok ( ) {
348
351
Ok ( length as usize )
@@ -548,8 +551,8 @@ impl<'a> OperationDescription<'a> {
548
551
/// Builds the operation and adds it to the graph.
549
552
pub fn finish ( mut self ) -> Result < Operation > {
550
553
self . finished = true ; // used by the drop code
551
- let status = Status :: new ( ) ;
552
- let operation = unsafe { tf:: TF_FinishOperation ( self . inner , status. inner ) } ;
554
+ let mut status = Status :: new ( ) ;
555
+ let operation = unsafe { tf:: TF_FinishOperation ( self . inner , status. inner ( ) ) } ;
553
556
if status. is_ok ( ) {
554
557
Ok ( Operation {
555
558
inner : operation,
@@ -818,15 +821,15 @@ impl<'a> OperationDescription<'a> {
818
821
#[ allow( trivial_numeric_casts) ]
819
822
pub fn set_attr_tensor_shape_proto ( & mut self , attr_name : & str , value : & [ u8 ] ) -> Result < ( ) > {
820
823
let c_attr_name = try!( CString :: new ( attr_name) ) ;
821
- let status = Status :: new ( ) ;
824
+ let mut status = Status :: new ( ) ;
822
825
unsafe {
823
826
tf:: TF_SetAttrTensorShapeProto ( self . inner ,
824
827
c_attr_name. as_ptr ( ) ,
825
828
value. as_ptr ( ) as * const c_void ,
826
829
value. len ( ) as size_t ,
827
- status. inner ) ;
830
+ status. inner ( ) ) ;
828
831
}
829
- status. as_result ( )
832
+ status. into_result ( )
830
833
}
831
834
832
835
/// Sets an attribute with an array of `TensorShapeProto` protobufs.
@@ -840,16 +843,16 @@ impl<'a> OperationDescription<'a> {
840
843
. map ( |x| x. as_ref ( ) . as_ptr ( ) as * const c_void )
841
844
. collect ( ) ;
842
845
let lens: Vec < size_t > = value. iter ( ) . map ( |x| x. as_ref ( ) . len ( ) as size_t ) . collect ( ) ;
843
- let status = Status :: new ( ) ;
846
+ let mut status = Status :: new ( ) ;
844
847
unsafe {
845
848
tf:: TF_SetAttrTensorShapeProtoList ( self . inner ,
846
849
c_attr_name. as_ptr ( ) ,
847
850
ptrs. as_ptr ( ) ,
848
851
lens. as_ptr ( ) ,
849
852
ptrs. len ( ) as c_int ,
850
- status. inner ) ;
853
+ status. inner ( ) ) ;
851
854
}
852
- status. as_result ( )
855
+ status. into_result ( )
853
856
}
854
857
855
858
/// Sets a tensor-valued attribute.
@@ -858,14 +861,14 @@ impl<'a> OperationDescription<'a> {
858
861
value : Tensor < T > )
859
862
-> Result < ( ) > {
860
863
let c_attr_name = try!( CString :: new ( attr_name) ) ;
861
- let status = Status :: new ( ) ;
864
+ let mut status = Status :: new ( ) ;
862
865
unsafe {
863
866
tf:: TF_SetAttrTensor ( self . inner ,
864
867
c_attr_name. as_ptr ( ) ,
865
868
value. into_ptr ( ) ,
866
- status. inner ) ;
869
+ status. inner ( ) ) ;
867
870
}
868
- status. as_result ( )
871
+ status. into_result ( )
869
872
}
870
873
871
874
/// Sets an attribute which holds an array of tensors.
@@ -874,33 +877,33 @@ impl<'a> OperationDescription<'a> {
874
877
value : T )
875
878
-> Result < ( ) > {
876
879
let c_attr_name = try!( CString :: new ( attr_name) ) ;
877
- let status = Status :: new ( ) ;
880
+ let mut status = Status :: new ( ) ;
878
881
unsafe {
879
882
let ptrs: Vec < * mut tf:: TF_Tensor > = value. into_iter ( ) . map ( |x| x. into_ptr ( ) ) . collect ( ) ;
880
883
tf:: TF_SetAttrTensorList ( self . inner ,
881
884
c_attr_name. as_ptr ( ) ,
882
885
ptrs. as_ptr ( ) ,
883
886
ptrs. len ( ) as c_int ,
884
- status. inner ) ;
887
+ status. inner ( ) ) ;
885
888
}
886
- status. as_result ( )
889
+ status. into_result ( )
887
890
}
888
891
889
892
/// Sets an attribute with an `AttrValue` proto.
890
893
#[ allow( trivial_numeric_casts) ]
891
894
pub fn set_attr_to_attr_value_proto ( & mut self , attr_name : & str , value : & [ u8 ] ) -> Result < ( ) > {
892
895
let c_attr_name = try!( CString :: new ( attr_name) ) ;
893
- let status = Status :: new ( ) ;
896
+ let mut status = Status :: new ( ) ;
894
897
unsafe {
895
898
tf:: TF_SetAttrValueProto ( self . inner ,
896
899
c_attr_name. as_ptr ( ) ,
897
900
value. as_ptr ( ) as * const c_void ,
898
901
// Allow trivial_numeric_casts because usize is not
899
902
// necessarily size_t.
900
903
value. len ( ) as size_t ,
901
- status. inner ) ;
904
+ status. inner ( ) ) ;
902
905
}
903
- status. as_result ( )
906
+ status. into_result ( )
904
907
}
905
908
}
906
909
0 commit comments