eager.h 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* 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>
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"

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

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 30 31 32 33 34 35 36 37 38 39 40
} TensorObject;

typedef struct {
  PyObject_HEAD

      PyObject* container;
  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;

41 42
void BindEager(pybind11::module* m);
void BindFunctions(PyObject* module);
W
wanghuancoder 已提交
43
void BindEagerPyLayer(PyObject* module);
44 45 46

}  // namespace pybind
}  // namespace paddle