!4919 Change Primitive to PrimitiveC
Merge pull request !4919 from yeyunpeng2020/primitve_1pull/4919/MERGE
commit
4f928a4f7e
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "src/ir/primitive_t_value.h"
|
||||
|
||||
namespace mindspore::lite {
|
||||
std::shared_ptr<PrimitiveTValue> GetReturnPrim() {
|
||||
auto return_primitiveT = new schema::PrimitiveT;
|
||||
return_primitiveT->value.type = schema::PrimitiveType_Return;
|
||||
return_primitiveT->value.value = new schema::ReturnT;
|
||||
return std::make_shared<PrimitiveTValue>(return_primitiveT);
|
||||
}
|
||||
|
||||
std::shared_ptr<PrimitiveTValue> GetMakeTuplePrim() {
|
||||
auto make_tuple_primitiveT = new schema::PrimitiveT;
|
||||
make_tuple_primitiveT->value.type = schema::PrimitiveType_MakeTuple;
|
||||
make_tuple_primitiveT->value.value = new schema::MakeTupleT;
|
||||
return std::make_shared<PrimitiveTValue>(make_tuple_primitiveT);
|
||||
}
|
||||
|
||||
std::shared_ptr<PrimitiveTValue> GetTupleGetItemPrim() {
|
||||
auto tuple_get_item_primitiveT = new schema::PrimitiveT();
|
||||
tuple_get_item_primitiveT->value.type = schema::PrimitiveType_TupleGetItem;
|
||||
tuple_get_item_primitiveT->value.value = new schema::TupleGetItemT;
|
||||
return std::make_shared<PrimitiveTValue>(tuple_get_item_primitiveT);
|
||||
}
|
||||
} // namespace mindspore::lite
|
@ -1,91 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_LITE_SRC_ANF_IMPORTER_PRIMITIVET_H_
|
||||
#define MINDSPORE_LITE_SRC_ANF_IMPORTER_PRIMITIVET_H_
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "schema/inner/model_generated.h"
|
||||
#include "ir/value.h"
|
||||
|
||||
namespace mindspore::lite {
|
||||
|
||||
class PrimitiveTValue : public Value {
|
||||
public:
|
||||
explicit PrimitiveTValue(schema::PrimitiveT *primt) : primitive(primt) {}
|
||||
// not responsible to free primitive, the one created the dynamic memory is responsible to free it.
|
||||
~PrimitiveTValue() override = default;
|
||||
|
||||
MS_DECLARE_PARENT(PrimitiveTValue, Value)
|
||||
|
||||
schema::PrimitiveT *GetPrimitiveT() const { return this->primitive; }
|
||||
|
||||
void SetPrimitiveT(schema::PrimitiveT *primIn) { this->primitive = primIn; }
|
||||
|
||||
bool operator==(const Value &rhs) const override {
|
||||
if (rhs.isa<PrimitiveTValue>()) {
|
||||
auto other_prim = static_cast<const PrimitiveTValue &>(rhs);
|
||||
auto a = this->primitive->value.type;
|
||||
auto b = other_prim.primitive->value.type;
|
||||
return a == b;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SetInputQuantParam(const std::vector<std::vector<schema::QuantParamT>> &input_quant_param) {
|
||||
this->input_quant_param_ = input_quant_param;
|
||||
}
|
||||
|
||||
void SetOutputQuantParam(const std::vector<std::vector<schema::QuantParamT>> &output_quant_param) {
|
||||
this->output_quant_param_ = output_quant_param;
|
||||
}
|
||||
|
||||
void ClearInputOutputQuantParam() {
|
||||
input_quant_param_.clear();
|
||||
output_quant_param_.clear();
|
||||
}
|
||||
|
||||
void AddInputQuantParam(std::vector<schema::QuantParamT> quant_param) {
|
||||
this->input_quant_param_.emplace_back(quant_param);
|
||||
}
|
||||
std::vector<std::vector<schema::QuantParamT>> GetInputQuantParams() const { return input_quant_param_; }
|
||||
|
||||
void AddOutputQuantParam(std::vector<schema::QuantParamT> quant_param) {
|
||||
this->output_quant_param_.emplace_back(quant_param);
|
||||
}
|
||||
std::vector<std::vector<schema::QuantParamT>> GetOutputQuantParams() const { return output_quant_param_; }
|
||||
|
||||
void SetQuantType(schema::QuantType quant_type) { this->quant_type_ = quant_type; }
|
||||
|
||||
schema::QuantType GetQuantType() const { return quant_type_; }
|
||||
|
||||
protected:
|
||||
schema::PrimitiveT *primitive = nullptr;
|
||||
std::vector<std::vector<schema::QuantParamT>> input_quant_param_;
|
||||
std::vector<std::vector<schema::QuantParamT>> output_quant_param_;
|
||||
schema::QuantType quant_type_{schema::QuantType_QUANT_NONE};
|
||||
};
|
||||
|
||||
std::shared_ptr<PrimitiveTValue> GetReturnPrim();
|
||||
|
||||
std::shared_ptr<PrimitiveTValue> GetMakeTuplePrim();
|
||||
|
||||
std::shared_ptr<PrimitiveTValue> GetTupleGetItemPrim();
|
||||
} // namespace mindspore::lite
|
||||
|
||||
#endif // MINDSPORE_LITE_SRC_ANF_IMPORTER_PRIMITIVET_H_
|
@ -1,3 +0,0 @@
|
||||
file(GLOB_RECURSE C_OPS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
|
||||
|
||||
add_library(c_ops_mid OBJECT ${C_OPS_SRC})
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue