Skip to content
Snippets Groups Projects
Commit 3d892e42 authored by Houssem ROUIS's avatar Houssem ROUIS Committed by Olivier BICHLER
Browse files

Add python binding for Flatten

parent 6de11c4b
No related branches found
No related tags found
2 merge requests!341Error,!311fix failed onnx tests
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include <memory>
#include <pybind11/pybind11.h>
#include <string>
#include <vector>
#include "aidge/operator/OperatorTensor.hpp"
#include "aidge/operator/Flatten.hpp"
#include "aidge/utils/Attributes.hpp"
#include "aidge/utils/Types.h"
namespace py = pybind11;
namespace Aidge {
void init_Flatten(py::module &m) {
py::class_<Flatten_Op, std::shared_ptr<Flatten_Op>, OperatorTensor>(
m, "FlattenOp", py::multiple_inheritance(),
R"mydelimiter(
Initialize flatten operator
:param axis : up to which input dimensions (exclusive) should be flattened to the outer dimension of the output
between [-r;r-1] with r = input_tensor.nbDims()
:type axes : :py:class: List[Int]
)mydelimiter")
.def("get_inputs_name", &Flatten_Op::getInputsName)
.def("get_outputs_name", &Flatten_Op::getOutputsName)
.def("axis", &Flatten_Op::axis);
// Here we bind the constructor of the Flatten Node. We add an argument
// for each attribute of the operator (in here we only have 'axis') and
// the last argument is the node's name.
m.def("Flatten", &Flatten, py::arg("axis") = 1,
py::arg("name") = "",
R"mydelimiter(
Initialize a node containing a flatten operator.
:param axis : up to which input dimensions (exclusive) should be flattened to the outer dimension of the output
between [-r;r-1] with r = input_tensor.nbDims()
:type axes : :py:class: List[Int]
:param name : name of the node.
)mydelimiter");
}
} // namespace Aidge
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment