File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed 
extension/android/executorch_android/src/main/java/org/pytorch/executorch Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 1+ package  org .pytorch .executorch ;
2+ 
3+ import  com .facebook .soloader .nativeloader .NativeLoader ;
4+ import  com .facebook .soloader .nativeloader .SystemDelegate ;
5+ import  com .facebook .jni .annotations .DoNotStrip ;
6+ 
7+ public  class  Runtime  {
8+     private  static  boolean  initialized  = false ;
9+ 
10+     static  {
11+         if  (!NativeLoader .isInitialized ()) {
12+             NativeLoader .init (new  SystemDelegate ());
13+         }
14+         // Loads libexecutorch.so from jniLibs 
15+         NativeLoader .loadLibrary ("executorch" );
16+         initialized  = true ;
17+     }
18+ 
19+     public  static  boolean  isInitialized () {
20+         return  initialized ;
21+     }
22+ 
23+     @ DoNotStrip 
24+     public  static  native  String [] getRegisteredOps ();
25+ 
26+     @ DoNotStrip 
27+     public  static  native  String [] getRegisteredBackends ();
28+ }
Original file line number Diff line number Diff line change 1313import  com .facebook .soloader .nativeloader .NativeLoader ;
1414import  com .facebook .soloader .nativeloader .SystemDelegate ;
1515import  org .pytorch .executorch .annotations .Experimental ;
16+ import  org .pytorch .executorch .Runtime ;
1617
1718/** 
1819 * LlmModule is a wrapper around the Executorch LLM. It provides a simple interface to generate text 
@@ -27,11 +28,9 @@ public class LlmModule {
2728  public  static  final  int  MODEL_TYPE_TEXT_VISION  = 2 ;
2829
2930  static  {
30-     if  (!NativeLoader .isInitialized ()) {
31-       NativeLoader . init ( new  SystemDelegate () );
31+     if  (!Runtime .isInitialized ()) {
32+          throw   new  IllegalStateException ( "ExecuTorch runtime not initialized." );
3233    }
33-     NativeLoader .loadLibrary ("executorch" );
34-   }
3534
3635  private  final  HybridData  mHybridData ;
3736  private  static  final  int  DEFAULT_SEQ_LEN  = 128 ;
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments