eager.h 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Licensed 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. */
#pragma once

#include <Python.h>

W
wanghuancoder 已提交
15 16
#include "paddle/fluid/eager/pylayer/py_layer_node.h"
#include "paddle/phi/core/dense_tensor.h"
17 18
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"
W
wanghuancoder 已提交
19

20 21 22
namespace paddle {
namespace pybind {

W
wanghuancoder 已提交
23 24
typedef struct {
  PyObject_HEAD paddle::experimental::Tensor tensor;
25 26
  // Weak references
  PyObject* weakrefs;
W
wanghuancoder 已提交
27 28 29
} TensorObject;

typedef struct {
30
  PyObject_HEAD PyObject* container;
W
wanghuancoder 已提交
31 32 33 34 35 36 37 38
  PyObject* non_differentiable;
  PyObject* dirty_tensors;
  bool materialize_grads;
  std::vector<bool> forward_input_tensor_is_duplicable;
  std::vector<bool> forward_output_tensor_is_duplicable;
  std::weak_ptr<egr::GradNodePyLayer> grad_node;
} PyLayerObject;

39
void BindEager(pybind11::module* m);
J
Jack Zhou 已提交
40
void BindEagerStringTensor(pybind11::module* module);
41
void BindFunctions(PyObject* module);
W
wanghuancoder 已提交
42
void BindEagerPyLayer(PyObject* module);
43 44
void BindEagerOpFunctions(pybind11::module* module);
void BindFinalStateEagerOpFunctions(pybind11::module* module);
45 46
}  // namespace pybind
}  // namespace paddle