@@ -344,87 +344,86 @@ c_enum!("Error values that can be returned.", TF_Code, Code {
344344
345345////////////////////////
346346
347- c_enum ! ( "Type of a single tensor element." , TF_DataType , DataType {
347+ c_enum ! (
348+ TF_DataType ,
349+ /// Type of a single tensor element.
350+ #[ derive( Default ) ]
351+ DataType {
348352 /// 32-bit floating point.
349- value Float = 1 ,
353+ #[ default ]
354+ Float = 1 ,
350355
351356 /// 64-bit floating point.
352- value Double = 2 ,
357+ Double = 2 ,
353358
354359 /// 32-bit signed integer.
355- value Int32 = 3 ,
360+ Int32 = 3 ,
356361
357362 /// 8-bit unsigned integer.
358- value UInt8 = 4 ,
363+ UInt8 = 4 ,
359364
360365 /// 16-bit signed integer.
361- value Int16 = 5 ,
366+ Int16 = 5 ,
362367
363368 /// 8-bit signed integer.
364- value Int8 = 6 ,
369+ Int8 = 6 ,
365370
366371 /// String.
367- value String = 7 ,
372+ String = 7 ,
368373
369374 /// Complex number composed of two 32-bit floats.
370- value Complex64 = 8 ,
375+ Complex64 = 8 ,
371376
372377 /// 64-bit signed integer.
373- value Int64 = 9 ,
378+ Int64 = 9 ,
374379
375380 /// Boolean.
376- value Bool = 10 ,
381+ Bool = 10 ,
377382
378383 /// Quantized 8-bit signed integer.
379- value QInt8 = 11 ,
384+ QInt8 = 11 ,
380385
381386 /// Quantized 8-bit unsigned integer.
382- value QUInt8 = 12 ,
387+ QUInt8 = 12 ,
383388
384389 /// Quantized 32-bit signed integer.
385- value QInt32 = 13 ,
390+ QInt32 = 13 ,
386391
387392 /// Float32 truncated to 16 bits. Only for cast ops.
388393 /// Note that this is not the same as Half. BFloat16 is not an IEEE-754
389394 /// 16-bit float. See
390395 /// <https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/bfloat16.h>
391396 /// for details.
392- value BFloat16 = 14 ,
397+ BFloat16 = 14 ,
393398
394399 /// Quantized 16-bit signed integer.
395- value QInt16 = 15 ,
400+ QInt16 = 15 ,
396401
397402 /// Quantized 16-bit unsigned integer.
398- value QUInt16 = 16 ,
403+ QUInt16 = 16 ,
399404
400405 /// 16-bit unsigned integer.
401- value UInt16 = 17 ,
406+ UInt16 = 17 ,
402407
403408 /// Complex number composed of two 64-bit floats.
404- value Complex128 = 18 ,
409+ Complex128 = 18 ,
405410
406411 /// 16-bit floating point.
407- value Half = 19 ,
412+ Half = 19 ,
408413
409414 /// TensorFlow Resource (name, container, device,...)
410- value Resource = 20 ,
415+ Resource = 20 ,
411416
412417 /// A dynamic type similar to std::any::Any.
413- value Variant = 21 ,
418+ Variant = 21 ,
414419
415420 /// 32-bit unsigned integer.
416- value UInt32 = 22 ,
421+ UInt32 = 22 ,
417422
418423 /// 64-bit unsigned integer.
419- value UInt64 = 23 ,
424+ UInt64 = 23 ,
420425} ) ;
421426
422- impl Default for DataType {
423- fn default ( ) -> DataType {
424- DataType :: Float
425- }
426- }
427-
428427impl DataType {
429428 // We don't use Into, because we don't want this to be public API.
430429 fn into_proto ( self ) -> protos:: types:: DataType {
@@ -658,7 +657,7 @@ pub type Result<T> = std::result::Result<T, Status>;
658657////////////////////////
659658
660659/// A common implementation of the sealed supertrait
661- ///
660+ ///
662661/// See https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed
663662mod private {
664663 use crate :: { BFloat16 , QInt16 , QInt32 , QInt8 , QUInt16 , QUInt8 } ;
@@ -1092,7 +1091,7 @@ where
10921091 // Zero-initialize allocated memory.
10931092 let data = tf:: TF_TensorData ( inner) ;
10941093 let byte_size = tf:: TF_TensorByteSize ( inner) ;
1095- libc:: memset ( data as * mut libc :: c_void , 0 , byte_size) ;
1094+ libc:: memset ( data, 0 , byte_size) ;
10961095
10971096 TensorDataCRepr {
10981097 inner,
0 commit comments