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