• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_C_EAGER_ABSTRACT_FUNCTION_H_
16 #define TENSORFLOW_C_EAGER_ABSTRACT_FUNCTION_H_
17 
18 #include "tensorflow/core/framework/function.pb.h"
19 #include "tensorflow/core/platform/status.h"
20 
21 namespace tensorflow {
22 
23 // A traced function: this hides the complexity of converting the serialized
24 // representation between various supported formats e.g. FunctionDef and Mlir
25 // function.
26 class AbstractFunction {
27  protected:
28   enum AbstractFunctionKind { kGraph, kMlir };
AbstractFunction(AbstractFunctionKind kind)29   explicit AbstractFunction(AbstractFunctionKind kind) : kind_(kind) {}
30 
31  public:
32   // Returns which subclass is this instance of.
getKind()33   AbstractFunctionKind getKind() const { return kind_; }
34   virtual ~AbstractFunction() = default;
35 
36   // Returns the AbstractFunction as a FunctionDef.
37   virtual Status GetFunctionDef(FunctionDef**) = 0;
38 
39  private:
40   const AbstractFunctionKind kind_;
41 };
42 
43 }  // namespace tensorflow
44 
45 #endif  // TENSORFLOW_C_EAGER_ABSTRACT_FUNCTION_H_
46