public static synchronized Map < String , OpDef > opDescs ( ) { if ( DESCRIPTORS != null ) { return DESCRIPTORS ; } try ( InputStream contents = new ClassPathResource ( "ops.proto" ) . getInputStream ( ) ; BufferedInputStream bis2 = new BufferedInputStream ( contents ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( bis2 ) ) ) { org . tensorflow . framework . OpList . Builder builder = org . tensorflow . framework . OpList . newBuilder ( ) ; StringBuilder str = new StringBuilder ( ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { str . append ( line ) ; //.append("\n"); } TextFormat . getParser ( ) . merge ( str . toString ( ) , builder ) ; List < OpDef > list = builder . getOpList ( ) ; Map < String , OpDef > map = new HashMap <> ( ) ; for ( OpDef opDef : list ) { map . put ( opDef . getName ( ) , opDef ) ; } DESCRIPTORS = map ; return DESCRIPTORS ; } catch ( Exception e ) { throw new ND4JIllegalStateException ( "Unable to load tensorflow descriptors" , e ) ; } }
Get the op descriptors for tensorflow