1 /** 2 * Copyright 2020-2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "src/delegate/tensorrt/op/tensorrt_op.h" 18 19 namespace mindspore::lite { GetPrimitive()20const schema::Primitive *TensorRTOp::GetPrimitive() { return this->op_primitive_; } 21 AddInnerInTensors(ITensorHelper tensor)22void TensorRTOp::AddInnerInTensors(ITensorHelper tensor) { this->tensorrt_in_tensors_.push_back(tensor); } 23 AddInnerOutTensors(ITensorHelper tensor)24void TensorRTOp::AddInnerOutTensors(ITensorHelper tensor) { this->tensorrt_out_tensors_.push_back(tensor); } 25 GetInnerOutTensor()26std::vector<ITensorHelper> &TensorRTOp::GetInnerOutTensor() { return this->tensorrt_out_tensors_; } 27 GetInnerInTensors()28std::vector<ITensorHelper> &TensorRTOp::GetInnerInTensors() { return this->tensorrt_in_tensors_; } 29 GetOpName()30std::string TensorRTOp::GetOpName() { return this->op_name_; } 31 inputs()32std::vector<mindspore::MSTensor> &TensorRTOp::inputs() { return this->in_tensors_; } 33 outputs()34std::vector<mindspore::MSTensor> &TensorRTOp::outputs() { return this->out_tensors_; } 35 type() const36schema::PrimitiveType TensorRTOp::type() const { return this->type_; } 37 set_in_ops(const std::vector<TensorRTOp * > & in_ops)38void TensorRTOp::set_in_ops(const std::vector<TensorRTOp *> &in_ops) { this->in_ops_ = in_ops; } 39 set_out_ops(const std::vector<TensorRTOp * > & out_ops)40void TensorRTOp::set_out_ops(const std::vector<TensorRTOp *> &out_ops) { this->out_ops_ = out_ops; } 41 in_ops() const42const std::vector<TensorRTOp *> &TensorRTOp::in_ops() const { return this->in_ops_; } 43 out_ops() const44const std::vector<TensorRTOp *> &TensorRTOp::out_ops() const { return this->out_ops_; } 45 IsShapeKnown()46bool TensorRTOp::IsShapeKnown() { 47 if (this->in_tensors_[0].Shape().size() == 0) { 48 return false; 49 } else { 50 if (this->in_tensors_[0].Shape()[0] == -1) { 51 return false; 52 } 53 } 54 return true; 55 } 56 } // namespace mindspore::lite 57