As I know I don’t think is possibile now. Is your the same case as?
  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      TensorArray support dtype of Custom defined  class object? 7
    

    
      
        opened 
        
          
        
        Oct 15, 2021
      
      


      
        
          
          joan126
        
      
    

    
        type:others
    
  


  
    This template is for miscellaneous issues not covered by the other issue categor…ies.

For questions on how to work with TensorFlow, or support for problems that are
not verified bugs in TensorFlow, please go to
[Discourse](https://discuss.tensorflow.org/).

If you are reporting a vulnerability, please use the [dedicated reporting process](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md).

For high-level discussions about TensorFlow, please post to discuss@tensorflow.org, for questions about the development or internal workings of TensorFlow, or if you would like to know how to contribute to TensorFlow, please post to developers@tensorflow.org.
  

  

  
    
    
  

  


I think you could find a short analisys in this ttf-encrypted TF big tensor library ticket:

  

      github.com/tf-encrypted/tf-big
  

  
    
  
	  
  

  
    
      Extend support to tensors 3
    

    
      
        opened 
        
          
        
        Jul 2, 2019
      
      


      
        
          
          mortendahl
        
      
    

    
    
  


  
    Right now we only support matrices; using eg https://eigen.tuxfamily.org/dox-dev…el/unsupported/eigen_tensors.html we might support more general tensors as well
  

  

  
    
    
  

  


Also, more in general, have you tried to see what was their approach in:

  
      

      github.com
  

  
    

GitHub - tf-encrypted/tf-encrypted: A Framework for Encrypted Machine Learning... 4


  A Framework for Encrypted Machine Learning in TensorFlow - GitHub - tf-encrypted/tf-encrypted: A Framework for Encrypted Machine Learning in TensorFlow

  

  
    
    
  

  



  
      

      github.com
  

  
    

GitHub - tf-encrypted/tf-seal: Bridge between TensorFlow and the Microsoft SEAL... 1


  Bridge between TensorFlow and the Microsoft SEAL homomorphic encryption library - GitHub - tf-encrypted/tf-seal: Bridge between TensorFlow and the Microsoft SEAL homomorphic encryption library

  

  
    
    
  

  



  
      

      github.com
  

  
    

GitHub - tf-encrypted/tf-pjc: Bridge between TensorFlow and Google's Private... 1


  Bridge between TensorFlow and Google's Private Join and Compute library - GitHub - tf-encrypted/tf-pjc: Bridge between TensorFlow and Google's Private Join and Compute library