1 /**
2 * Copyright 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 #include "schema/model_v0_generated.h"
17 #include "src/ops/populate/populate_register.h"
18 #include "nnacl/tensorlist_parameter.h"
19
20 namespace mindspore {
21 namespace lite {
22 namespace {
PopulateTensorListStackParameter(const void * prim)23 OpParameter *PopulateTensorListStackParameter(const void *prim) {
24 MS_CHECK_TRUE_RET(prim != nullptr, nullptr);
25 auto *primitive = static_cast<const schema::v0::Primitive *>(prim);
26 auto tensorList_prim = primitive->value_as_TensorListStack();
27 MS_CHECK_TRUE_MSG(tensorList_prim != nullptr, nullptr, "value is nullptr");
28 auto *stack_param = reinterpret_cast<TensorListParameter *>(malloc(sizeof(TensorListParameter)));
29 if (stack_param == nullptr) {
30 MS_LOG(ERROR) << "malloc TensorListParameter failed.";
31 return nullptr;
32 }
33 memset(stack_param, 0, sizeof(TensorListParameter));
34 stack_param->op_parameter_.type_ = schema::PrimitiveType_TensorListStack;
35 stack_param->element_dtype_ = tensorList_prim->elementDType();
36 stack_param->num_element_ = tensorList_prim->numElements();
37 return reinterpret_cast<OpParameter *>(stack_param);
38 }
39 } // namespace
40
41 Registry g_tensorListStackV0ParameterRegistry(schema::v0::PrimitiveType_TensorListStack,
42 PopulateTensorListStackParameter, SCHEMA_V0);
43 } // namespace lite
44 } // namespace mindspore
45