17
17
18
18
import * as tf from '@tensorflow/tfjs' ;
19
19
import { backend_util , BackendTimingInfo , DataId , DataType , KernelBackend , ModelTensorInfo , Rank , Scalar , scalar , ScalarLike , Tensor , Tensor1D , Tensor2D , Tensor3D , Tensor4D , TensorInfo , tidy , util } from '@tensorflow/tfjs' ;
20
- import { isArray , isNullOrUndefined } from 'util' ;
21
20
22
21
import { encodeInt32ArrayAsInt64 , Int64Scalar } from './int64_tensors' ;
23
22
import { TensorMetadata , TFEOpAttr , TFJSBinding } from './tfjs_binding' ;
@@ -740,7 +739,7 @@ export function getTFDType(dataType: tf.DataType): number {
740
739
export function createTensorsTypeOpAttr (
741
740
attrName : string ,
742
741
tensorsOrDtype : tf . Tensor | tf . Tensor [ ] | tf . DataType ) : TFEOpAttr {
743
- if ( isNullOrUndefined ( tensorsOrDtype ) ) {
742
+ if ( tensorsOrDtype === null || tensorsOrDtype === undefined ) {
744
743
throw new Error ( 'Invalid input tensors value.' ) ;
745
744
}
746
745
return {
@@ -757,18 +756,18 @@ export function createTensorsTypeOpAttr(
757
756
export function createOpAttr (
758
757
attrName : string , tensorsOrDtype : tf . Tensor | tf . Tensor [ ] | tf . DataType ,
759
758
value : ScalarLike ) : TFEOpAttr {
760
- if ( isNullOrUndefined ( tensorsOrDtype ) ) {
759
+ if ( tensorsOrDtype === null || tensorsOrDtype === undefined ) {
761
760
throw new Error ( 'Invalid input tensors value.' ) ;
762
761
}
763
762
return { name : attrName , type : nodeBackend ( ) . binding . TF_BOOL , value} ;
764
763
}
765
764
766
765
/** Returns the dtype number for a single or list of input Tensors. */
767
766
function getTFDTypeForInputs ( tensors : tf . Tensor | tf . Tensor [ ] ) : number {
768
- if ( isNullOrUndefined ( tensors ) ) {
767
+ if ( tensors === null || tensors === undefined ) {
769
768
throw new Error ( 'Invalid input tensors value.' ) ;
770
769
}
771
- if ( isArray ( tensors ) ) {
770
+ if ( Array . isArray ( tensors ) ) {
772
771
for ( let i = 0 ; i < tensors . length ; i ++ ) {
773
772
return getTFDType ( tensors [ i ] . dtype ) ;
774
773
}
0 commit comments