Xuejun/remove api tensor related (#15877)
* [Remove APIs] remove api set_partial_shape() Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com> * [Remove APIs] remove api set_element_type() Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com> * [Remove APIs] remove api set_tensor_type() Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com> * Revert "[Remove APIs] remove api set_tensor_type()" This reverts commit96f89e222d
. * Revert "[Remove APIs] remove api set_element_type()" This reverts commit33ebb61977
. * Apply suggestions from code review --------- Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com> Co-authored-by: Evgenya Stepyreva <eva.my.link@gmail.com> Co-authored-by: Evgenya Stepyreva <evgenya.stepyreva@intel.com>
This commit is contained in:
parent
07437eec1e
commit
3be946371d
@ -70,9 +70,6 @@ public:
|
||||
OPENVINO_DEPRECATED(
|
||||
"set_element_type() is deprecated. To change Tensor element type please change the Parameter type")
|
||||
void set_element_type(const element::Type& elemenet_type);
|
||||
OPENVINO_DEPRECATED(
|
||||
"set_partial_shape() is deprecated. To change Tensor partial shape please change the Parameter partial shape")
|
||||
void set_partial_shape(const PartialShape& partial_shape);
|
||||
|
||||
/// \brief sets lower bound value description
|
||||
void set_lower_value(const ov::Tensor& value);
|
||||
@ -148,6 +145,7 @@ protected:
|
||||
friend OPENVINO_API std::string get_ov_tensor_legacy_name(const Tensor& tensor);
|
||||
friend OPENVINO_API void set_ov_tensor_legacy_name(Tensor& tensor, const std::string& tensor_name);
|
||||
friend class pass::ReverseShapeAndTypeInfer;
|
||||
friend class ngraph::runtime::HostTensor;
|
||||
};
|
||||
|
||||
OPENVINO_API
|
||||
|
@ -38,17 +38,13 @@ ov::descriptor::Tensor::Tensor(const element::Type& element_type,
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
void ov::descriptor::Tensor::set_tensor_type(const element::Type& element_type, const PartialShape& pshape) {
|
||||
set_element_type(element_type);
|
||||
set_partial_shape(pshape);
|
||||
m_partial_shape = pshape;
|
||||
m_shape_changed = true;
|
||||
}
|
||||
|
||||
void ov::descriptor::Tensor::set_element_type(const element::Type& element_type) {
|
||||
m_element_type = element_type;
|
||||
}
|
||||
|
||||
void ov::descriptor::Tensor::set_partial_shape(const PartialShape& partial_shape) {
|
||||
m_partial_shape = partial_shape;
|
||||
m_shape_changed = true;
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
void ov::descriptor::Tensor::invalidate_values() {
|
||||
|
@ -143,9 +143,8 @@ void runtime::HostTensor::set_shape(const Shape& shape) {
|
||||
shape,
|
||||
" must be compatible with the partial shape: ",
|
||||
get_partial_shape());
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
m_descriptor->set_partial_shape(shape);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
m_descriptor->m_partial_shape = shape;
|
||||
m_descriptor->m_shape_changed = true;
|
||||
}
|
||||
|
||||
void runtime::HostTensor::set_unary(const HostTensorPtr& arg) {
|
||||
|
@ -233,13 +233,12 @@ public:
|
||||
local_op = op->clone_with_new_inputs(new_inputs);
|
||||
} else {
|
||||
local_op = local_op_default;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
for (size_t i = 0; i < local_op->get_input_size(); i++) {
|
||||
if (dynamic_cast<ov::opset1::Parameter*>(local_op->get_input_node_ptr(i))) {
|
||||
local_op->get_input_tensor(i).set_partial_shape(input_shapes[i].to_partial_shape());
|
||||
if (auto parameter = dynamic_cast<ov::opset1::Parameter*>(local_op->get_input_node_ptr(i))) {
|
||||
parameter->set_partial_shape(input_shapes[i].to_partial_shape());
|
||||
parameter->validate_and_infer_types();
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
local_op->validate_and_infer_types();
|
||||
|
@ -145,7 +145,10 @@ protected:
|
||||
}
|
||||
|
||||
std::vector<ov::Shape> secondParameterShapes;
|
||||
opToShapeInfer->get_input_tensor(0).set_partial_shape(targetShapes.front());
|
||||
if (auto parameter = dynamic_cast<ov::op::v0::Parameter*>(opToShapeInfer->get_input_node_ptr(0))) {
|
||||
parameter->set_partial_shape(targetShapes.front());
|
||||
parameter->validate_and_infer_types();
|
||||
}
|
||||
opToShapeInfer->validate_and_infer_types();
|
||||
targetShapes.push_back(opToShapeInfer->get_output_shape(0));
|
||||
}
|
||||
|
@ -142,7 +142,10 @@ protected:
|
||||
}
|
||||
|
||||
std::vector<ov::Shape> secondParameterShapes;
|
||||
opToShapeInfer->get_input_tensor(0).set_partial_shape(targetShapes.front());
|
||||
if (auto parameter = dynamic_cast<ov::op::v0::Parameter*>(opToShapeInfer->get_input_node_ptr(0))) {
|
||||
parameter->set_partial_shape(targetShapes.front());
|
||||
parameter->validate_and_infer_types();
|
||||
}
|
||||
opToShapeInfer->validate_and_infer_types();
|
||||
targetShapes.push_back(opToShapeInfer->get_output_shape(0));
|
||||
}
|
||||
|
@ -75,23 +75,27 @@ inline void update_output_tensors(ov::TensorVector& output_values, const ngraph:
|
||||
} // namespace
|
||||
|
||||
class TemporaryOverrideOutputs {
|
||||
std::shared_ptr<ov::Node> node;
|
||||
std::vector<ov::PartialShape> orig_shapes;
|
||||
std::shared_ptr<ov::Model> model;
|
||||
std::unordered_map<std::shared_ptr<ov::descriptor::Tensor>, ov::PartialShape> orig_paramter_shapes_map;
|
||||
|
||||
public:
|
||||
TemporaryOverrideOutputs(std::shared_ptr<ov::Node> node, const std::vector<ov::Tensor>& args) : node(node) {
|
||||
for (size_t i = 0; i < args.size(); ++i) {
|
||||
auto output = node->get_input_source_output(i);
|
||||
orig_shapes.push_back(output.get_partial_shape());
|
||||
output.get_tensor().set_partial_shape(args[i].get_shape());
|
||||
TemporaryOverrideOutputs(std::shared_ptr<ov::Model>& model,
|
||||
const std::unordered_map<std::shared_ptr<ov::descriptor::Tensor>, ov::Tensor>& tensor_map)
|
||||
: model(model) {
|
||||
for (const auto& param : model->get_parameters()) {
|
||||
auto output_tensor = param->output(0).get_tensor_ptr();
|
||||
orig_paramter_shapes_map.insert({output_tensor, param->get_partial_shape()});
|
||||
param->set_partial_shape(tensor_map.at(output_tensor).get_shape());
|
||||
}
|
||||
model->validate_nodes_and_infer_types();
|
||||
}
|
||||
|
||||
~TemporaryOverrideOutputs() {
|
||||
for (size_t i = 0; i < orig_shapes.size(); ++i) {
|
||||
auto output = node->get_input_source_output(i);
|
||||
output.get_tensor().set_partial_shape(orig_shapes[i]);
|
||||
for (const auto& param : model->get_parameters()) {
|
||||
auto output_tensor = param->output(0).get_tensor_ptr();
|
||||
param->set_partial_shape(orig_paramter_shapes_map.at(output_tensor));
|
||||
}
|
||||
model->validate_nodes_and_infer_types();
|
||||
}
|
||||
};
|
||||
|
||||
@ -147,12 +151,13 @@ bool ov::runtime::interpreter::INTExecutable::call(std::vector<ov::Tensor>& outp
|
||||
results_map.emplace(output, output_count);
|
||||
}
|
||||
|
||||
auto overrider = TemporaryOverrideOutputs(m_model, tensor_map);
|
||||
|
||||
// for each ordered op in the graph
|
||||
for (const auto& op : m_nodes) {
|
||||
if (std::dynamic_pointer_cast<ov::op::v0::Parameter>(op)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// get op inputs from map
|
||||
std::vector<ov::Tensor> op_inputs;
|
||||
for (auto input : op->inputs()) {
|
||||
@ -160,7 +165,6 @@ bool ov::runtime::interpreter::INTExecutable::call(std::vector<ov::Tensor>& outp
|
||||
op_inputs.push_back(tensor_map.at(tensor));
|
||||
}
|
||||
|
||||
TemporaryOverrideOutputs overrider(op, op_inputs);
|
||||
OutputVector output_ports;
|
||||
for (size_t i = 0; i < op->inputs().size(); ++i) {
|
||||
output_ports.push_back(op->get_input_source_output(i));
|
||||
|
Loading…
Reference in New Issue
Block a user