You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/04/07 03:54:31 UTC

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4459: [RUNTIME] Implement TVMDSOOp(TensorFlow custom op) for TVM runtime

tqchen commented on a change in pull request #4459: [RUNTIME] Implement TVMDSOOp(TensorFlow custom op) for TVM runtime
URL: https://github.com/apache/incubator-tvm/pull/4459#discussion_r404520154
 
 

 ##########
 File path: python/tvm/contrib/tf_op/module.py
 ##########
 @@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Module container of TensorFlow TVMDSO op"""
+import tensorflow as tf
+from tensorflow.python.framework import load_library
+
+
+class OpModule():
+    """Module container of TensorFlow TVMDSO op which wraps exported
+    TVM op implementation library to be called on TensorFlow side"""
+
+    def __init__(self, lib_path):
+        self.lib_path = lib_path
+
+    def func(self, name, output_dtype=None, output_shape=None):
+        """Get tvm op function wrapped as TensorFlow tensor to tensor function
+
+        Parameters
+        ----------
+        name: str
+            function name
+        output_dtype: str or TensorFlow datatype
+            Output datatype, default is float32
+        output_shape: List of integer/tf scalar tensor or tf shape tensor
+            Output shape, default the same with first input's shape
+
+        Returns
+        ----------
+        Func object that acts as TensorFlow tensor to tensor function.
+        """
+        return TensorFunc(self.lib_path, name, output_dtype, output_shape)
+
+    def __getitem__(self, func_name):
+        return self.func(func_name)
+
+
+class TensorFunc():
 
 Review comment:
   `style: remove ()`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services