code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
/* * Copyright (C) 2010-2019 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_reshape_s8.c * Description: Reshape a s8 vector * * $Date: September 2019 * $Revision: V.1.0.0 * * Target Processor: Cortex-M cores * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" /** * @ingroup groupNN */ /** * @addtogroup Reshape * @{ */ /** * Basic s8 reshape function. * * Refer header file for details. * */ void arm_reshape_s8(const int8_t *input, int8_t *output, const uint32_t total_size) { memcpy(output, input, total_size); } /** * @} end of Reshape group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/ReshapeFunctions/arm_reshape_s8.c
C
apache-2.0
1,369
/* * Copyright (C) 2010-2021 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_svdf_s8.c * Description: S8 basic SVDF layer function * * $Date: 15. April 2021 * $Revision: V.1.5.0 * * Target Processor: Cortex-M processors * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" #include "arm_nnsupportfunctions.h" /** * @ingroup groupNN */ /** * @addtogroup SVDF * @{ */ /* * S8 SVDF layer function for TensorFlow Lite * * Refer to header file for details. * */ arm_status arm_svdf_s8(const cmsis_nn_context *input_ctx, const cmsis_nn_context *output_ctx, const cmsis_nn_svdf_params *svdf_params, const cmsis_nn_per_tensor_quant_params *input_quant_params, const cmsis_nn_per_tensor_quant_params *output_quant_params, const cmsis_nn_dims *input_dims, const q7_t *input_data, const cmsis_nn_dims *state_dims, q15_t *state_data, const cmsis_nn_dims *weights_feature_dims, const q7_t *weights_feature_data, const cmsis_nn_dims *weights_time_dims, const q15_t *weights_time_data, const cmsis_nn_dims *bias_dims, const q31_t *bias_data, const cmsis_nn_dims *output_dims, q7_t *output_data) { (void)bias_dims; (void)state_dims; (void)output_dims; const q31_t multiplier_in = input_quant_params->multiplier; const q31_t shift_in = input_quant_params->shift; const q31_t multiplier_out = output_quant_params->multiplier; const q31_t shift_2 = output_quant_params->shift; const int32_t zp_in = svdf_params->input_offset; const int32_t zp_out = svdf_params->output_offset; const int32_t in_activation_min = svdf_params->input_activation.min; const int32_t in_activation_max = svdf_params->input_activation.max; const int32_t out_activation_min = svdf_params->output_activation.min; const int32_t out_activation_max = svdf_params->output_activation.max; const int16_t rank = svdf_params->rank; const int32_t input_batches = input_dims->n; const int32_t input_height = input_dims->h; const int32_t feature_batches = weights_feature_dims->n; const int32_t time_batches = weights_time_dims->h; const int32_t unit_count = feature_batches / rank; q31_t *buffer_a = (q31_t *)input_ctx->buf; q31_t *buffer_b = (q31_t *)output_ctx->buf; memmove((q15_t *)state_data, (q15_t *)state_data + 1, (size_t)(input_batches * feature_batches * time_batches * (int32_t)sizeof(int16_t))); for (int i_batch = 0; i_batch < input_batches; i_batch++) { q15_t *res_ptr = state_data + (time_batches * i_batch * feature_batches) + (time_batches - 1); const q7_t *weight = weights_feature_data; const q7_t *input = input_data + i_batch * input_height; arm_status res = arm_nn_vec_mat_mult_t_svdf_s8(input, weight, res_ptr, -zp_in, 0, time_batches, multiplier_in, shift_in, input_height, feature_batches, in_activation_min, in_activation_max); if (res != ARM_MATH_SUCCESS) { return res; } } { q31_t *ptr_a = buffer_a; const q15_t *v2 = state_data; for (int i_batch = 0; i_batch < input_batches; i_batch++) { const q15_t *v1 = weights_time_data; for (int i_feature_batch = 0; i_feature_batch < feature_batches; i_feature_batch++) { *ptr_a = 0; int32_t sum = 0; #if defined(ARM_MATH_DSP) && !defined(ARM_MATH_MVEI) int j = 0; int32_t block_count = time_batches >> 1; for (int i = 0; i < block_count; i++) { j += 2; q31_t r1 = arm_nn_read_q15x2_ia(&v1); q31_t r2 = arm_nn_read_q15x2_ia(&v2); sum = __SMLAD(r1, r2, sum); } // Process the remaining data for (; j < time_batches; j++) { sum += *v1 * *v2; v1++; v2++; } #else for (int j = 0; j < time_batches; j++) { sum += *v1 * *v2; v1++; v2++; } #endif *ptr_a = sum; ptr_a++; } } } if (bias_data) { if (unit_count == feature_batches) { for (int i = 0; i < input_batches; i++) { q31_t *output_temp = buffer_b + i * feature_batches; const q31_t *ptr_a = buffer_a + i * feature_batches; const int32_t *bi = bias_data; for (int j = 0; j < feature_batches; j++) { output_temp[j] = ptr_a[j] + bi[j]; } } } else { for (int i_batch = 0; i_batch < input_batches; i_batch++) { q31_t *output_data_temp = buffer_b + i_batch * unit_count; q31_t *ptr_a = buffer_a + i_batch * feature_batches; for (int i = 0; i < unit_count; i++) { int32_t sum = bias_data[i]; for (int j = 0; j < rank; j++) { sum += *ptr_a; ptr_a++; } output_data_temp[i] = sum; } } } } else { for (int i_batch = 0; i_batch < input_batches; i_batch++) { q31_t *output_data_temp = buffer_b + i_batch * unit_count; q31_t *ptr_a = buffer_a + i_batch * feature_batches; for (int i = 0; i < unit_count; i++) { int32_t sum = 0; for (int j = 0; j < rank; j++) { sum += *ptr_a; ptr_a++; } output_data_temp[i] = sum; } } } #if defined(ARM_MATH_MVEI) int32_t num_elements = input_batches * unit_count; const int32_t loop_count = (num_elements + 3) / 4; for (int i_op = 0; i_op < loop_count; i_op++) { mve_pred16_t p = vctp32q((uint32_t)num_elements); int32x4_t op = vldrwq_z_s32(buffer_b, p); op = arm_requantize_mve(op, multiplier_out, shift_2); op = vaddq_n_s32(op, zp_out); const int32x4_t min_vec = vdupq_n_s32((int8_t)out_activation_min); const int32x4_t max_vec = vdupq_n_s32((int8_t)out_activation_max); op = vmaxq_s32(op, min_vec); op = vminq_s32(op, max_vec); vstrbq_p_s32(output_data, op, p); output_data += 4; buffer_b += 4; num_elements -= 4; } #else for (int i = 0; i < input_batches * unit_count; i++) { output_data[i] = (q7_t)CLAMP( arm_nn_requantize(buffer_b[i], multiplier_out, shift_2) + zp_out, out_activation_max, out_activation_min); } #endif return (ARM_MATH_SUCCESS); } /** * @} end of SVDF group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SVDFunctions/arm_svdf_s8.c
C
apache-2.0
8,760
/* * Copyright (C) 2010-2018 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_softmax_q15.c * Description: Q15 softmax function * * $Date: 09. October 2020 * $Revision: V.1.0.1 * * Target Processor: Cortex-M cores * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" /** * @ingroup groupNN */ /** * @addtogroup Softmax * @{ */ /** * @brief Q15 softmax function * @param[in] vec_in pointer to input vector * @param[in] dim_vec input vector dimention * @param[out] p_out pointer to output vector * * @details * * Here, instead of typical e based softmax, we use * 2-based softmax, i.e.,: * * y_i = 2^(x_i) / sum(2^x_j) * * The relative output will be different here. * But mathematically, the gradient will be the same * with a log(2) scaling factor. * */ void arm_softmax_q15(const q15_t *vec_in, const uint16_t dim_vec, q15_t *p_out) { q31_t sum; int16_t i; uint8_t shift; q31_t base; base = -1 * 0x100000; for (i = 0; i < dim_vec; i++) { if (vec_in[i] > base) { base = vec_in[i]; } } /* we ignore really small values * anyway, they will be 0 after shrinking * to q15_t */ base = base - 16; sum = 0; for (i = 0; i < dim_vec; i++) { if (vec_in[i] > base) { shift = (uint8_t)__USAT(vec_in[i] - base, 5); sum += 0x1 << shift; } } /* This is effectively (0x1 << 32) / sum */ int64_t div_base = 0x100000000LL; int output_base = (int32_t)(div_base / sum); /* Final confidence will be output_base >> ( 17 - (vec_in[i] - base) ) * so 32768 (0x1<<15) -> 100% confidence when sum = 0x1 << 16, output_base = 0x1 << 16 * and vec_in[i]-base = 16 */ for (i = 0; i < dim_vec; i++) { if (vec_in[i] > base) { /* Here minimum value of 17+base-vec[i] will be 1 */ shift = (uint8_t)__USAT(17 + base - vec_in[i], 5); p_out[i] = (q15_t)__SSAT((output_base >> shift), 16); } else { p_out[i] = 0; } } } /** * @} end of Softmax group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_q15.c
C
apache-2.0
2,975
/* * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_softmax_q7.c * Description: Q7 softmax function * * $Date: 09. October 2020 * $Revision: V.1.0.2 * * Target Processor: Cortex-M cores * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" /** * @ingroup groupNN */ /** * @addtogroup Softmax * @{ */ /** * @brief Q7 softmax function * @param[in] vec_in pointer to input vector * @param[in] dim_vec input vector dimention * @param[out] p_out pointer to output vector * * @details * * Here, instead of typical natural logarithm e based softmax, we use * 2-based softmax here, i.e.,: * * y_i = 2^(x_i) / sum(2^x_j) * * The relative output will be different here. * But mathematically, the gradient will be the same * with a log(2) scaling factor. * */ void arm_softmax_q7(const q7_t *vec_in, const uint16_t dim_vec, q7_t *p_out) { q31_t sum; int16_t i; uint8_t shift; q15_t base; base = -128; /* We first search for the maximum */ for (i = 0; i < dim_vec; i++) { if (vec_in[i] > base) { base = vec_in[i]; } } /* * So the base is set to max-8, meaning * that we ignore really small values. * anyway, they will be 0 after shrinking to q7_t. */ base = base - (1 << 3); sum = 0; for (i = 0; i < dim_vec; i++) { shift = (uint8_t)__USAT(vec_in[i] - base, 3); sum += 0x1 << shift; } /* This is effectively (0x1 << 20) / sum */ int output_base = (1 << 20) / sum; for (i = 0; i < dim_vec; i++) { /* Here minimum value of 13+base-vec_in[i] will be 5 */ shift = (uint8_t)__USAT(13 + base - vec_in[i], 5); p_out[i] = (q7_t)__SSAT((output_base >> shift), 8); } } /** * @} end of Softmax group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_q7.c
C
apache-2.0
2,652
/* * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_softmax_s8.c * Description: S8 softmax function * * $Date: 01. March 2021 * $Revision: V.2.0.2 * * Target Processor: Cortex-M cores * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" #include "arm_nnsupportfunctions.h" #define ACCUM_BITS 12 #ifdef ARM_MATH_MVEI static int32x4_t arm_exp_on_negative_values_mve_32x4(int32x4_t val) { #define SHIFT_START (24) int32_t shift = SHIFT_START; int32x4_t mask; const int32x4_t val_mod_minus_quarter = vandq_s32(val, vdupq_n_s32((1 << SHIFT_START) - 1)) - vdupq_n_s32(1 << SHIFT_START); const int32x4_t remainder = vsubq_s32(val_mod_minus_quarter, val); const int32x4_t x = vaddq_n_s32(val_mod_minus_quarter << 5, 1 << 28); const int32x4_t x2 = MUL_SAT_MVE(x, x); const int32x4_t op_1 = DIV_POW2_MVE(MUL_SAT_MVE(x2, x2), 2) + MUL_SAT_MVE(x2, x); const int32x4_t op_2 = x + DIV_POW2_MVE(MUL_SAT_MVE(op_1, vdupq_n_s32(715827883)) + x2, 1); int32x4_t result = vdupq_n_s32(1895147668) + MUL_SAT_MVE(vdupq_n_s32(1895147668), op_2); #define SELECT_IF_NON_ZERO(x) \ { \ mve_pred16_t p = vcmpneq_n_s32(remainder & vdupq_n_s32(1 << shift++), 0); \ mask = vmvnq_m_s32(vdupq_n_s32(0), vdupq_n_s32(0), p); \ result = SELECT_USING_MASK(mask, MUL_SAT_MVE(result, vdupq_n_s32(x)), result); \ } SELECT_IF_NON_ZERO(1672461947) SELECT_IF_NON_ZERO(1302514674) SELECT_IF_NON_ZERO(790015084) SELECT_IF_NON_ZERO(290630308) SELECT_IF_NON_ZERO(39332535) SELECT_IF_NON_ZERO(720401) SELECT_IF_NON_ZERO(242) #undef SELECT_IF_NON_ZERO mve_pred16_t p = vcmpeqq_n_s32(val, 0); mask = vmvnq_m_s32(vdupq_n_s32(0), vdupq_n_s32(0), p); result = SELECT_USING_MASK(mask, vdupq_n_s32(Q31_MAX), result); return result; } #endif /** * @ingroup groupNN */ /** * @addtogroup Softmax * @{ */ void arm_softmax_s8(const int8_t *input, const int32_t num_rows, const int32_t row_size, const int32_t mult, const int32_t shift, const int32_t diff_min, int8_t *output) { #ifdef ARM_MATH_MVEI #define ACT_MIN ((int8_t)Q7_MIN) #define ACT_MAX ((int8_t)Q7_MAX) const int32_t mask = (1 << shift); for (int i_num_rows = 0; i_num_rows < num_rows; ++i_num_rows) { int8_t max = ACT_MIN; int32_t vec_count = (row_size + 15) / 16; uint32_t r_count = (uint32_t)row_size; for (int i = 0; i < vec_count; i++) { mve_pred16_t p = vctp8q(r_count); const int8x16_t ip = vldrbq_z_s8(&input[i * 16], p); max = vmaxvq_p_s8(max, ip, p); r_count -= 16; } vec_count = row_size / 4; int32_t idx = 0; int32_t sum = 0; while (vec_count) { int32x4_t ip = vldrbq_s32(&input[idx * 4]); ip = vsubq_n_s32(ip, max); mve_pred16_t p = vcmpgeq_n_s32(ip, diff_min); if (p != 0) { ip = vmulq_n_s32(ip, mask); int32x4_t res = MUL_SAT_MVE(ip, vdupq_n_s32(mult)); res = arm_exp_on_negative_values_mve_32x4(res); res = DIV_POW2_MVE(res, ACCUM_BITS); res = vpselq_s32(res, vdupq_n_s32(0), p); sum += vaddvq_s32(res); } vec_count--; idx++; } const int32_t tail_idx = row_size & ~3; for (int i = 0; i < (row_size & 3); i++) { const int32_t diff = input[tail_idx + i] - max; if (diff >= diff_min) { sum += DIV_POW2(EXP_ON_NEG(MUL_SAT(diff * mask, mult)), ACCUM_BITS); } } const int32_t headroom = __CLZ((uint32_t)sum); const int32_t bits_over_unit = ACCUM_BITS - headroom + 23; const int32_t shifted_scale = ONE_OVER1((sum > 0 ? sum << headroom : 0) - (1 << 31)); vec_count = row_size / 4; idx = 0; while (vec_count) { int32x4_t ip = vldrbq_s32(&input[idx]); ip = vsubq_n_s32(ip, max); mve_pred16_t p = vcmpgeq_n_s32(ip, diff_min); int32x4_t tmp_res; if (p != 0) { ip = vmulq_n_s32(ip, mask); tmp_res = MUL_SAT_MVE(ip, vdupq_n_s32(mult)); tmp_res = arm_exp_on_negative_values_mve_32x4(tmp_res); tmp_res = MUL_SAT_MVE(vdupq_n_s32(shifted_scale), tmp_res); tmp_res = DIV_POW2_MVE(tmp_res, bits_over_unit); tmp_res += vdupq_n_s32(ACT_MIN); tmp_res = vmaxq_s32(tmp_res, vdupq_n_s32(ACT_MIN)); tmp_res = vminq_s32(tmp_res, vdupq_n_s32(ACT_MAX)); tmp_res = vpselq_s32(tmp_res, vdupq_n_s32(ACT_MIN), p); } else { tmp_res = vdupq_n_s32(ACT_MIN); } vstrbq_s32(&output[idx], tmp_res); vec_count--; idx += 4; } for (int i = 0; i < (row_size & 3); i++) { int32_t diff = input[tail_idx + i] - max; if (diff >= diff_min) { const int32_t res = DIV_POW2(MUL_SAT(shifted_scale, EXP_ON_NEG(MUL_SAT(diff * mask, mult))), bits_over_unit) - 128; output[tail_idx + i] = (int8_t)CLAMP(res, (int32_t)ACT_MAX, (int32_t)ACT_MIN); } else { output[tail_idx + i] = ACT_MIN; } } input += row_size; output += row_size; } #else const int32_t mask = (1 << shift); int32_t col = 0; int32_t row_idx; for (row_idx = 0; row_idx < num_rows; ++row_idx) { // Find the maximum value in order to ensure numerical stability int8_t max = *input; for (col = 1; col < row_size; ++col) { max = MAX(max, input[col]); } int32_t diff = 0; int32_t sum = 0; for (col = 0; col < row_size; ++col) { diff = input[col] - max; if (diff >= diff_min) { sum += DIV_POW2(EXP_ON_NEG(MUL_SAT(diff * mask, mult)), ACCUM_BITS); } } const int32_t headroom = __CLZ(sum); const int32_t bits_over_unit = ACCUM_BITS - headroom + 23; const int32_t shifted_scale = ONE_OVER1((sum > 0 ? sum << headroom : 0) - (1 << 31)); for (col = 0; col < row_size; ++col) { diff = input[col] - max; if (diff >= diff_min) { const int32_t res = DIV_POW2(MUL_SAT(shifted_scale, EXP_ON_NEG(MUL_SAT(diff * mask, mult))), bits_over_unit) - 128; output[col] = (int8_t)CLAMP(res, (int32_t)127, (int32_t)-128); } else { output[col] = -128; } } input += row_size; output += row_size; } #endif } /** * @} end of Softmax group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_s8.c
C
apache-2.0
8,284
/* * Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_softmax_u8.c * Description: U8 softmax function * * $Date: 09. October 2020 * $Revision: V.1.0.2 * * Target Processor: Cortex-M CPUs * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" #include "arm_nnsupportfunctions.h" #define ACCUM_BITS 12 /** * @ingroup groupNN */ /** * @addtogroup Softmax * @{ */ void arm_softmax_u8(const uint8_t *input, const int32_t num_rows, const int32_t row_size, const int32_t mult, const int32_t shift, const int32_t diff_min, uint8_t *output) { const int32_t mask = (1 << shift); int32_t col = 0; int32_t row_idx; for (row_idx = 0; row_idx < num_rows; ++row_idx) { // Find the maximum value in order to ensure numerical stability uint8_t max = *input; for (col = 1; col < row_size; ++col) { max = MAX(max, input[col]); } int32_t diff = 0; int32_t sum = 0; for (col = 0; col < row_size; ++col) { diff = input[col] - max; if (diff >= diff_min) { sum += DIV_POW2(EXP_ON_NEG(MUL_SAT(diff * mask, mult)), ACCUM_BITS); } } const int32_t headroom = __CLZ((uint32_t)sum); const int32_t bits_over_unit = ACCUM_BITS - headroom + 23; const int32_t shifted_scale = ONE_OVER1((sum << headroom) - (1 << 31)); for (col = 0; col < row_size; ++col) { diff = input[col] - max; if (diff >= diff_min) { const int32_t res = DIV_POW2(MUL_SAT(shifted_scale, EXP_ON_NEG(MUL_SAT(diff * mask, mult))), bits_over_unit); output[col] = (uint8_t)CLAMP(res, (int32_t)255, (int32_t)0); } else { output[col] = 0; } } input += row_size; output += row_size; } } /** * @} end of Softmax group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_u8.c
C
apache-2.0
2,900
/* * Copyright (C) 2010-2019 Arm Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * 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 * * 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. */ /* ---------------------------------------------------------------------- * Project: CMSIS NN Library * Title: arm_softmax_with_batch_q7.c * Description: Q7 softmax function * * $Date: 09. October 2020 * $Revision: V.1.0.1 * * Target Processor: Cortex-M and Cortex-A cores * * -------------------------------------------------------------------- */ #include "arm_nnfunctions.h" /** * @ingroup groupNN */ /** * @addtogroup Softmax * @{ */ /** * @brief Q7 softmax function with batch parameter * @param[in] vec_in pointer to input vector * @param[in] nb_batches number of batches * @param[in] dim_vec input vector dimention * @param[out] p_out pointer to output vector * * @details * * Here, instead of typical natural logarithm e based softmax, we use * 2-based softmax here, i.e.,: * * y_i = 2^(x_i) / sum(2^x_j) * * The relative output will be different here. * But mathematically, the gradient will be the same * with a log(2) scaling factor. * */ void arm_softmax_with_batch_q7(const q7_t *vec_in, const uint16_t nb_batches, const uint16_t dim_vec, q7_t *p_out) { for (int i = 0; i < nb_batches; i++) { arm_softmax_q7(vec_in, dim_vec, p_out); vec_in += dim_vec; p_out += dim_vec; } } /** * @} end of Softmax group */
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_with_batch_q7.c
C
apache-2.0
2,039
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_MINIMAL_LOGGING_H_ #define TENSORFLOW_LITE_MINIMAL_LOGGING_H_ #include <cstdarg> namespace tflite { enum LogSeverity { TFLITE_LOG_INFO = 0, TFLITE_LOG_WARNING = 1, TFLITE_LOG_ERROR = 2, }; namespace logging_internal { // Helper class for simple platform-specific console logging. Note that we // explicitly avoid the convenience of ostream-style logging to minimize binary // size impact. class MinimalLogger { public: // Logging hook that takes variadic args. static void Log(LogSeverity severity, const char* format, ...); // Logging hook that takes a formatted va_list. static void LogFormatted(LogSeverity severity, const char* format, va_list args); private: static const char* GetSeverityName(LogSeverity severity); }; } // namespace logging_internal } // namespace tflite // Convenience macro for basic internal logging in production builds. // Note: This should never be used for debug-type logs, as it will *not* be // stripped in release optimized builds. In general, prefer the error reporting // APIs for developer-facing errors, and only use this for diagnostic output // that should always be logged in user builds. #define TFLITE_LOG_PROD(severity, format, ...) \ tflite::logging_internal::MinimalLogger::Log(severity, format, ##__VA_ARGS__); // Convenience macro for logging a statement *once* for a given process lifetime // in production builds. #define TFLITE_LOG_PROD_ONCE(severity, format, ...) \ do { \ static const bool s_logged = [&] { \ TFLITE_LOG_PROD(severity, format, ##__VA_ARGS__) \ return true; \ }(); \ (void)s_logged; \ } while (false); #ifndef NDEBUG // In debug builds, always log. #define TFLITE_LOG TFLITE_LOG_PROD #define TFLITE_LOG_ONCE TFLITE_LOG_PROD_ONCE #else // In prod builds, never log, but ensure the code is well-formed and compiles. #define TFLITE_LOG(severity, format, ...) \ while (false) { \ TFLITE_LOG_PROD(severity, format, ##__VA_ARGS__); \ } #define TFLITE_LOG_ONCE TFLITE_LOG #endif #endif // TENSORFLOW_LITE_MINIMAL_LOGGING_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/minimal_logging.h
C++
apache-2.0
3,008
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ /// \file /// Defines tflite::Interpreter and tflite::InterpreterBuilder. /// #ifndef TENSORFLOW_LITE_MODEL_H_ #define TENSORFLOW_LITE_MODEL_H_ #include "tensorflow/lite/interpreter_builder.h" #include "tensorflow/lite/model_builder.h" // TODO(b/168725050): Address the issue of proxy header in this file. #endif // TENSORFLOW_LITE_MODEL_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/model.h
C
apache-2.0
1,014
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ /// \file /// Deserialization infrastructure for tflite. Provides functionality /// to go from a serialized tflite model in flatbuffer format to an /// in-memory representation of the model. /// #ifndef TENSORFLOW_LITE_MODEL_BUILDER_H_ #define TENSORFLOW_LITE_MODEL_BUILDER_H_ #include <stddef.h> #include <memory> #include <string> #include "tensorflow/lite/allocation.h" #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/core/api/error_reporter.h" #include "tensorflow/lite/core/api/op_resolver.h" #include "tensorflow/lite/core/api/verifier.h" #include "tensorflow/lite/mutable_op_resolver.h" #include "tensorflow/lite/schema/schema_generated.h" #include "tensorflow/lite/stderr_reporter.h" #include "tensorflow/lite/string_type.h" namespace tflite { /// An RAII object that represents a read-only tflite model, copied from disk, /// or mmapped. This uses flatbuffers as the serialization format. /// /// NOTE: The current API requires that a FlatBufferModel instance be kept alive /// by the client as long as it is in use by any dependent Interpreter /// instances. As the FlatBufferModel instance is effectively immutable after /// creation, the client may safely use a single model with multiple dependent /// Interpreter instances, even across multiple threads (though note that each /// Interpreter instance is *not* thread-safe). /// /// <pre><code> /// using namespace tflite; /// StderrReporter error_reporter; /// auto model = FlatBufferModel::BuildFromFile("interesting_model.tflite", /// &error_reporter); /// MyOpResolver resolver; // You need to subclass OpResolver to provide /// // implementations. /// InterpreterBuilder builder(*model, resolver); /// std::unique_ptr<Interpreter> interpreter; /// if(builder(&interpreter) == kTfLiteOk) { /// .. run model inference with interpreter /// } /// </code></pre> /// /// OpResolver must be defined to provide your kernel implementations to the /// interpreter. This is environment specific and may consist of just the /// builtin ops, or some custom operators you defined to extend tflite. class FlatBufferModel { public: /// Builds a model based on a file. /// Caller retains ownership of `error_reporter` and must ensure its lifetime /// is longer than the FlatBufferModel instance. /// Returns a nullptr in case of failure. static std::unique_ptr<FlatBufferModel> BuildFromFile( const char* filename, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Verifies whether the content of the file is legit, then builds a model /// based on the file. /// The extra_verifier argument is an additional optional verifier for the /// file contents. By default, we always check with tflite::VerifyModelBuffer. /// If extra_verifier is supplied, the file contents is also checked against /// the extra_verifier after the check against tflite::VerifyModelBuilder. /// Caller retains ownership of `error_reporter` and must ensure its lifetime /// is longer than the FlatBufferModel instance. /// Returns a nullptr in case of failure. static std::unique_ptr<FlatBufferModel> VerifyAndBuildFromFile( const char* filename, TfLiteVerifier* extra_verifier = nullptr, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Builds a model based on a pre-loaded flatbuffer. /// Caller retains ownership of the buffer and should keep it alive until /// the returned object is destroyed. Caller also retains ownership of /// `error_reporter` and must ensure its lifetime is longer than the /// FlatBufferModel instance. /// Returns a nullptr in case of failure. /// NOTE: this does NOT validate the buffer so it should NOT be called on /// invalid/untrusted input. Use VerifyAndBuildFromBuffer in that case static std::unique_ptr<FlatBufferModel> BuildFromBuffer( const char* caller_owned_buffer, size_t buffer_size, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Verifies whether the content of the buffer is legit, then builds a model /// based on the pre-loaded flatbuffer. /// The extra_verifier argument is an additional optional verifier for the /// buffer. By default, we always check with tflite::VerifyModelBuffer. If /// extra_verifier is supplied, the buffer is checked against the /// extra_verifier after the check against tflite::VerifyModelBuilder. The /// caller retains ownership of the buffer and should keep it alive until the /// returned object is destroyed. Caller retains ownership of `error_reporter` /// and must ensure its lifetime is longer than the FlatBufferModel instance. /// Returns a nullptr in case of failure. static std::unique_ptr<FlatBufferModel> VerifyAndBuildFromBuffer( const char* caller_owned_buffer, size_t buffer_size, TfLiteVerifier* extra_verifier = nullptr, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Builds a model directly from an allocation. /// Ownership of the allocation is passed to the model, but the caller /// retains ownership of `error_reporter` and must ensure its lifetime is /// longer than the FlatBufferModel instance. /// Returns a nullptr in case of failure (e.g., the allocation is invalid). static std::unique_ptr<FlatBufferModel> BuildFromAllocation( std::unique_ptr<Allocation> allocation, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Verifies whether the content of the allocation is legit, then builds a /// model based on the provided allocation. /// The extra_verifier argument is an additional optional verifier for the /// buffer. By default, we always check with tflite::VerifyModelBuffer. If /// extra_verifier is supplied, the buffer is checked against the /// extra_verifier after the check against tflite::VerifyModelBuilder. /// Ownership of the allocation is passed to the model, but the caller /// retains ownership of `error_reporter` and must ensure its lifetime is /// longer than the FlatBufferModel instance. /// Returns a nullptr in case of failure. static std::unique_ptr<FlatBufferModel> VerifyAndBuildFromAllocation( std::unique_ptr<Allocation> allocation, TfLiteVerifier* extra_verifier = nullptr, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Builds a model directly from a flatbuffer pointer /// Caller retains ownership of the buffer and should keep it alive until the /// returned object is destroyed. Caller retains ownership of `error_reporter` /// and must ensure its lifetime is longer than the FlatBufferModel instance. /// Returns a nullptr in case of failure. static std::unique_ptr<FlatBufferModel> BuildFromModel( const tflite::Model* caller_owned_model_spec, ErrorReporter* error_reporter = DefaultErrorReporter()); // Releases memory or unmaps mmaped memory. ~FlatBufferModel(); // Copying or assignment is disallowed to simplify ownership semantics. FlatBufferModel(const FlatBufferModel&) = delete; FlatBufferModel& operator=(const FlatBufferModel&) = delete; bool initialized() const { return model_ != nullptr; } const tflite::Model* operator->() const { return model_; } const tflite::Model* GetModel() const { return model_; } ErrorReporter* error_reporter() const { return error_reporter_; } const Allocation* allocation() const { return allocation_.get(); } // Returns the minimum runtime version from the flatbuffer. This runtime // version encodes the minimum required interpreter version to run the // flatbuffer model. If the minimum version can't be determined, an empty // string will be returned. // Note that the returned minimum version is a lower-bound but not a strict // lower-bound; ops in the graph may not have an associated runtime version, // in which case the actual required runtime might be greater than the // reported minimum. std::string GetMinimumRuntime() const; /// Returns true if the model identifier is correct (otherwise false and /// reports an error). bool CheckModelIdentifier() const; private: /// Loads a model from a given allocation. FlatBufferModel will take over the /// ownership of `allocation`, and delete it in destructor. The ownership of /// `error_reporter`remains with the caller and must have lifetime at least /// as much as FlatBufferModel. This is to allow multiple models to use the /// same ErrorReporter instance. FlatBufferModel(std::unique_ptr<Allocation> allocation, ErrorReporter* error_reporter = DefaultErrorReporter()); /// Loads a model from Model flatbuffer. The `model` has to remain alive and /// unchanged until the end of this flatbuffermodel's lifetime. FlatBufferModel(const Model* model, ErrorReporter* error_reporter); /// Flatbuffer traverser pointer. (Model* is a pointer that is within the /// allocated memory of the data allocated by allocation's internals. const tflite::Model* model_ = nullptr; /// The error reporter to use for model errors and subsequent errors when /// the interpreter is created ErrorReporter* error_reporter_; /// The allocator used for holding memory of the model. Note that this will /// be null if the client provides a tflite::Model directly. std::unique_ptr<Allocation> allocation_; }; } // namespace tflite #endif // TENSORFLOW_LITE_MODEL_BUILDER_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/model_builder.h
C++
apache-2.0
10,086
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_MUTABLE_OP_RESOLVER_H_ #define TENSORFLOW_LITE_MUTABLE_OP_RESOLVER_H_ #include <stddef.h> #include <string> #include <unordered_map> #include <utility> #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/core/api/op_resolver.h" #include "tensorflow/lite/schema/schema_generated.h" #include "tensorflow/lite/util.h" namespace tflite { // Some versions of gcc don't support partial specialization in class scope, // so these are defined in a namescope. namespace op_resolver_hasher { template <typename V> struct ValueHasher { size_t operator()(const V& v) const { return std::hash<V>()(v); } }; template <> struct ValueHasher<tflite::BuiltinOperator> { size_t operator()(const tflite::BuiltinOperator& v) const { return std::hash<int>()(static_cast<int>(v)); } }; template <typename T> struct OperatorKeyHasher { size_t operator()(const T& x) const { size_t a = ValueHasher<typename T::first_type>()(x.first); size_t b = ValueHasher<typename T::second_type>()(x.second); return CombineHashes({a, b}); } }; } // namespace op_resolver_hasher /// An OpResolver that is mutable, also used as the op in gen_op_registration. /// A typical usage: /// MutableOpResolver resolver; /// resolver.AddBuiltin(BuiltinOperator_ADD, Register_ADD()); /// resolver.AddCustom("CustomOp", Register_CUSTOM_OP()); /// InterpreterBuilder(model, resolver)(&interpreter); class MutableOpResolver : public OpResolver { public: const TfLiteRegistration* FindOp(tflite::BuiltinOperator op, int version) const override; const TfLiteRegistration* FindOp(const char* op, int version) const override; /// Registers the specified `version` of the specified builtin operator `op`. /// Replaces any previous registration for the same operator version. void AddBuiltin(tflite::BuiltinOperator op, const TfLiteRegistration* registration, int version = 1); /// Registers the specified version range (versions `min_version` to /// `max_version`, inclusive) of the specified builtin operator `op`. /// Replaces any previous registration for the same operator version. void AddBuiltin(tflite::BuiltinOperator op, const TfLiteRegistration* registration, int min_version, int max_version); /// Registers the specified `version` of the specified builtin operator `op`. /// Replaces any previous registration for the same operator version. void AddCustom(const char* name, const TfLiteRegistration* registration, int version = 1); /// Registers the specified version range (versions `min_version` to /// `max_version`, inclusive) of the specified custom operator `name`. /// Replaces any previous registration for the same operator version. void AddCustom(const char* name, const TfLiteRegistration* registration, int min_version, int max_version); /// Registers all operator versions supported by another MutableOpResolver. /// Replaces any previous registrations for the same operator versions, /// except that registrations made with `AddBuiltin` or `AddCustom` always /// take precedence over registrations made with `ChainOpResolver`. void AddAll(const MutableOpResolver& other); protected: /// Registers all operator versions supported by another OpResolver, /// except any already registered in this MutableOpResolver. /// `other` must point to an OpResolver whose lifetime is at least as long /// as the lifetime of the MutableOpResolver pointed to by `this`. /// The OpResolver pointed to by `other` should not be modified during the /// lifetime of this MutableOpResolver. void ChainOpResolver(const OpResolver* other); private: bool MayContainUserDefinedOps() const override; typedef std::pair<tflite::BuiltinOperator, int> BuiltinOperatorKey; typedef std::pair<std::string, int> CustomOperatorKey; std::unordered_map<BuiltinOperatorKey, TfLiteRegistration, op_resolver_hasher::OperatorKeyHasher<BuiltinOperatorKey> > builtins_; std::unordered_map<CustomOperatorKey, TfLiteRegistration, op_resolver_hasher::OperatorKeyHasher<CustomOperatorKey> > custom_ops_; std::vector<const OpResolver*> other_op_resolvers_; }; } // namespace tflite #endif // TENSORFLOW_LITE_MUTABLE_OP_RESOLVER_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/mutable_op_resolver.h
C++
apache-2.0
5,059
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ // Compatibility shim for moved header location. #ifndef TENSORFLOW_LITE_OP_RESOLVER_H_ #define TENSORFLOW_LITE_OP_RESOLVER_H_ #include "tensorflow/lite/core/api/op_resolver.h" #include "tensorflow/lite/mutable_op_resolver.h" #endif // TENSORFLOW_LITE_OP_RESOLVER_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/op_resolver.h
C
apache-2.0
939
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ /// \file /// Optional debugging functionality. /// For small sized binaries, these are not needed. #ifndef TENSORFLOW_LITE_OPTIONAL_DEBUG_TOOLS_H_ #define TENSORFLOW_LITE_OPTIONAL_DEBUG_TOOLS_H_ #include "tensorflow/lite/interpreter.h" namespace tflite { // Prints a dump of what tensors and what nodes are in the interpreter. void PrintInterpreterState(Interpreter* interpreter); } // namespace tflite #endif // TENSORFLOW_LITE_OPTIONAL_DEBUG_TOOLS_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/optional_debug_tools.h
C++
apache-2.0
1,130
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_PORTABLE_TYPE_TO_TFLITETYPE_H_ #define TENSORFLOW_LITE_PORTABLE_TYPE_TO_TFLITETYPE_H_ // Most of the definitions have been moved to this subheader so that Micro // can include it without relying on <string> and <complex>, which isn't // available on all platforms. // Arduino build defines abs as a macro here. That is invalid C++, and breaks // libc++'s <complex> header, undefine it. #ifdef abs #undef abs #endif #include <stdint.h> #include "tensorflow/lite/c/common.h" namespace tflite { // Map statically from a C++ type to a TfLiteType. Used in interpreter for // safe casts. // Example: // typeToTfLiteType<bool>() -> kTfLiteBool template <typename T> constexpr TfLiteType typeToTfLiteType() { return kTfLiteNoType; } // Map from TfLiteType to the corresponding C++ type. // Example: // TfLiteTypeToType<kTfLiteBool>::Type -> bool template <TfLiteType TFLITE_TYPE_ENUM> struct TfLiteTypeToType {}; // Specializations below // Template specialization for both typeToTfLiteType and TfLiteTypeToType. #define MATCH_TYPE_AND_TFLITE_TYPE(CPP_TYPE, TFLITE_TYPE_ENUM) \ template <> \ constexpr TfLiteType typeToTfLiteType<CPP_TYPE>() { \ return TFLITE_TYPE_ENUM; \ } \ template <> \ struct TfLiteTypeToType<TFLITE_TYPE_ENUM> { \ using Type = CPP_TYPE; \ } // No string mapping is included here, since the TF Lite packed representation // doesn't correspond to a C++ type well. MATCH_TYPE_AND_TFLITE_TYPE(int32_t, kTfLiteInt32); MATCH_TYPE_AND_TFLITE_TYPE(uint32_t, kTfLiteUInt32); MATCH_TYPE_AND_TFLITE_TYPE(int16_t, kTfLiteInt16); MATCH_TYPE_AND_TFLITE_TYPE(int64_t, kTfLiteInt64); MATCH_TYPE_AND_TFLITE_TYPE(float, kTfLiteFloat32); MATCH_TYPE_AND_TFLITE_TYPE(unsigned char, kTfLiteUInt8); MATCH_TYPE_AND_TFLITE_TYPE(int8_t, kTfLiteInt8); MATCH_TYPE_AND_TFLITE_TYPE(bool, kTfLiteBool); MATCH_TYPE_AND_TFLITE_TYPE(TfLiteFloat16, kTfLiteFloat16); MATCH_TYPE_AND_TFLITE_TYPE(double, kTfLiteFloat64); MATCH_TYPE_AND_TFLITE_TYPE(uint64_t, kTfLiteUInt64); } // namespace tflite #endif // TENSORFLOW_LITE_PORTABLE_TYPE_TO_TFLITETYPE_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/portable_type_to_tflitetype.h
C++
apache-2.0
3,013
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_SCHEMA_SCHEMA_CONVERSION_UTILS_H_ #define TENSORFLOW_LITE_SCHEMA_SCHEMA_CONVERSION_UTILS_H_ #include "flatbuffers/flatbuffers.h" #include "tensorflow/lite/schema/schema_generated.h" namespace tflite { int8_t ConvertBuiltinCodeToDeprecatedBuiltinCode( const BuiltinOperator builtin_code); // The following methods are for backward compatibility for the early version // three, which does not have an extended builtin code. flatbuffers::Offset<OperatorCode> CreateOperatorCode( flatbuffers::FlatBufferBuilder &_fbb, BuiltinOperator builtin_code = BuiltinOperator_ADD, flatbuffers::Offset<flatbuffers::String> custom_code = 0, int32_t version = 1); flatbuffers::Offset<OperatorCode> CreateOperatorCodeDirect( flatbuffers::FlatBufferBuilder &_fbb, BuiltinOperator builtin_code = BuiltinOperator_ADD, const char *custom_code = nullptr, int32_t version = 1); } // namespace tflite #endif // TENSORFLOW_LITE_SCHEMA_SCHEMA_CONVERSION_UTILS_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/schema/schema_conversion_utils.h
C++
apache-2.0
1,669
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ // automatically generated by the FlatBuffers compiler, do not modify #ifndef FLATBUFFERS_GENERATED_SCHEMA_TFLITE_H_ #define FLATBUFFERS_GENERATED_SCHEMA_TFLITE_H_ #include "flatbuffers/flatbuffers.h" namespace tflite { struct CustomQuantization; struct CustomQuantizationT; struct QuantizationParameters; struct QuantizationParametersT; struct Int32Vector; struct Int32VectorT; struct Uint16Vector; struct Uint16VectorT; struct Uint8Vector; struct Uint8VectorT; struct DimensionMetadata; struct DimensionMetadataT; struct SparsityParameters; struct SparsityParametersT; struct Tensor; struct TensorT; struct Conv2DOptions; struct Conv2DOptionsT; struct Conv3DOptions; struct Conv3DOptionsT; struct Pool2DOptions; struct Pool2DOptionsT; struct DepthwiseConv2DOptions; struct DepthwiseConv2DOptionsT; struct ConcatEmbeddingsOptions; struct ConcatEmbeddingsOptionsT; struct LSHProjectionOptions; struct LSHProjectionOptionsT; struct SVDFOptions; struct SVDFOptionsT; struct RNNOptions; struct RNNOptionsT; struct SequenceRNNOptions; struct SequenceRNNOptionsT; struct BidirectionalSequenceRNNOptions; struct BidirectionalSequenceRNNOptionsT; struct FullyConnectedOptions; struct FullyConnectedOptionsT; struct SoftmaxOptions; struct SoftmaxOptionsT; struct ConcatenationOptions; struct ConcatenationOptionsT; struct AddOptions; struct AddOptionsT; struct MulOptions; struct MulOptionsT; struct L2NormOptions; struct L2NormOptionsT; struct LocalResponseNormalizationOptions; struct LocalResponseNormalizationOptionsT; struct LSTMOptions; struct LSTMOptionsT; struct UnidirectionalSequenceLSTMOptions; struct UnidirectionalSequenceLSTMOptionsT; struct BidirectionalSequenceLSTMOptions; struct BidirectionalSequenceLSTMOptionsT; struct ResizeBilinearOptions; struct ResizeBilinearOptionsT; struct ResizeNearestNeighborOptions; struct ResizeNearestNeighborOptionsT; struct CallOptions; struct CallOptionsT; struct PadOptions; struct PadOptionsT; struct PadV2Options; struct PadV2OptionsT; struct ReshapeOptions; struct ReshapeOptionsT; struct SpaceToBatchNDOptions; struct SpaceToBatchNDOptionsT; struct BatchToSpaceNDOptions; struct BatchToSpaceNDOptionsT; struct SkipGramOptions; struct SkipGramOptionsT; struct SpaceToDepthOptions; struct SpaceToDepthOptionsT; struct DepthToSpaceOptions; struct DepthToSpaceOptionsT; struct SubOptions; struct SubOptionsT; struct DivOptions; struct DivOptionsT; struct TopKV2Options; struct TopKV2OptionsT; struct EmbeddingLookupSparseOptions; struct EmbeddingLookupSparseOptionsT; struct GatherOptions; struct GatherOptionsT; struct TransposeOptions; struct TransposeOptionsT; struct ExpOptions; struct ExpOptionsT; struct CosOptions; struct CosOptionsT; struct ReducerOptions; struct ReducerOptionsT; struct SqueezeOptions; struct SqueezeOptionsT; struct SplitOptions; struct SplitOptionsT; struct SplitVOptions; struct SplitVOptionsT; struct StridedSliceOptions; struct StridedSliceOptionsT; struct LogSoftmaxOptions; struct LogSoftmaxOptionsT; struct CastOptions; struct CastOptionsT; struct DequantizeOptions; struct DequantizeOptionsT; struct MaximumMinimumOptions; struct MaximumMinimumOptionsT; struct TileOptions; struct TileOptionsT; struct ArgMaxOptions; struct ArgMaxOptionsT; struct ArgMinOptions; struct ArgMinOptionsT; struct GreaterOptions; struct GreaterOptionsT; struct GreaterEqualOptions; struct GreaterEqualOptionsT; struct LessOptions; struct LessOptionsT; struct LessEqualOptions; struct LessEqualOptionsT; struct NegOptions; struct NegOptionsT; struct SelectOptions; struct SelectOptionsT; struct SliceOptions; struct SliceOptionsT; struct TransposeConvOptions; struct TransposeConvOptionsT; struct ExpandDimsOptions; struct ExpandDimsOptionsT; struct SparseToDenseOptions; struct SparseToDenseOptionsT; struct EqualOptions; struct EqualOptionsT; struct NotEqualOptions; struct NotEqualOptionsT; struct ShapeOptions; struct ShapeOptionsT; struct RankOptions; struct RankOptionsT; struct PowOptions; struct PowOptionsT; struct FakeQuantOptions; struct FakeQuantOptionsT; struct PackOptions; struct PackOptionsT; struct LogicalOrOptions; struct LogicalOrOptionsT; struct OneHotOptions; struct OneHotOptionsT; struct AbsOptions; struct AbsOptionsT; struct HardSwishOptions; struct HardSwishOptionsT; struct LogicalAndOptions; struct LogicalAndOptionsT; struct LogicalNotOptions; struct LogicalNotOptionsT; struct UnpackOptions; struct UnpackOptionsT; struct FloorDivOptions; struct FloorDivOptionsT; struct SquareOptions; struct SquareOptionsT; struct ZerosLikeOptions; struct ZerosLikeOptionsT; struct FillOptions; struct FillOptionsT; struct FloorModOptions; struct FloorModOptionsT; struct RangeOptions; struct RangeOptionsT; struct LeakyReluOptions; struct LeakyReluOptionsT; struct SquaredDifferenceOptions; struct SquaredDifferenceOptionsT; struct MirrorPadOptions; struct MirrorPadOptionsT; struct UniqueOptions; struct UniqueOptionsT; struct ReverseV2Options; struct ReverseV2OptionsT; struct AddNOptions; struct AddNOptionsT; struct GatherNdOptions; struct GatherNdOptionsT; struct WhereOptions; struct WhereOptionsT; struct ReverseSequenceOptions; struct ReverseSequenceOptionsT; struct MatrixDiagOptions; struct MatrixDiagOptionsT; struct QuantizeOptions; struct QuantizeOptionsT; struct MatrixSetDiagOptions; struct MatrixSetDiagOptionsT; struct IfOptions; struct IfOptionsT; struct CallOnceOptions; struct CallOnceOptionsT; struct WhileOptions; struct WhileOptionsT; struct NonMaxSuppressionV4Options; struct NonMaxSuppressionV4OptionsT; struct NonMaxSuppressionV5Options; struct NonMaxSuppressionV5OptionsT; struct ScatterNdOptions; struct ScatterNdOptionsT; struct SelectV2Options; struct SelectV2OptionsT; struct DensifyOptions; struct DensifyOptionsT; struct SegmentSumOptions; struct SegmentSumOptionsT; struct BatchMatMulOptions; struct BatchMatMulOptionsT; struct CumsumOptions; struct CumsumOptionsT; struct BroadcastToOptions; struct BroadcastToOptionsT; struct Rfft2dOptions; struct Rfft2dOptionsT; struct HashtableOptions; struct HashtableOptionsT; struct HashtableFindOptions; struct HashtableFindOptionsT; struct HashtableImportOptions; struct HashtableImportOptionsT; struct HashtableSizeOptions; struct HashtableSizeOptionsT; struct OperatorCode; struct OperatorCodeT; struct Operator; struct OperatorT; struct SubGraph; struct SubGraphT; struct Buffer; struct BufferT; struct Metadata; struct MetadataT; struct TensorMap; struct TensorMapT; struct SignatureDef; struct SignatureDefT; struct Model; struct ModelT; enum TensorType { TensorType_FLOAT32 = 0, TensorType_FLOAT16 = 1, TensorType_INT32 = 2, TensorType_UINT8 = 3, TensorType_INT64 = 4, TensorType_STRING = 5, TensorType_BOOL = 6, TensorType_INT16 = 7, TensorType_COMPLEX64 = 8, TensorType_INT8 = 9, TensorType_FLOAT64 = 10, TensorType_COMPLEX128 = 11, TensorType_UINT64 = 12, TensorType_RESOURCE = 13, TensorType_VARIANT = 14, TensorType_UINT32 = 15, TensorType_MIN = TensorType_FLOAT32, TensorType_MAX = TensorType_UINT32 }; inline const TensorType (&EnumValuesTensorType())[16] { static const TensorType values[] = { TensorType_FLOAT32, TensorType_FLOAT16, TensorType_INT32, TensorType_UINT8, TensorType_INT64, TensorType_STRING, TensorType_BOOL, TensorType_INT16, TensorType_COMPLEX64, TensorType_INT8, TensorType_FLOAT64, TensorType_COMPLEX128, TensorType_UINT64, TensorType_RESOURCE, TensorType_VARIANT, TensorType_UINT32 }; return values; } inline const char * const *EnumNamesTensorType() { static const char * const names[17] = { "FLOAT32", "FLOAT16", "INT32", "UINT8", "INT64", "STRING", "BOOL", "INT16", "COMPLEX64", "INT8", "FLOAT64", "COMPLEX128", "UINT64", "RESOURCE", "VARIANT", "UINT32", nullptr }; return names; } inline const char *EnumNameTensorType(TensorType e) { if (flatbuffers::IsOutRange(e, TensorType_FLOAT32, TensorType_UINT32)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesTensorType()[index]; } enum QuantizationDetails { QuantizationDetails_NONE = 0, QuantizationDetails_CustomQuantization = 1, QuantizationDetails_MIN = QuantizationDetails_NONE, QuantizationDetails_MAX = QuantizationDetails_CustomQuantization }; inline const QuantizationDetails (&EnumValuesQuantizationDetails())[2] { static const QuantizationDetails values[] = { QuantizationDetails_NONE, QuantizationDetails_CustomQuantization }; return values; } inline const char * const *EnumNamesQuantizationDetails() { static const char * const names[3] = { "NONE", "CustomQuantization", nullptr }; return names; } inline const char *EnumNameQuantizationDetails(QuantizationDetails e) { if (flatbuffers::IsOutRange(e, QuantizationDetails_NONE, QuantizationDetails_CustomQuantization)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesQuantizationDetails()[index]; } template<typename T> struct QuantizationDetailsTraits { static const QuantizationDetails enum_value = QuantizationDetails_NONE; }; template<> struct QuantizationDetailsTraits<tflite::CustomQuantization> { static const QuantizationDetails enum_value = QuantizationDetails_CustomQuantization; }; struct QuantizationDetailsUnion { QuantizationDetails type; void *value; QuantizationDetailsUnion() : type(QuantizationDetails_NONE), value(nullptr) {} QuantizationDetailsUnion(QuantizationDetailsUnion&& u) FLATBUFFERS_NOEXCEPT : type(QuantizationDetails_NONE), value(nullptr) { std::swap(type, u.type); std::swap(value, u.value); } QuantizationDetailsUnion(const QuantizationDetailsUnion &) FLATBUFFERS_NOEXCEPT; QuantizationDetailsUnion &operator=(const QuantizationDetailsUnion &u) FLATBUFFERS_NOEXCEPT { QuantizationDetailsUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; } QuantizationDetailsUnion &operator=(QuantizationDetailsUnion &&u) FLATBUFFERS_NOEXCEPT { std::swap(type, u.type); std::swap(value, u.value); return *this; } ~QuantizationDetailsUnion() { Reset(); } void Reset(); #ifndef FLATBUFFERS_CPP98_STL template <typename T> void Set(T&& val) { using RT = typename std::remove_reference<T>::type; Reset(); type = QuantizationDetailsTraits<typename RT::TableType>::enum_value; if (type != QuantizationDetails_NONE) { value = new RT(std::forward<T>(val)); } } #endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, QuantizationDetails type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; tflite::CustomQuantizationT *AsCustomQuantization() { return type == QuantizationDetails_CustomQuantization ? reinterpret_cast<tflite::CustomQuantizationT *>(value) : nullptr; } const tflite::CustomQuantizationT *AsCustomQuantization() const { return type == QuantizationDetails_CustomQuantization ? reinterpret_cast<const tflite::CustomQuantizationT *>(value) : nullptr; } }; bool VerifyQuantizationDetails(flatbuffers::Verifier &verifier, const void *obj, QuantizationDetails type); bool VerifyQuantizationDetailsVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); enum DimensionType { DimensionType_DENSE = 0, DimensionType_SPARSE_CSR = 1, DimensionType_MIN = DimensionType_DENSE, DimensionType_MAX = DimensionType_SPARSE_CSR }; inline const DimensionType (&EnumValuesDimensionType())[2] { static const DimensionType values[] = { DimensionType_DENSE, DimensionType_SPARSE_CSR }; return values; } inline const char * const *EnumNamesDimensionType() { static const char * const names[3] = { "DENSE", "SPARSE_CSR", nullptr }; return names; } inline const char *EnumNameDimensionType(DimensionType e) { if (flatbuffers::IsOutRange(e, DimensionType_DENSE, DimensionType_SPARSE_CSR)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesDimensionType()[index]; } enum SparseIndexVector { SparseIndexVector_NONE = 0, SparseIndexVector_Int32Vector = 1, SparseIndexVector_Uint16Vector = 2, SparseIndexVector_Uint8Vector = 3, SparseIndexVector_MIN = SparseIndexVector_NONE, SparseIndexVector_MAX = SparseIndexVector_Uint8Vector }; inline const SparseIndexVector (&EnumValuesSparseIndexVector())[4] { static const SparseIndexVector values[] = { SparseIndexVector_NONE, SparseIndexVector_Int32Vector, SparseIndexVector_Uint16Vector, SparseIndexVector_Uint8Vector }; return values; } inline const char * const *EnumNamesSparseIndexVector() { static const char * const names[5] = { "NONE", "Int32Vector", "Uint16Vector", "Uint8Vector", nullptr }; return names; } inline const char *EnumNameSparseIndexVector(SparseIndexVector e) { if (flatbuffers::IsOutRange(e, SparseIndexVector_NONE, SparseIndexVector_Uint8Vector)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesSparseIndexVector()[index]; } template<typename T> struct SparseIndexVectorTraits { static const SparseIndexVector enum_value = SparseIndexVector_NONE; }; template<> struct SparseIndexVectorTraits<tflite::Int32Vector> { static const SparseIndexVector enum_value = SparseIndexVector_Int32Vector; }; template<> struct SparseIndexVectorTraits<tflite::Uint16Vector> { static const SparseIndexVector enum_value = SparseIndexVector_Uint16Vector; }; template<> struct SparseIndexVectorTraits<tflite::Uint8Vector> { static const SparseIndexVector enum_value = SparseIndexVector_Uint8Vector; }; struct SparseIndexVectorUnion { SparseIndexVector type; void *value; SparseIndexVectorUnion() : type(SparseIndexVector_NONE), value(nullptr) {} SparseIndexVectorUnion(SparseIndexVectorUnion&& u) FLATBUFFERS_NOEXCEPT : type(SparseIndexVector_NONE), value(nullptr) { std::swap(type, u.type); std::swap(value, u.value); } SparseIndexVectorUnion(const SparseIndexVectorUnion &) FLATBUFFERS_NOEXCEPT; SparseIndexVectorUnion &operator=(const SparseIndexVectorUnion &u) FLATBUFFERS_NOEXCEPT { SparseIndexVectorUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; } SparseIndexVectorUnion &operator=(SparseIndexVectorUnion &&u) FLATBUFFERS_NOEXCEPT { std::swap(type, u.type); std::swap(value, u.value); return *this; } ~SparseIndexVectorUnion() { Reset(); } void Reset(); #ifndef FLATBUFFERS_CPP98_STL template <typename T> void Set(T&& val) { using RT = typename std::remove_reference<T>::type; Reset(); type = SparseIndexVectorTraits<typename RT::TableType>::enum_value; if (type != SparseIndexVector_NONE) { value = new RT(std::forward<T>(val)); } } #endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, SparseIndexVector type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; tflite::Int32VectorT *AsInt32Vector() { return type == SparseIndexVector_Int32Vector ? reinterpret_cast<tflite::Int32VectorT *>(value) : nullptr; } const tflite::Int32VectorT *AsInt32Vector() const { return type == SparseIndexVector_Int32Vector ? reinterpret_cast<const tflite::Int32VectorT *>(value) : nullptr; } tflite::Uint16VectorT *AsUint16Vector() { return type == SparseIndexVector_Uint16Vector ? reinterpret_cast<tflite::Uint16VectorT *>(value) : nullptr; } const tflite::Uint16VectorT *AsUint16Vector() const { return type == SparseIndexVector_Uint16Vector ? reinterpret_cast<const tflite::Uint16VectorT *>(value) : nullptr; } tflite::Uint8VectorT *AsUint8Vector() { return type == SparseIndexVector_Uint8Vector ? reinterpret_cast<tflite::Uint8VectorT *>(value) : nullptr; } const tflite::Uint8VectorT *AsUint8Vector() const { return type == SparseIndexVector_Uint8Vector ? reinterpret_cast<const tflite::Uint8VectorT *>(value) : nullptr; } }; bool VerifySparseIndexVector(flatbuffers::Verifier &verifier, const void *obj, SparseIndexVector type); bool VerifySparseIndexVectorVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); enum BuiltinOperator { BuiltinOperator_ADD = 0, BuiltinOperator_AVERAGE_POOL_2D = 1, BuiltinOperator_CONCATENATION = 2, BuiltinOperator_CONV_2D = 3, BuiltinOperator_DEPTHWISE_CONV_2D = 4, BuiltinOperator_DEPTH_TO_SPACE = 5, BuiltinOperator_DEQUANTIZE = 6, BuiltinOperator_EMBEDDING_LOOKUP = 7, BuiltinOperator_FLOOR = 8, BuiltinOperator_FULLY_CONNECTED = 9, BuiltinOperator_HASHTABLE_LOOKUP = 10, BuiltinOperator_L2_NORMALIZATION = 11, BuiltinOperator_L2_POOL_2D = 12, BuiltinOperator_LOCAL_RESPONSE_NORMALIZATION = 13, BuiltinOperator_LOGISTIC = 14, BuiltinOperator_LSH_PROJECTION = 15, BuiltinOperator_LSTM = 16, BuiltinOperator_MAX_POOL_2D = 17, BuiltinOperator_MUL = 18, BuiltinOperator_RELU = 19, BuiltinOperator_RELU_N1_TO_1 = 20, BuiltinOperator_RELU6 = 21, BuiltinOperator_RESHAPE = 22, BuiltinOperator_RESIZE_BILINEAR = 23, BuiltinOperator_RNN = 24, BuiltinOperator_SOFTMAX = 25, BuiltinOperator_SPACE_TO_DEPTH = 26, BuiltinOperator_SVDF = 27, BuiltinOperator_TANH = 28, BuiltinOperator_CONCAT_EMBEDDINGS = 29, BuiltinOperator_SKIP_GRAM = 30, BuiltinOperator_CALL = 31, BuiltinOperator_CUSTOM = 32, BuiltinOperator_EMBEDDING_LOOKUP_SPARSE = 33, BuiltinOperator_PAD = 34, BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_RNN = 35, BuiltinOperator_GATHER = 36, BuiltinOperator_BATCH_TO_SPACE_ND = 37, BuiltinOperator_SPACE_TO_BATCH_ND = 38, BuiltinOperator_TRANSPOSE = 39, BuiltinOperator_MEAN = 40, BuiltinOperator_SUB = 41, BuiltinOperator_DIV = 42, BuiltinOperator_SQUEEZE = 43, BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM = 44, BuiltinOperator_STRIDED_SLICE = 45, BuiltinOperator_BIDIRECTIONAL_SEQUENCE_RNN = 46, BuiltinOperator_EXP = 47, BuiltinOperator_TOPK_V2 = 48, BuiltinOperator_SPLIT = 49, BuiltinOperator_LOG_SOFTMAX = 50, BuiltinOperator_DELEGATE = 51, BuiltinOperator_BIDIRECTIONAL_SEQUENCE_LSTM = 52, BuiltinOperator_CAST = 53, BuiltinOperator_PRELU = 54, BuiltinOperator_MAXIMUM = 55, BuiltinOperator_ARG_MAX = 56, BuiltinOperator_MINIMUM = 57, BuiltinOperator_LESS = 58, BuiltinOperator_NEG = 59, BuiltinOperator_PADV2 = 60, BuiltinOperator_GREATER = 61, BuiltinOperator_GREATER_EQUAL = 62, BuiltinOperator_LESS_EQUAL = 63, BuiltinOperator_SELECT = 64, BuiltinOperator_SLICE = 65, BuiltinOperator_SIN = 66, BuiltinOperator_TRANSPOSE_CONV = 67, BuiltinOperator_SPARSE_TO_DENSE = 68, BuiltinOperator_TILE = 69, BuiltinOperator_EXPAND_DIMS = 70, BuiltinOperator_EQUAL = 71, BuiltinOperator_NOT_EQUAL = 72, BuiltinOperator_LOG = 73, BuiltinOperator_SUM = 74, BuiltinOperator_SQRT = 75, BuiltinOperator_RSQRT = 76, BuiltinOperator_SHAPE = 77, BuiltinOperator_POW = 78, BuiltinOperator_ARG_MIN = 79, BuiltinOperator_FAKE_QUANT = 80, BuiltinOperator_REDUCE_PROD = 81, BuiltinOperator_REDUCE_MAX = 82, BuiltinOperator_PACK = 83, BuiltinOperator_LOGICAL_OR = 84, BuiltinOperator_ONE_HOT = 85, BuiltinOperator_LOGICAL_AND = 86, BuiltinOperator_LOGICAL_NOT = 87, BuiltinOperator_UNPACK = 88, BuiltinOperator_REDUCE_MIN = 89, BuiltinOperator_FLOOR_DIV = 90, BuiltinOperator_REDUCE_ANY = 91, BuiltinOperator_SQUARE = 92, BuiltinOperator_ZEROS_LIKE = 93, BuiltinOperator_FILL = 94, BuiltinOperator_FLOOR_MOD = 95, BuiltinOperator_RANGE = 96, BuiltinOperator_RESIZE_NEAREST_NEIGHBOR = 97, BuiltinOperator_LEAKY_RELU = 98, BuiltinOperator_SQUARED_DIFFERENCE = 99, BuiltinOperator_MIRROR_PAD = 100, BuiltinOperator_ABS = 101, BuiltinOperator_SPLIT_V = 102, BuiltinOperator_UNIQUE = 103, BuiltinOperator_CEIL = 104, BuiltinOperator_REVERSE_V2 = 105, BuiltinOperator_ADD_N = 106, BuiltinOperator_GATHER_ND = 107, BuiltinOperator_COS = 108, BuiltinOperator_WHERE = 109, BuiltinOperator_RANK = 110, BuiltinOperator_ELU = 111, BuiltinOperator_REVERSE_SEQUENCE = 112, BuiltinOperator_MATRIX_DIAG = 113, BuiltinOperator_QUANTIZE = 114, BuiltinOperator_MATRIX_SET_DIAG = 115, BuiltinOperator_ROUND = 116, BuiltinOperator_HARD_SWISH = 117, BuiltinOperator_IF = 118, BuiltinOperator_WHILE = 119, BuiltinOperator_NON_MAX_SUPPRESSION_V4 = 120, BuiltinOperator_NON_MAX_SUPPRESSION_V5 = 121, BuiltinOperator_SCATTER_ND = 122, BuiltinOperator_SELECT_V2 = 123, BuiltinOperator_DENSIFY = 124, BuiltinOperator_SEGMENT_SUM = 125, BuiltinOperator_BATCH_MATMUL = 126, BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES = 127, BuiltinOperator_CUMSUM = 128, BuiltinOperator_CALL_ONCE = 129, BuiltinOperator_BROADCAST_TO = 130, BuiltinOperator_RFFT2D = 131, BuiltinOperator_CONV_3D = 132, BuiltinOperator_IMAG = 133, BuiltinOperator_REAL = 134, BuiltinOperator_COMPLEX_ABS = 135, BuiltinOperator_HASHTABLE = 136, BuiltinOperator_HASHTABLE_FIND = 137, BuiltinOperator_HASHTABLE_IMPORT = 138, BuiltinOperator_HASHTABLE_SIZE = 139, BuiltinOperator_REDUCE_ALL = 140, BuiltinOperator_MIN = BuiltinOperator_ADD, BuiltinOperator_MAX = BuiltinOperator_REDUCE_ALL }; inline const BuiltinOperator (&EnumValuesBuiltinOperator())[141] { static const BuiltinOperator values[] = { BuiltinOperator_ADD, BuiltinOperator_AVERAGE_POOL_2D, BuiltinOperator_CONCATENATION, BuiltinOperator_CONV_2D, BuiltinOperator_DEPTHWISE_CONV_2D, BuiltinOperator_DEPTH_TO_SPACE, BuiltinOperator_DEQUANTIZE, BuiltinOperator_EMBEDDING_LOOKUP, BuiltinOperator_FLOOR, BuiltinOperator_FULLY_CONNECTED, BuiltinOperator_HASHTABLE_LOOKUP, BuiltinOperator_L2_NORMALIZATION, BuiltinOperator_L2_POOL_2D, BuiltinOperator_LOCAL_RESPONSE_NORMALIZATION, BuiltinOperator_LOGISTIC, BuiltinOperator_LSH_PROJECTION, BuiltinOperator_LSTM, BuiltinOperator_MAX_POOL_2D, BuiltinOperator_MUL, BuiltinOperator_RELU, BuiltinOperator_RELU_N1_TO_1, BuiltinOperator_RELU6, BuiltinOperator_RESHAPE, BuiltinOperator_RESIZE_BILINEAR, BuiltinOperator_RNN, BuiltinOperator_SOFTMAX, BuiltinOperator_SPACE_TO_DEPTH, BuiltinOperator_SVDF, BuiltinOperator_TANH, BuiltinOperator_CONCAT_EMBEDDINGS, BuiltinOperator_SKIP_GRAM, BuiltinOperator_CALL, BuiltinOperator_CUSTOM, BuiltinOperator_EMBEDDING_LOOKUP_SPARSE, BuiltinOperator_PAD, BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_RNN, BuiltinOperator_GATHER, BuiltinOperator_BATCH_TO_SPACE_ND, BuiltinOperator_SPACE_TO_BATCH_ND, BuiltinOperator_TRANSPOSE, BuiltinOperator_MEAN, BuiltinOperator_SUB, BuiltinOperator_DIV, BuiltinOperator_SQUEEZE, BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM, BuiltinOperator_STRIDED_SLICE, BuiltinOperator_BIDIRECTIONAL_SEQUENCE_RNN, BuiltinOperator_EXP, BuiltinOperator_TOPK_V2, BuiltinOperator_SPLIT, BuiltinOperator_LOG_SOFTMAX, BuiltinOperator_DELEGATE, BuiltinOperator_BIDIRECTIONAL_SEQUENCE_LSTM, BuiltinOperator_CAST, BuiltinOperator_PRELU, BuiltinOperator_MAXIMUM, BuiltinOperator_ARG_MAX, BuiltinOperator_MINIMUM, BuiltinOperator_LESS, BuiltinOperator_NEG, BuiltinOperator_PADV2, BuiltinOperator_GREATER, BuiltinOperator_GREATER_EQUAL, BuiltinOperator_LESS_EQUAL, BuiltinOperator_SELECT, BuiltinOperator_SLICE, BuiltinOperator_SIN, BuiltinOperator_TRANSPOSE_CONV, BuiltinOperator_SPARSE_TO_DENSE, BuiltinOperator_TILE, BuiltinOperator_EXPAND_DIMS, BuiltinOperator_EQUAL, BuiltinOperator_NOT_EQUAL, BuiltinOperator_LOG, BuiltinOperator_SUM, BuiltinOperator_SQRT, BuiltinOperator_RSQRT, BuiltinOperator_SHAPE, BuiltinOperator_POW, BuiltinOperator_ARG_MIN, BuiltinOperator_FAKE_QUANT, BuiltinOperator_REDUCE_PROD, BuiltinOperator_REDUCE_MAX, BuiltinOperator_PACK, BuiltinOperator_LOGICAL_OR, BuiltinOperator_ONE_HOT, BuiltinOperator_LOGICAL_AND, BuiltinOperator_LOGICAL_NOT, BuiltinOperator_UNPACK, BuiltinOperator_REDUCE_MIN, BuiltinOperator_FLOOR_DIV, BuiltinOperator_REDUCE_ANY, BuiltinOperator_SQUARE, BuiltinOperator_ZEROS_LIKE, BuiltinOperator_FILL, BuiltinOperator_FLOOR_MOD, BuiltinOperator_RANGE, BuiltinOperator_RESIZE_NEAREST_NEIGHBOR, BuiltinOperator_LEAKY_RELU, BuiltinOperator_SQUARED_DIFFERENCE, BuiltinOperator_MIRROR_PAD, BuiltinOperator_ABS, BuiltinOperator_SPLIT_V, BuiltinOperator_UNIQUE, BuiltinOperator_CEIL, BuiltinOperator_REVERSE_V2, BuiltinOperator_ADD_N, BuiltinOperator_GATHER_ND, BuiltinOperator_COS, BuiltinOperator_WHERE, BuiltinOperator_RANK, BuiltinOperator_ELU, BuiltinOperator_REVERSE_SEQUENCE, BuiltinOperator_MATRIX_DIAG, BuiltinOperator_QUANTIZE, BuiltinOperator_MATRIX_SET_DIAG, BuiltinOperator_ROUND, BuiltinOperator_HARD_SWISH, BuiltinOperator_IF, BuiltinOperator_WHILE, BuiltinOperator_NON_MAX_SUPPRESSION_V4, BuiltinOperator_NON_MAX_SUPPRESSION_V5, BuiltinOperator_SCATTER_ND, BuiltinOperator_SELECT_V2, BuiltinOperator_DENSIFY, BuiltinOperator_SEGMENT_SUM, BuiltinOperator_BATCH_MATMUL, BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES, BuiltinOperator_CUMSUM, BuiltinOperator_CALL_ONCE, BuiltinOperator_BROADCAST_TO, BuiltinOperator_RFFT2D, BuiltinOperator_CONV_3D, BuiltinOperator_IMAG, BuiltinOperator_REAL, BuiltinOperator_COMPLEX_ABS, BuiltinOperator_HASHTABLE, BuiltinOperator_HASHTABLE_FIND, BuiltinOperator_HASHTABLE_IMPORT, BuiltinOperator_HASHTABLE_SIZE, BuiltinOperator_REDUCE_ALL }; return values; } inline const char * const *EnumNamesBuiltinOperator() { static const char * const names[142] = { "ADD", "AVERAGE_POOL_2D", "CONCATENATION", "CONV_2D", "DEPTHWISE_CONV_2D", "DEPTH_TO_SPACE", "DEQUANTIZE", "EMBEDDING_LOOKUP", "FLOOR", "FULLY_CONNECTED", "HASHTABLE_LOOKUP", "L2_NORMALIZATION", "L2_POOL_2D", "LOCAL_RESPONSE_NORMALIZATION", "LOGISTIC", "LSH_PROJECTION", "LSTM", "MAX_POOL_2D", "MUL", "RELU", "RELU_N1_TO_1", "RELU6", "RESHAPE", "RESIZE_BILINEAR", "RNN", "SOFTMAX", "SPACE_TO_DEPTH", "SVDF", "TANH", "CONCAT_EMBEDDINGS", "SKIP_GRAM", "CALL", "CUSTOM", "EMBEDDING_LOOKUP_SPARSE", "PAD", "UNIDIRECTIONAL_SEQUENCE_RNN", "GATHER", "BATCH_TO_SPACE_ND", "SPACE_TO_BATCH_ND", "TRANSPOSE", "MEAN", "SUB", "DIV", "SQUEEZE", "UNIDIRECTIONAL_SEQUENCE_LSTM", "STRIDED_SLICE", "BIDIRECTIONAL_SEQUENCE_RNN", "EXP", "TOPK_V2", "SPLIT", "LOG_SOFTMAX", "DELEGATE", "BIDIRECTIONAL_SEQUENCE_LSTM", "CAST", "PRELU", "MAXIMUM", "ARG_MAX", "MINIMUM", "LESS", "NEG", "PADV2", "GREATER", "GREATER_EQUAL", "LESS_EQUAL", "SELECT", "SLICE", "SIN", "TRANSPOSE_CONV", "SPARSE_TO_DENSE", "TILE", "EXPAND_DIMS", "EQUAL", "NOT_EQUAL", "LOG", "SUM", "SQRT", "RSQRT", "SHAPE", "POW", "ARG_MIN", "FAKE_QUANT", "REDUCE_PROD", "REDUCE_MAX", "PACK", "LOGICAL_OR", "ONE_HOT", "LOGICAL_AND", "LOGICAL_NOT", "UNPACK", "REDUCE_MIN", "FLOOR_DIV", "REDUCE_ANY", "SQUARE", "ZEROS_LIKE", "FILL", "FLOOR_MOD", "RANGE", "RESIZE_NEAREST_NEIGHBOR", "LEAKY_RELU", "SQUARED_DIFFERENCE", "MIRROR_PAD", "ABS", "SPLIT_V", "UNIQUE", "CEIL", "REVERSE_V2", "ADD_N", "GATHER_ND", "COS", "WHERE", "RANK", "ELU", "REVERSE_SEQUENCE", "MATRIX_DIAG", "QUANTIZE", "MATRIX_SET_DIAG", "ROUND", "HARD_SWISH", "IF", "WHILE", "NON_MAX_SUPPRESSION_V4", "NON_MAX_SUPPRESSION_V5", "SCATTER_ND", "SELECT_V2", "DENSIFY", "SEGMENT_SUM", "BATCH_MATMUL", "PLACEHOLDER_FOR_GREATER_OP_CODES", "CUMSUM", "CALL_ONCE", "BROADCAST_TO", "RFFT2D", "CONV_3D", "IMAG", "REAL", "COMPLEX_ABS", "HASHTABLE", "HASHTABLE_FIND", "HASHTABLE_IMPORT", "HASHTABLE_SIZE", "REDUCE_ALL", nullptr }; return names; } inline const char *EnumNameBuiltinOperator(BuiltinOperator e) { if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_REDUCE_ALL)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesBuiltinOperator()[index]; } enum BuiltinOptions { BuiltinOptions_NONE = 0, BuiltinOptions_Conv2DOptions = 1, BuiltinOptions_DepthwiseConv2DOptions = 2, BuiltinOptions_ConcatEmbeddingsOptions = 3, BuiltinOptions_LSHProjectionOptions = 4, BuiltinOptions_Pool2DOptions = 5, BuiltinOptions_SVDFOptions = 6, BuiltinOptions_RNNOptions = 7, BuiltinOptions_FullyConnectedOptions = 8, BuiltinOptions_SoftmaxOptions = 9, BuiltinOptions_ConcatenationOptions = 10, BuiltinOptions_AddOptions = 11, BuiltinOptions_L2NormOptions = 12, BuiltinOptions_LocalResponseNormalizationOptions = 13, BuiltinOptions_LSTMOptions = 14, BuiltinOptions_ResizeBilinearOptions = 15, BuiltinOptions_CallOptions = 16, BuiltinOptions_ReshapeOptions = 17, BuiltinOptions_SkipGramOptions = 18, BuiltinOptions_SpaceToDepthOptions = 19, BuiltinOptions_EmbeddingLookupSparseOptions = 20, BuiltinOptions_MulOptions = 21, BuiltinOptions_PadOptions = 22, BuiltinOptions_GatherOptions = 23, BuiltinOptions_BatchToSpaceNDOptions = 24, BuiltinOptions_SpaceToBatchNDOptions = 25, BuiltinOptions_TransposeOptions = 26, BuiltinOptions_ReducerOptions = 27, BuiltinOptions_SubOptions = 28, BuiltinOptions_DivOptions = 29, BuiltinOptions_SqueezeOptions = 30, BuiltinOptions_SequenceRNNOptions = 31, BuiltinOptions_StridedSliceOptions = 32, BuiltinOptions_ExpOptions = 33, BuiltinOptions_TopKV2Options = 34, BuiltinOptions_SplitOptions = 35, BuiltinOptions_LogSoftmaxOptions = 36, BuiltinOptions_CastOptions = 37, BuiltinOptions_DequantizeOptions = 38, BuiltinOptions_MaximumMinimumOptions = 39, BuiltinOptions_ArgMaxOptions = 40, BuiltinOptions_LessOptions = 41, BuiltinOptions_NegOptions = 42, BuiltinOptions_PadV2Options = 43, BuiltinOptions_GreaterOptions = 44, BuiltinOptions_GreaterEqualOptions = 45, BuiltinOptions_LessEqualOptions = 46, BuiltinOptions_SelectOptions = 47, BuiltinOptions_SliceOptions = 48, BuiltinOptions_TransposeConvOptions = 49, BuiltinOptions_SparseToDenseOptions = 50, BuiltinOptions_TileOptions = 51, BuiltinOptions_ExpandDimsOptions = 52, BuiltinOptions_EqualOptions = 53, BuiltinOptions_NotEqualOptions = 54, BuiltinOptions_ShapeOptions = 55, BuiltinOptions_PowOptions = 56, BuiltinOptions_ArgMinOptions = 57, BuiltinOptions_FakeQuantOptions = 58, BuiltinOptions_PackOptions = 59, BuiltinOptions_LogicalOrOptions = 60, BuiltinOptions_OneHotOptions = 61, BuiltinOptions_LogicalAndOptions = 62, BuiltinOptions_LogicalNotOptions = 63, BuiltinOptions_UnpackOptions = 64, BuiltinOptions_FloorDivOptions = 65, BuiltinOptions_SquareOptions = 66, BuiltinOptions_ZerosLikeOptions = 67, BuiltinOptions_FillOptions = 68, BuiltinOptions_BidirectionalSequenceLSTMOptions = 69, BuiltinOptions_BidirectionalSequenceRNNOptions = 70, BuiltinOptions_UnidirectionalSequenceLSTMOptions = 71, BuiltinOptions_FloorModOptions = 72, BuiltinOptions_RangeOptions = 73, BuiltinOptions_ResizeNearestNeighborOptions = 74, BuiltinOptions_LeakyReluOptions = 75, BuiltinOptions_SquaredDifferenceOptions = 76, BuiltinOptions_MirrorPadOptions = 77, BuiltinOptions_AbsOptions = 78, BuiltinOptions_SplitVOptions = 79, BuiltinOptions_UniqueOptions = 80, BuiltinOptions_ReverseV2Options = 81, BuiltinOptions_AddNOptions = 82, BuiltinOptions_GatherNdOptions = 83, BuiltinOptions_CosOptions = 84, BuiltinOptions_WhereOptions = 85, BuiltinOptions_RankOptions = 86, BuiltinOptions_ReverseSequenceOptions = 87, BuiltinOptions_MatrixDiagOptions = 88, BuiltinOptions_QuantizeOptions = 89, BuiltinOptions_MatrixSetDiagOptions = 90, BuiltinOptions_HardSwishOptions = 91, BuiltinOptions_IfOptions = 92, BuiltinOptions_WhileOptions = 93, BuiltinOptions_DepthToSpaceOptions = 94, BuiltinOptions_NonMaxSuppressionV4Options = 95, BuiltinOptions_NonMaxSuppressionV5Options = 96, BuiltinOptions_ScatterNdOptions = 97, BuiltinOptions_SelectV2Options = 98, BuiltinOptions_DensifyOptions = 99, BuiltinOptions_SegmentSumOptions = 100, BuiltinOptions_BatchMatMulOptions = 101, BuiltinOptions_CumsumOptions = 102, BuiltinOptions_CallOnceOptions = 103, BuiltinOptions_BroadcastToOptions = 104, BuiltinOptions_Rfft2dOptions = 105, BuiltinOptions_Conv3DOptions = 106, BuiltinOptions_HashtableOptions = 107, BuiltinOptions_HashtableFindOptions = 108, BuiltinOptions_HashtableImportOptions = 109, BuiltinOptions_HashtableSizeOptions = 110, BuiltinOptions_MIN = BuiltinOptions_NONE, BuiltinOptions_MAX = BuiltinOptions_HashtableSizeOptions }; inline const BuiltinOptions (&EnumValuesBuiltinOptions())[111] { static const BuiltinOptions values[] = { BuiltinOptions_NONE, BuiltinOptions_Conv2DOptions, BuiltinOptions_DepthwiseConv2DOptions, BuiltinOptions_ConcatEmbeddingsOptions, BuiltinOptions_LSHProjectionOptions, BuiltinOptions_Pool2DOptions, BuiltinOptions_SVDFOptions, BuiltinOptions_RNNOptions, BuiltinOptions_FullyConnectedOptions, BuiltinOptions_SoftmaxOptions, BuiltinOptions_ConcatenationOptions, BuiltinOptions_AddOptions, BuiltinOptions_L2NormOptions, BuiltinOptions_LocalResponseNormalizationOptions, BuiltinOptions_LSTMOptions, BuiltinOptions_ResizeBilinearOptions, BuiltinOptions_CallOptions, BuiltinOptions_ReshapeOptions, BuiltinOptions_SkipGramOptions, BuiltinOptions_SpaceToDepthOptions, BuiltinOptions_EmbeddingLookupSparseOptions, BuiltinOptions_MulOptions, BuiltinOptions_PadOptions, BuiltinOptions_GatherOptions, BuiltinOptions_BatchToSpaceNDOptions, BuiltinOptions_SpaceToBatchNDOptions, BuiltinOptions_TransposeOptions, BuiltinOptions_ReducerOptions, BuiltinOptions_SubOptions, BuiltinOptions_DivOptions, BuiltinOptions_SqueezeOptions, BuiltinOptions_SequenceRNNOptions, BuiltinOptions_StridedSliceOptions, BuiltinOptions_ExpOptions, BuiltinOptions_TopKV2Options, BuiltinOptions_SplitOptions, BuiltinOptions_LogSoftmaxOptions, BuiltinOptions_CastOptions, BuiltinOptions_DequantizeOptions, BuiltinOptions_MaximumMinimumOptions, BuiltinOptions_ArgMaxOptions, BuiltinOptions_LessOptions, BuiltinOptions_NegOptions, BuiltinOptions_PadV2Options, BuiltinOptions_GreaterOptions, BuiltinOptions_GreaterEqualOptions, BuiltinOptions_LessEqualOptions, BuiltinOptions_SelectOptions, BuiltinOptions_SliceOptions, BuiltinOptions_TransposeConvOptions, BuiltinOptions_SparseToDenseOptions, BuiltinOptions_TileOptions, BuiltinOptions_ExpandDimsOptions, BuiltinOptions_EqualOptions, BuiltinOptions_NotEqualOptions, BuiltinOptions_ShapeOptions, BuiltinOptions_PowOptions, BuiltinOptions_ArgMinOptions, BuiltinOptions_FakeQuantOptions, BuiltinOptions_PackOptions, BuiltinOptions_LogicalOrOptions, BuiltinOptions_OneHotOptions, BuiltinOptions_LogicalAndOptions, BuiltinOptions_LogicalNotOptions, BuiltinOptions_UnpackOptions, BuiltinOptions_FloorDivOptions, BuiltinOptions_SquareOptions, BuiltinOptions_ZerosLikeOptions, BuiltinOptions_FillOptions, BuiltinOptions_BidirectionalSequenceLSTMOptions, BuiltinOptions_BidirectionalSequenceRNNOptions, BuiltinOptions_UnidirectionalSequenceLSTMOptions, BuiltinOptions_FloorModOptions, BuiltinOptions_RangeOptions, BuiltinOptions_ResizeNearestNeighborOptions, BuiltinOptions_LeakyReluOptions, BuiltinOptions_SquaredDifferenceOptions, BuiltinOptions_MirrorPadOptions, BuiltinOptions_AbsOptions, BuiltinOptions_SplitVOptions, BuiltinOptions_UniqueOptions, BuiltinOptions_ReverseV2Options, BuiltinOptions_AddNOptions, BuiltinOptions_GatherNdOptions, BuiltinOptions_CosOptions, BuiltinOptions_WhereOptions, BuiltinOptions_RankOptions, BuiltinOptions_ReverseSequenceOptions, BuiltinOptions_MatrixDiagOptions, BuiltinOptions_QuantizeOptions, BuiltinOptions_MatrixSetDiagOptions, BuiltinOptions_HardSwishOptions, BuiltinOptions_IfOptions, BuiltinOptions_WhileOptions, BuiltinOptions_DepthToSpaceOptions, BuiltinOptions_NonMaxSuppressionV4Options, BuiltinOptions_NonMaxSuppressionV5Options, BuiltinOptions_ScatterNdOptions, BuiltinOptions_SelectV2Options, BuiltinOptions_DensifyOptions, BuiltinOptions_SegmentSumOptions, BuiltinOptions_BatchMatMulOptions, BuiltinOptions_CumsumOptions, BuiltinOptions_CallOnceOptions, BuiltinOptions_BroadcastToOptions, BuiltinOptions_Rfft2dOptions, BuiltinOptions_Conv3DOptions, BuiltinOptions_HashtableOptions, BuiltinOptions_HashtableFindOptions, BuiltinOptions_HashtableImportOptions, BuiltinOptions_HashtableSizeOptions }; return values; } inline const char * const *EnumNamesBuiltinOptions() { static const char * const names[112] = { "NONE", "Conv2DOptions", "DepthwiseConv2DOptions", "ConcatEmbeddingsOptions", "LSHProjectionOptions", "Pool2DOptions", "SVDFOptions", "RNNOptions", "FullyConnectedOptions", "SoftmaxOptions", "ConcatenationOptions", "AddOptions", "L2NormOptions", "LocalResponseNormalizationOptions", "LSTMOptions", "ResizeBilinearOptions", "CallOptions", "ReshapeOptions", "SkipGramOptions", "SpaceToDepthOptions", "EmbeddingLookupSparseOptions", "MulOptions", "PadOptions", "GatherOptions", "BatchToSpaceNDOptions", "SpaceToBatchNDOptions", "TransposeOptions", "ReducerOptions", "SubOptions", "DivOptions", "SqueezeOptions", "SequenceRNNOptions", "StridedSliceOptions", "ExpOptions", "TopKV2Options", "SplitOptions", "LogSoftmaxOptions", "CastOptions", "DequantizeOptions", "MaximumMinimumOptions", "ArgMaxOptions", "LessOptions", "NegOptions", "PadV2Options", "GreaterOptions", "GreaterEqualOptions", "LessEqualOptions", "SelectOptions", "SliceOptions", "TransposeConvOptions", "SparseToDenseOptions", "TileOptions", "ExpandDimsOptions", "EqualOptions", "NotEqualOptions", "ShapeOptions", "PowOptions", "ArgMinOptions", "FakeQuantOptions", "PackOptions", "LogicalOrOptions", "OneHotOptions", "LogicalAndOptions", "LogicalNotOptions", "UnpackOptions", "FloorDivOptions", "SquareOptions", "ZerosLikeOptions", "FillOptions", "BidirectionalSequenceLSTMOptions", "BidirectionalSequenceRNNOptions", "UnidirectionalSequenceLSTMOptions", "FloorModOptions", "RangeOptions", "ResizeNearestNeighborOptions", "LeakyReluOptions", "SquaredDifferenceOptions", "MirrorPadOptions", "AbsOptions", "SplitVOptions", "UniqueOptions", "ReverseV2Options", "AddNOptions", "GatherNdOptions", "CosOptions", "WhereOptions", "RankOptions", "ReverseSequenceOptions", "MatrixDiagOptions", "QuantizeOptions", "MatrixSetDiagOptions", "HardSwishOptions", "IfOptions", "WhileOptions", "DepthToSpaceOptions", "NonMaxSuppressionV4Options", "NonMaxSuppressionV5Options", "ScatterNdOptions", "SelectV2Options", "DensifyOptions", "SegmentSumOptions", "BatchMatMulOptions", "CumsumOptions", "CallOnceOptions", "BroadcastToOptions", "Rfft2dOptions", "Conv3DOptions", "HashtableOptions", "HashtableFindOptions", "HashtableImportOptions", "HashtableSizeOptions", nullptr }; return names; } inline const char *EnumNameBuiltinOptions(BuiltinOptions e) { if (flatbuffers::IsOutRange(e, BuiltinOptions_NONE, BuiltinOptions_HashtableSizeOptions)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesBuiltinOptions()[index]; } template<typename T> struct BuiltinOptionsTraits { static const BuiltinOptions enum_value = BuiltinOptions_NONE; }; template<> struct BuiltinOptionsTraits<tflite::Conv2DOptions> { static const BuiltinOptions enum_value = BuiltinOptions_Conv2DOptions; }; template<> struct BuiltinOptionsTraits<tflite::DepthwiseConv2DOptions> { static const BuiltinOptions enum_value = BuiltinOptions_DepthwiseConv2DOptions; }; template<> struct BuiltinOptionsTraits<tflite::ConcatEmbeddingsOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ConcatEmbeddingsOptions; }; template<> struct BuiltinOptionsTraits<tflite::LSHProjectionOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LSHProjectionOptions; }; template<> struct BuiltinOptionsTraits<tflite::Pool2DOptions> { static const BuiltinOptions enum_value = BuiltinOptions_Pool2DOptions; }; template<> struct BuiltinOptionsTraits<tflite::SVDFOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SVDFOptions; }; template<> struct BuiltinOptionsTraits<tflite::RNNOptions> { static const BuiltinOptions enum_value = BuiltinOptions_RNNOptions; }; template<> struct BuiltinOptionsTraits<tflite::FullyConnectedOptions> { static const BuiltinOptions enum_value = BuiltinOptions_FullyConnectedOptions; }; template<> struct BuiltinOptionsTraits<tflite::SoftmaxOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SoftmaxOptions; }; template<> struct BuiltinOptionsTraits<tflite::ConcatenationOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ConcatenationOptions; }; template<> struct BuiltinOptionsTraits<tflite::AddOptions> { static const BuiltinOptions enum_value = BuiltinOptions_AddOptions; }; template<> struct BuiltinOptionsTraits<tflite::L2NormOptions> { static const BuiltinOptions enum_value = BuiltinOptions_L2NormOptions; }; template<> struct BuiltinOptionsTraits<tflite::LocalResponseNormalizationOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LocalResponseNormalizationOptions; }; template<> struct BuiltinOptionsTraits<tflite::LSTMOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LSTMOptions; }; template<> struct BuiltinOptionsTraits<tflite::ResizeBilinearOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ResizeBilinearOptions; }; template<> struct BuiltinOptionsTraits<tflite::CallOptions> { static const BuiltinOptions enum_value = BuiltinOptions_CallOptions; }; template<> struct BuiltinOptionsTraits<tflite::ReshapeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ReshapeOptions; }; template<> struct BuiltinOptionsTraits<tflite::SkipGramOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SkipGramOptions; }; template<> struct BuiltinOptionsTraits<tflite::SpaceToDepthOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SpaceToDepthOptions; }; template<> struct BuiltinOptionsTraits<tflite::EmbeddingLookupSparseOptions> { static const BuiltinOptions enum_value = BuiltinOptions_EmbeddingLookupSparseOptions; }; template<> struct BuiltinOptionsTraits<tflite::MulOptions> { static const BuiltinOptions enum_value = BuiltinOptions_MulOptions; }; template<> struct BuiltinOptionsTraits<tflite::PadOptions> { static const BuiltinOptions enum_value = BuiltinOptions_PadOptions; }; template<> struct BuiltinOptionsTraits<tflite::GatherOptions> { static const BuiltinOptions enum_value = BuiltinOptions_GatherOptions; }; template<> struct BuiltinOptionsTraits<tflite::BatchToSpaceNDOptions> { static const BuiltinOptions enum_value = BuiltinOptions_BatchToSpaceNDOptions; }; template<> struct BuiltinOptionsTraits<tflite::SpaceToBatchNDOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SpaceToBatchNDOptions; }; template<> struct BuiltinOptionsTraits<tflite::TransposeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_TransposeOptions; }; template<> struct BuiltinOptionsTraits<tflite::ReducerOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ReducerOptions; }; template<> struct BuiltinOptionsTraits<tflite::SubOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SubOptions; }; template<> struct BuiltinOptionsTraits<tflite::DivOptions> { static const BuiltinOptions enum_value = BuiltinOptions_DivOptions; }; template<> struct BuiltinOptionsTraits<tflite::SqueezeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SqueezeOptions; }; template<> struct BuiltinOptionsTraits<tflite::SequenceRNNOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SequenceRNNOptions; }; template<> struct BuiltinOptionsTraits<tflite::StridedSliceOptions> { static const BuiltinOptions enum_value = BuiltinOptions_StridedSliceOptions; }; template<> struct BuiltinOptionsTraits<tflite::ExpOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ExpOptions; }; template<> struct BuiltinOptionsTraits<tflite::TopKV2Options> { static const BuiltinOptions enum_value = BuiltinOptions_TopKV2Options; }; template<> struct BuiltinOptionsTraits<tflite::SplitOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SplitOptions; }; template<> struct BuiltinOptionsTraits<tflite::LogSoftmaxOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LogSoftmaxOptions; }; template<> struct BuiltinOptionsTraits<tflite::CastOptions> { static const BuiltinOptions enum_value = BuiltinOptions_CastOptions; }; template<> struct BuiltinOptionsTraits<tflite::DequantizeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_DequantizeOptions; }; template<> struct BuiltinOptionsTraits<tflite::MaximumMinimumOptions> { static const BuiltinOptions enum_value = BuiltinOptions_MaximumMinimumOptions; }; template<> struct BuiltinOptionsTraits<tflite::ArgMaxOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ArgMaxOptions; }; template<> struct BuiltinOptionsTraits<tflite::LessOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LessOptions; }; template<> struct BuiltinOptionsTraits<tflite::NegOptions> { static const BuiltinOptions enum_value = BuiltinOptions_NegOptions; }; template<> struct BuiltinOptionsTraits<tflite::PadV2Options> { static const BuiltinOptions enum_value = BuiltinOptions_PadV2Options; }; template<> struct BuiltinOptionsTraits<tflite::GreaterOptions> { static const BuiltinOptions enum_value = BuiltinOptions_GreaterOptions; }; template<> struct BuiltinOptionsTraits<tflite::GreaterEqualOptions> { static const BuiltinOptions enum_value = BuiltinOptions_GreaterEqualOptions; }; template<> struct BuiltinOptionsTraits<tflite::LessEqualOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LessEqualOptions; }; template<> struct BuiltinOptionsTraits<tflite::SelectOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SelectOptions; }; template<> struct BuiltinOptionsTraits<tflite::SliceOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SliceOptions; }; template<> struct BuiltinOptionsTraits<tflite::TransposeConvOptions> { static const BuiltinOptions enum_value = BuiltinOptions_TransposeConvOptions; }; template<> struct BuiltinOptionsTraits<tflite::SparseToDenseOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SparseToDenseOptions; }; template<> struct BuiltinOptionsTraits<tflite::TileOptions> { static const BuiltinOptions enum_value = BuiltinOptions_TileOptions; }; template<> struct BuiltinOptionsTraits<tflite::ExpandDimsOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ExpandDimsOptions; }; template<> struct BuiltinOptionsTraits<tflite::EqualOptions> { static const BuiltinOptions enum_value = BuiltinOptions_EqualOptions; }; template<> struct BuiltinOptionsTraits<tflite::NotEqualOptions> { static const BuiltinOptions enum_value = BuiltinOptions_NotEqualOptions; }; template<> struct BuiltinOptionsTraits<tflite::ShapeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ShapeOptions; }; template<> struct BuiltinOptionsTraits<tflite::PowOptions> { static const BuiltinOptions enum_value = BuiltinOptions_PowOptions; }; template<> struct BuiltinOptionsTraits<tflite::ArgMinOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ArgMinOptions; }; template<> struct BuiltinOptionsTraits<tflite::FakeQuantOptions> { static const BuiltinOptions enum_value = BuiltinOptions_FakeQuantOptions; }; template<> struct BuiltinOptionsTraits<tflite::PackOptions> { static const BuiltinOptions enum_value = BuiltinOptions_PackOptions; }; template<> struct BuiltinOptionsTraits<tflite::LogicalOrOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LogicalOrOptions; }; template<> struct BuiltinOptionsTraits<tflite::OneHotOptions> { static const BuiltinOptions enum_value = BuiltinOptions_OneHotOptions; }; template<> struct BuiltinOptionsTraits<tflite::LogicalAndOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LogicalAndOptions; }; template<> struct BuiltinOptionsTraits<tflite::LogicalNotOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LogicalNotOptions; }; template<> struct BuiltinOptionsTraits<tflite::UnpackOptions> { static const BuiltinOptions enum_value = BuiltinOptions_UnpackOptions; }; template<> struct BuiltinOptionsTraits<tflite::FloorDivOptions> { static const BuiltinOptions enum_value = BuiltinOptions_FloorDivOptions; }; template<> struct BuiltinOptionsTraits<tflite::SquareOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SquareOptions; }; template<> struct BuiltinOptionsTraits<tflite::ZerosLikeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ZerosLikeOptions; }; template<> struct BuiltinOptionsTraits<tflite::FillOptions> { static const BuiltinOptions enum_value = BuiltinOptions_FillOptions; }; template<> struct BuiltinOptionsTraits<tflite::BidirectionalSequenceLSTMOptions> { static const BuiltinOptions enum_value = BuiltinOptions_BidirectionalSequenceLSTMOptions; }; template<> struct BuiltinOptionsTraits<tflite::BidirectionalSequenceRNNOptions> { static const BuiltinOptions enum_value = BuiltinOptions_BidirectionalSequenceRNNOptions; }; template<> struct BuiltinOptionsTraits<tflite::UnidirectionalSequenceLSTMOptions> { static const BuiltinOptions enum_value = BuiltinOptions_UnidirectionalSequenceLSTMOptions; }; template<> struct BuiltinOptionsTraits<tflite::FloorModOptions> { static const BuiltinOptions enum_value = BuiltinOptions_FloorModOptions; }; template<> struct BuiltinOptionsTraits<tflite::RangeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_RangeOptions; }; template<> struct BuiltinOptionsTraits<tflite::ResizeNearestNeighborOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ResizeNearestNeighborOptions; }; template<> struct BuiltinOptionsTraits<tflite::LeakyReluOptions> { static const BuiltinOptions enum_value = BuiltinOptions_LeakyReluOptions; }; template<> struct BuiltinOptionsTraits<tflite::SquaredDifferenceOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SquaredDifferenceOptions; }; template<> struct BuiltinOptionsTraits<tflite::MirrorPadOptions> { static const BuiltinOptions enum_value = BuiltinOptions_MirrorPadOptions; }; template<> struct BuiltinOptionsTraits<tflite::AbsOptions> { static const BuiltinOptions enum_value = BuiltinOptions_AbsOptions; }; template<> struct BuiltinOptionsTraits<tflite::SplitVOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SplitVOptions; }; template<> struct BuiltinOptionsTraits<tflite::UniqueOptions> { static const BuiltinOptions enum_value = BuiltinOptions_UniqueOptions; }; template<> struct BuiltinOptionsTraits<tflite::ReverseV2Options> { static const BuiltinOptions enum_value = BuiltinOptions_ReverseV2Options; }; template<> struct BuiltinOptionsTraits<tflite::AddNOptions> { static const BuiltinOptions enum_value = BuiltinOptions_AddNOptions; }; template<> struct BuiltinOptionsTraits<tflite::GatherNdOptions> { static const BuiltinOptions enum_value = BuiltinOptions_GatherNdOptions; }; template<> struct BuiltinOptionsTraits<tflite::CosOptions> { static const BuiltinOptions enum_value = BuiltinOptions_CosOptions; }; template<> struct BuiltinOptionsTraits<tflite::WhereOptions> { static const BuiltinOptions enum_value = BuiltinOptions_WhereOptions; }; template<> struct BuiltinOptionsTraits<tflite::RankOptions> { static const BuiltinOptions enum_value = BuiltinOptions_RankOptions; }; template<> struct BuiltinOptionsTraits<tflite::ReverseSequenceOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ReverseSequenceOptions; }; template<> struct BuiltinOptionsTraits<tflite::MatrixDiagOptions> { static const BuiltinOptions enum_value = BuiltinOptions_MatrixDiagOptions; }; template<> struct BuiltinOptionsTraits<tflite::QuantizeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_QuantizeOptions; }; template<> struct BuiltinOptionsTraits<tflite::MatrixSetDiagOptions> { static const BuiltinOptions enum_value = BuiltinOptions_MatrixSetDiagOptions; }; template<> struct BuiltinOptionsTraits<tflite::HardSwishOptions> { static const BuiltinOptions enum_value = BuiltinOptions_HardSwishOptions; }; template<> struct BuiltinOptionsTraits<tflite::IfOptions> { static const BuiltinOptions enum_value = BuiltinOptions_IfOptions; }; template<> struct BuiltinOptionsTraits<tflite::WhileOptions> { static const BuiltinOptions enum_value = BuiltinOptions_WhileOptions; }; template<> struct BuiltinOptionsTraits<tflite::DepthToSpaceOptions> { static const BuiltinOptions enum_value = BuiltinOptions_DepthToSpaceOptions; }; template<> struct BuiltinOptionsTraits<tflite::NonMaxSuppressionV4Options> { static const BuiltinOptions enum_value = BuiltinOptions_NonMaxSuppressionV4Options; }; template<> struct BuiltinOptionsTraits<tflite::NonMaxSuppressionV5Options> { static const BuiltinOptions enum_value = BuiltinOptions_NonMaxSuppressionV5Options; }; template<> struct BuiltinOptionsTraits<tflite::ScatterNdOptions> { static const BuiltinOptions enum_value = BuiltinOptions_ScatterNdOptions; }; template<> struct BuiltinOptionsTraits<tflite::SelectV2Options> { static const BuiltinOptions enum_value = BuiltinOptions_SelectV2Options; }; template<> struct BuiltinOptionsTraits<tflite::DensifyOptions> { static const BuiltinOptions enum_value = BuiltinOptions_DensifyOptions; }; template<> struct BuiltinOptionsTraits<tflite::SegmentSumOptions> { static const BuiltinOptions enum_value = BuiltinOptions_SegmentSumOptions; }; template<> struct BuiltinOptionsTraits<tflite::BatchMatMulOptions> { static const BuiltinOptions enum_value = BuiltinOptions_BatchMatMulOptions; }; template<> struct BuiltinOptionsTraits<tflite::CumsumOptions> { static const BuiltinOptions enum_value = BuiltinOptions_CumsumOptions; }; template<> struct BuiltinOptionsTraits<tflite::CallOnceOptions> { static const BuiltinOptions enum_value = BuiltinOptions_CallOnceOptions; }; template<> struct BuiltinOptionsTraits<tflite::BroadcastToOptions> { static const BuiltinOptions enum_value = BuiltinOptions_BroadcastToOptions; }; template<> struct BuiltinOptionsTraits<tflite::Rfft2dOptions> { static const BuiltinOptions enum_value = BuiltinOptions_Rfft2dOptions; }; template<> struct BuiltinOptionsTraits<tflite::Conv3DOptions> { static const BuiltinOptions enum_value = BuiltinOptions_Conv3DOptions; }; template<> struct BuiltinOptionsTraits<tflite::HashtableOptions> { static const BuiltinOptions enum_value = BuiltinOptions_HashtableOptions; }; template<> struct BuiltinOptionsTraits<tflite::HashtableFindOptions> { static const BuiltinOptions enum_value = BuiltinOptions_HashtableFindOptions; }; template<> struct BuiltinOptionsTraits<tflite::HashtableImportOptions> { static const BuiltinOptions enum_value = BuiltinOptions_HashtableImportOptions; }; template<> struct BuiltinOptionsTraits<tflite::HashtableSizeOptions> { static const BuiltinOptions enum_value = BuiltinOptions_HashtableSizeOptions; }; struct BuiltinOptionsUnion { BuiltinOptions type; void *value; BuiltinOptionsUnion() : type(BuiltinOptions_NONE), value(nullptr) {} BuiltinOptionsUnion(BuiltinOptionsUnion&& u) FLATBUFFERS_NOEXCEPT : type(BuiltinOptions_NONE), value(nullptr) { std::swap(type, u.type); std::swap(value, u.value); } BuiltinOptionsUnion(const BuiltinOptionsUnion &) FLATBUFFERS_NOEXCEPT; BuiltinOptionsUnion &operator=(const BuiltinOptionsUnion &u) FLATBUFFERS_NOEXCEPT { BuiltinOptionsUnion t(u); std::swap(type, t.type); std::swap(value, t.value); return *this; } BuiltinOptionsUnion &operator=(BuiltinOptionsUnion &&u) FLATBUFFERS_NOEXCEPT { std::swap(type, u.type); std::swap(value, u.value); return *this; } ~BuiltinOptionsUnion() { Reset(); } void Reset(); #ifndef FLATBUFFERS_CPP98_STL template <typename T> void Set(T&& val) { using RT = typename std::remove_reference<T>::type; Reset(); type = BuiltinOptionsTraits<typename RT::TableType>::enum_value; if (type != BuiltinOptions_NONE) { value = new RT(std::forward<T>(val)); } } #endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, BuiltinOptions type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset<void> Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; tflite::Conv2DOptionsT *AsConv2DOptions() { return type == BuiltinOptions_Conv2DOptions ? reinterpret_cast<tflite::Conv2DOptionsT *>(value) : nullptr; } const tflite::Conv2DOptionsT *AsConv2DOptions() const { return type == BuiltinOptions_Conv2DOptions ? reinterpret_cast<const tflite::Conv2DOptionsT *>(value) : nullptr; } tflite::DepthwiseConv2DOptionsT *AsDepthwiseConv2DOptions() { return type == BuiltinOptions_DepthwiseConv2DOptions ? reinterpret_cast<tflite::DepthwiseConv2DOptionsT *>(value) : nullptr; } const tflite::DepthwiseConv2DOptionsT *AsDepthwiseConv2DOptions() const { return type == BuiltinOptions_DepthwiseConv2DOptions ? reinterpret_cast<const tflite::DepthwiseConv2DOptionsT *>(value) : nullptr; } tflite::ConcatEmbeddingsOptionsT *AsConcatEmbeddingsOptions() { return type == BuiltinOptions_ConcatEmbeddingsOptions ? reinterpret_cast<tflite::ConcatEmbeddingsOptionsT *>(value) : nullptr; } const tflite::ConcatEmbeddingsOptionsT *AsConcatEmbeddingsOptions() const { return type == BuiltinOptions_ConcatEmbeddingsOptions ? reinterpret_cast<const tflite::ConcatEmbeddingsOptionsT *>(value) : nullptr; } tflite::LSHProjectionOptionsT *AsLSHProjectionOptions() { return type == BuiltinOptions_LSHProjectionOptions ? reinterpret_cast<tflite::LSHProjectionOptionsT *>(value) : nullptr; } const tflite::LSHProjectionOptionsT *AsLSHProjectionOptions() const { return type == BuiltinOptions_LSHProjectionOptions ? reinterpret_cast<const tflite::LSHProjectionOptionsT *>(value) : nullptr; } tflite::Pool2DOptionsT *AsPool2DOptions() { return type == BuiltinOptions_Pool2DOptions ? reinterpret_cast<tflite::Pool2DOptionsT *>(value) : nullptr; } const tflite::Pool2DOptionsT *AsPool2DOptions() const { return type == BuiltinOptions_Pool2DOptions ? reinterpret_cast<const tflite::Pool2DOptionsT *>(value) : nullptr; } tflite::SVDFOptionsT *AsSVDFOptions() { return type == BuiltinOptions_SVDFOptions ? reinterpret_cast<tflite::SVDFOptionsT *>(value) : nullptr; } const tflite::SVDFOptionsT *AsSVDFOptions() const { return type == BuiltinOptions_SVDFOptions ? reinterpret_cast<const tflite::SVDFOptionsT *>(value) : nullptr; } tflite::RNNOptionsT *AsRNNOptions() { return type == BuiltinOptions_RNNOptions ? reinterpret_cast<tflite::RNNOptionsT *>(value) : nullptr; } const tflite::RNNOptionsT *AsRNNOptions() const { return type == BuiltinOptions_RNNOptions ? reinterpret_cast<const tflite::RNNOptionsT *>(value) : nullptr; } tflite::FullyConnectedOptionsT *AsFullyConnectedOptions() { return type == BuiltinOptions_FullyConnectedOptions ? reinterpret_cast<tflite::FullyConnectedOptionsT *>(value) : nullptr; } const tflite::FullyConnectedOptionsT *AsFullyConnectedOptions() const { return type == BuiltinOptions_FullyConnectedOptions ? reinterpret_cast<const tflite::FullyConnectedOptionsT *>(value) : nullptr; } tflite::SoftmaxOptionsT *AsSoftmaxOptions() { return type == BuiltinOptions_SoftmaxOptions ? reinterpret_cast<tflite::SoftmaxOptionsT *>(value) : nullptr; } const tflite::SoftmaxOptionsT *AsSoftmaxOptions() const { return type == BuiltinOptions_SoftmaxOptions ? reinterpret_cast<const tflite::SoftmaxOptionsT *>(value) : nullptr; } tflite::ConcatenationOptionsT *AsConcatenationOptions() { return type == BuiltinOptions_ConcatenationOptions ? reinterpret_cast<tflite::ConcatenationOptionsT *>(value) : nullptr; } const tflite::ConcatenationOptionsT *AsConcatenationOptions() const { return type == BuiltinOptions_ConcatenationOptions ? reinterpret_cast<const tflite::ConcatenationOptionsT *>(value) : nullptr; } tflite::AddOptionsT *AsAddOptions() { return type == BuiltinOptions_AddOptions ? reinterpret_cast<tflite::AddOptionsT *>(value) : nullptr; } const tflite::AddOptionsT *AsAddOptions() const { return type == BuiltinOptions_AddOptions ? reinterpret_cast<const tflite::AddOptionsT *>(value) : nullptr; } tflite::L2NormOptionsT *AsL2NormOptions() { return type == BuiltinOptions_L2NormOptions ? reinterpret_cast<tflite::L2NormOptionsT *>(value) : nullptr; } const tflite::L2NormOptionsT *AsL2NormOptions() const { return type == BuiltinOptions_L2NormOptions ? reinterpret_cast<const tflite::L2NormOptionsT *>(value) : nullptr; } tflite::LocalResponseNormalizationOptionsT *AsLocalResponseNormalizationOptions() { return type == BuiltinOptions_LocalResponseNormalizationOptions ? reinterpret_cast<tflite::LocalResponseNormalizationOptionsT *>(value) : nullptr; } const tflite::LocalResponseNormalizationOptionsT *AsLocalResponseNormalizationOptions() const { return type == BuiltinOptions_LocalResponseNormalizationOptions ? reinterpret_cast<const tflite::LocalResponseNormalizationOptionsT *>(value) : nullptr; } tflite::LSTMOptionsT *AsLSTMOptions() { return type == BuiltinOptions_LSTMOptions ? reinterpret_cast<tflite::LSTMOptionsT *>(value) : nullptr; } const tflite::LSTMOptionsT *AsLSTMOptions() const { return type == BuiltinOptions_LSTMOptions ? reinterpret_cast<const tflite::LSTMOptionsT *>(value) : nullptr; } tflite::ResizeBilinearOptionsT *AsResizeBilinearOptions() { return type == BuiltinOptions_ResizeBilinearOptions ? reinterpret_cast<tflite::ResizeBilinearOptionsT *>(value) : nullptr; } const tflite::ResizeBilinearOptionsT *AsResizeBilinearOptions() const { return type == BuiltinOptions_ResizeBilinearOptions ? reinterpret_cast<const tflite::ResizeBilinearOptionsT *>(value) : nullptr; } tflite::CallOptionsT *AsCallOptions() { return type == BuiltinOptions_CallOptions ? reinterpret_cast<tflite::CallOptionsT *>(value) : nullptr; } const tflite::CallOptionsT *AsCallOptions() const { return type == BuiltinOptions_CallOptions ? reinterpret_cast<const tflite::CallOptionsT *>(value) : nullptr; } tflite::ReshapeOptionsT *AsReshapeOptions() { return type == BuiltinOptions_ReshapeOptions ? reinterpret_cast<tflite::ReshapeOptionsT *>(value) : nullptr; } const tflite::ReshapeOptionsT *AsReshapeOptions() const { return type == BuiltinOptions_ReshapeOptions ? reinterpret_cast<const tflite::ReshapeOptionsT *>(value) : nullptr; } tflite::SkipGramOptionsT *AsSkipGramOptions() { return type == BuiltinOptions_SkipGramOptions ? reinterpret_cast<tflite::SkipGramOptionsT *>(value) : nullptr; } const tflite::SkipGramOptionsT *AsSkipGramOptions() const { return type == BuiltinOptions_SkipGramOptions ? reinterpret_cast<const tflite::SkipGramOptionsT *>(value) : nullptr; } tflite::SpaceToDepthOptionsT *AsSpaceToDepthOptions() { return type == BuiltinOptions_SpaceToDepthOptions ? reinterpret_cast<tflite::SpaceToDepthOptionsT *>(value) : nullptr; } const tflite::SpaceToDepthOptionsT *AsSpaceToDepthOptions() const { return type == BuiltinOptions_SpaceToDepthOptions ? reinterpret_cast<const tflite::SpaceToDepthOptionsT *>(value) : nullptr; } tflite::EmbeddingLookupSparseOptionsT *AsEmbeddingLookupSparseOptions() { return type == BuiltinOptions_EmbeddingLookupSparseOptions ? reinterpret_cast<tflite::EmbeddingLookupSparseOptionsT *>(value) : nullptr; } const tflite::EmbeddingLookupSparseOptionsT *AsEmbeddingLookupSparseOptions() const { return type == BuiltinOptions_EmbeddingLookupSparseOptions ? reinterpret_cast<const tflite::EmbeddingLookupSparseOptionsT *>(value) : nullptr; } tflite::MulOptionsT *AsMulOptions() { return type == BuiltinOptions_MulOptions ? reinterpret_cast<tflite::MulOptionsT *>(value) : nullptr; } const tflite::MulOptionsT *AsMulOptions() const { return type == BuiltinOptions_MulOptions ? reinterpret_cast<const tflite::MulOptionsT *>(value) : nullptr; } tflite::PadOptionsT *AsPadOptions() { return type == BuiltinOptions_PadOptions ? reinterpret_cast<tflite::PadOptionsT *>(value) : nullptr; } const tflite::PadOptionsT *AsPadOptions() const { return type == BuiltinOptions_PadOptions ? reinterpret_cast<const tflite::PadOptionsT *>(value) : nullptr; } tflite::GatherOptionsT *AsGatherOptions() { return type == BuiltinOptions_GatherOptions ? reinterpret_cast<tflite::GatherOptionsT *>(value) : nullptr; } const tflite::GatherOptionsT *AsGatherOptions() const { return type == BuiltinOptions_GatherOptions ? reinterpret_cast<const tflite::GatherOptionsT *>(value) : nullptr; } tflite::BatchToSpaceNDOptionsT *AsBatchToSpaceNDOptions() { return type == BuiltinOptions_BatchToSpaceNDOptions ? reinterpret_cast<tflite::BatchToSpaceNDOptionsT *>(value) : nullptr; } const tflite::BatchToSpaceNDOptionsT *AsBatchToSpaceNDOptions() const { return type == BuiltinOptions_BatchToSpaceNDOptions ? reinterpret_cast<const tflite::BatchToSpaceNDOptionsT *>(value) : nullptr; } tflite::SpaceToBatchNDOptionsT *AsSpaceToBatchNDOptions() { return type == BuiltinOptions_SpaceToBatchNDOptions ? reinterpret_cast<tflite::SpaceToBatchNDOptionsT *>(value) : nullptr; } const tflite::SpaceToBatchNDOptionsT *AsSpaceToBatchNDOptions() const { return type == BuiltinOptions_SpaceToBatchNDOptions ? reinterpret_cast<const tflite::SpaceToBatchNDOptionsT *>(value) : nullptr; } tflite::TransposeOptionsT *AsTransposeOptions() { return type == BuiltinOptions_TransposeOptions ? reinterpret_cast<tflite::TransposeOptionsT *>(value) : nullptr; } const tflite::TransposeOptionsT *AsTransposeOptions() const { return type == BuiltinOptions_TransposeOptions ? reinterpret_cast<const tflite::TransposeOptionsT *>(value) : nullptr; } tflite::ReducerOptionsT *AsReducerOptions() { return type == BuiltinOptions_ReducerOptions ? reinterpret_cast<tflite::ReducerOptionsT *>(value) : nullptr; } const tflite::ReducerOptionsT *AsReducerOptions() const { return type == BuiltinOptions_ReducerOptions ? reinterpret_cast<const tflite::ReducerOptionsT *>(value) : nullptr; } tflite::SubOptionsT *AsSubOptions() { return type == BuiltinOptions_SubOptions ? reinterpret_cast<tflite::SubOptionsT *>(value) : nullptr; } const tflite::SubOptionsT *AsSubOptions() const { return type == BuiltinOptions_SubOptions ? reinterpret_cast<const tflite::SubOptionsT *>(value) : nullptr; } tflite::DivOptionsT *AsDivOptions() { return type == BuiltinOptions_DivOptions ? reinterpret_cast<tflite::DivOptionsT *>(value) : nullptr; } const tflite::DivOptionsT *AsDivOptions() const { return type == BuiltinOptions_DivOptions ? reinterpret_cast<const tflite::DivOptionsT *>(value) : nullptr; } tflite::SqueezeOptionsT *AsSqueezeOptions() { return type == BuiltinOptions_SqueezeOptions ? reinterpret_cast<tflite::SqueezeOptionsT *>(value) : nullptr; } const tflite::SqueezeOptionsT *AsSqueezeOptions() const { return type == BuiltinOptions_SqueezeOptions ? reinterpret_cast<const tflite::SqueezeOptionsT *>(value) : nullptr; } tflite::SequenceRNNOptionsT *AsSequenceRNNOptions() { return type == BuiltinOptions_SequenceRNNOptions ? reinterpret_cast<tflite::SequenceRNNOptionsT *>(value) : nullptr; } const tflite::SequenceRNNOptionsT *AsSequenceRNNOptions() const { return type == BuiltinOptions_SequenceRNNOptions ? reinterpret_cast<const tflite::SequenceRNNOptionsT *>(value) : nullptr; } tflite::StridedSliceOptionsT *AsStridedSliceOptions() { return type == BuiltinOptions_StridedSliceOptions ? reinterpret_cast<tflite::StridedSliceOptionsT *>(value) : nullptr; } const tflite::StridedSliceOptionsT *AsStridedSliceOptions() const { return type == BuiltinOptions_StridedSliceOptions ? reinterpret_cast<const tflite::StridedSliceOptionsT *>(value) : nullptr; } tflite::ExpOptionsT *AsExpOptions() { return type == BuiltinOptions_ExpOptions ? reinterpret_cast<tflite::ExpOptionsT *>(value) : nullptr; } const tflite::ExpOptionsT *AsExpOptions() const { return type == BuiltinOptions_ExpOptions ? reinterpret_cast<const tflite::ExpOptionsT *>(value) : nullptr; } tflite::TopKV2OptionsT *AsTopKV2Options() { return type == BuiltinOptions_TopKV2Options ? reinterpret_cast<tflite::TopKV2OptionsT *>(value) : nullptr; } const tflite::TopKV2OptionsT *AsTopKV2Options() const { return type == BuiltinOptions_TopKV2Options ? reinterpret_cast<const tflite::TopKV2OptionsT *>(value) : nullptr; } tflite::SplitOptionsT *AsSplitOptions() { return type == BuiltinOptions_SplitOptions ? reinterpret_cast<tflite::SplitOptionsT *>(value) : nullptr; } const tflite::SplitOptionsT *AsSplitOptions() const { return type == BuiltinOptions_SplitOptions ? reinterpret_cast<const tflite::SplitOptionsT *>(value) : nullptr; } tflite::LogSoftmaxOptionsT *AsLogSoftmaxOptions() { return type == BuiltinOptions_LogSoftmaxOptions ? reinterpret_cast<tflite::LogSoftmaxOptionsT *>(value) : nullptr; } const tflite::LogSoftmaxOptionsT *AsLogSoftmaxOptions() const { return type == BuiltinOptions_LogSoftmaxOptions ? reinterpret_cast<const tflite::LogSoftmaxOptionsT *>(value) : nullptr; } tflite::CastOptionsT *AsCastOptions() { return type == BuiltinOptions_CastOptions ? reinterpret_cast<tflite::CastOptionsT *>(value) : nullptr; } const tflite::CastOptionsT *AsCastOptions() const { return type == BuiltinOptions_CastOptions ? reinterpret_cast<const tflite::CastOptionsT *>(value) : nullptr; } tflite::DequantizeOptionsT *AsDequantizeOptions() { return type == BuiltinOptions_DequantizeOptions ? reinterpret_cast<tflite::DequantizeOptionsT *>(value) : nullptr; } const tflite::DequantizeOptionsT *AsDequantizeOptions() const { return type == BuiltinOptions_DequantizeOptions ? reinterpret_cast<const tflite::DequantizeOptionsT *>(value) : nullptr; } tflite::MaximumMinimumOptionsT *AsMaximumMinimumOptions() { return type == BuiltinOptions_MaximumMinimumOptions ? reinterpret_cast<tflite::MaximumMinimumOptionsT *>(value) : nullptr; } const tflite::MaximumMinimumOptionsT *AsMaximumMinimumOptions() const { return type == BuiltinOptions_MaximumMinimumOptions ? reinterpret_cast<const tflite::MaximumMinimumOptionsT *>(value) : nullptr; } tflite::ArgMaxOptionsT *AsArgMaxOptions() { return type == BuiltinOptions_ArgMaxOptions ? reinterpret_cast<tflite::ArgMaxOptionsT *>(value) : nullptr; } const tflite::ArgMaxOptionsT *AsArgMaxOptions() const { return type == BuiltinOptions_ArgMaxOptions ? reinterpret_cast<const tflite::ArgMaxOptionsT *>(value) : nullptr; } tflite::LessOptionsT *AsLessOptions() { return type == BuiltinOptions_LessOptions ? reinterpret_cast<tflite::LessOptionsT *>(value) : nullptr; } const tflite::LessOptionsT *AsLessOptions() const { return type == BuiltinOptions_LessOptions ? reinterpret_cast<const tflite::LessOptionsT *>(value) : nullptr; } tflite::NegOptionsT *AsNegOptions() { return type == BuiltinOptions_NegOptions ? reinterpret_cast<tflite::NegOptionsT *>(value) : nullptr; } const tflite::NegOptionsT *AsNegOptions() const { return type == BuiltinOptions_NegOptions ? reinterpret_cast<const tflite::NegOptionsT *>(value) : nullptr; } tflite::PadV2OptionsT *AsPadV2Options() { return type == BuiltinOptions_PadV2Options ? reinterpret_cast<tflite::PadV2OptionsT *>(value) : nullptr; } const tflite::PadV2OptionsT *AsPadV2Options() const { return type == BuiltinOptions_PadV2Options ? reinterpret_cast<const tflite::PadV2OptionsT *>(value) : nullptr; } tflite::GreaterOptionsT *AsGreaterOptions() { return type == BuiltinOptions_GreaterOptions ? reinterpret_cast<tflite::GreaterOptionsT *>(value) : nullptr; } const tflite::GreaterOptionsT *AsGreaterOptions() const { return type == BuiltinOptions_GreaterOptions ? reinterpret_cast<const tflite::GreaterOptionsT *>(value) : nullptr; } tflite::GreaterEqualOptionsT *AsGreaterEqualOptions() { return type == BuiltinOptions_GreaterEqualOptions ? reinterpret_cast<tflite::GreaterEqualOptionsT *>(value) : nullptr; } const tflite::GreaterEqualOptionsT *AsGreaterEqualOptions() const { return type == BuiltinOptions_GreaterEqualOptions ? reinterpret_cast<const tflite::GreaterEqualOptionsT *>(value) : nullptr; } tflite::LessEqualOptionsT *AsLessEqualOptions() { return type == BuiltinOptions_LessEqualOptions ? reinterpret_cast<tflite::LessEqualOptionsT *>(value) : nullptr; } const tflite::LessEqualOptionsT *AsLessEqualOptions() const { return type == BuiltinOptions_LessEqualOptions ? reinterpret_cast<const tflite::LessEqualOptionsT *>(value) : nullptr; } tflite::SelectOptionsT *AsSelectOptions() { return type == BuiltinOptions_SelectOptions ? reinterpret_cast<tflite::SelectOptionsT *>(value) : nullptr; } const tflite::SelectOptionsT *AsSelectOptions() const { return type == BuiltinOptions_SelectOptions ? reinterpret_cast<const tflite::SelectOptionsT *>(value) : nullptr; } tflite::SliceOptionsT *AsSliceOptions() { return type == BuiltinOptions_SliceOptions ? reinterpret_cast<tflite::SliceOptionsT *>(value) : nullptr; } const tflite::SliceOptionsT *AsSliceOptions() const { return type == BuiltinOptions_SliceOptions ? reinterpret_cast<const tflite::SliceOptionsT *>(value) : nullptr; } tflite::TransposeConvOptionsT *AsTransposeConvOptions() { return type == BuiltinOptions_TransposeConvOptions ? reinterpret_cast<tflite::TransposeConvOptionsT *>(value) : nullptr; } const tflite::TransposeConvOptionsT *AsTransposeConvOptions() const { return type == BuiltinOptions_TransposeConvOptions ? reinterpret_cast<const tflite::TransposeConvOptionsT *>(value) : nullptr; } tflite::SparseToDenseOptionsT *AsSparseToDenseOptions() { return type == BuiltinOptions_SparseToDenseOptions ? reinterpret_cast<tflite::SparseToDenseOptionsT *>(value) : nullptr; } const tflite::SparseToDenseOptionsT *AsSparseToDenseOptions() const { return type == BuiltinOptions_SparseToDenseOptions ? reinterpret_cast<const tflite::SparseToDenseOptionsT *>(value) : nullptr; } tflite::TileOptionsT *AsTileOptions() { return type == BuiltinOptions_TileOptions ? reinterpret_cast<tflite::TileOptionsT *>(value) : nullptr; } const tflite::TileOptionsT *AsTileOptions() const { return type == BuiltinOptions_TileOptions ? reinterpret_cast<const tflite::TileOptionsT *>(value) : nullptr; } tflite::ExpandDimsOptionsT *AsExpandDimsOptions() { return type == BuiltinOptions_ExpandDimsOptions ? reinterpret_cast<tflite::ExpandDimsOptionsT *>(value) : nullptr; } const tflite::ExpandDimsOptionsT *AsExpandDimsOptions() const { return type == BuiltinOptions_ExpandDimsOptions ? reinterpret_cast<const tflite::ExpandDimsOptionsT *>(value) : nullptr; } tflite::EqualOptionsT *AsEqualOptions() { return type == BuiltinOptions_EqualOptions ? reinterpret_cast<tflite::EqualOptionsT *>(value) : nullptr; } const tflite::EqualOptionsT *AsEqualOptions() const { return type == BuiltinOptions_EqualOptions ? reinterpret_cast<const tflite::EqualOptionsT *>(value) : nullptr; } tflite::NotEqualOptionsT *AsNotEqualOptions() { return type == BuiltinOptions_NotEqualOptions ? reinterpret_cast<tflite::NotEqualOptionsT *>(value) : nullptr; } const tflite::NotEqualOptionsT *AsNotEqualOptions() const { return type == BuiltinOptions_NotEqualOptions ? reinterpret_cast<const tflite::NotEqualOptionsT *>(value) : nullptr; } tflite::ShapeOptionsT *AsShapeOptions() { return type == BuiltinOptions_ShapeOptions ? reinterpret_cast<tflite::ShapeOptionsT *>(value) : nullptr; } const tflite::ShapeOptionsT *AsShapeOptions() const { return type == BuiltinOptions_ShapeOptions ? reinterpret_cast<const tflite::ShapeOptionsT *>(value) : nullptr; } tflite::PowOptionsT *AsPowOptions() { return type == BuiltinOptions_PowOptions ? reinterpret_cast<tflite::PowOptionsT *>(value) : nullptr; } const tflite::PowOptionsT *AsPowOptions() const { return type == BuiltinOptions_PowOptions ? reinterpret_cast<const tflite::PowOptionsT *>(value) : nullptr; } tflite::ArgMinOptionsT *AsArgMinOptions() { return type == BuiltinOptions_ArgMinOptions ? reinterpret_cast<tflite::ArgMinOptionsT *>(value) : nullptr; } const tflite::ArgMinOptionsT *AsArgMinOptions() const { return type == BuiltinOptions_ArgMinOptions ? reinterpret_cast<const tflite::ArgMinOptionsT *>(value) : nullptr; } tflite::FakeQuantOptionsT *AsFakeQuantOptions() { return type == BuiltinOptions_FakeQuantOptions ? reinterpret_cast<tflite::FakeQuantOptionsT *>(value) : nullptr; } const tflite::FakeQuantOptionsT *AsFakeQuantOptions() const { return type == BuiltinOptions_FakeQuantOptions ? reinterpret_cast<const tflite::FakeQuantOptionsT *>(value) : nullptr; } tflite::PackOptionsT *AsPackOptions() { return type == BuiltinOptions_PackOptions ? reinterpret_cast<tflite::PackOptionsT *>(value) : nullptr; } const tflite::PackOptionsT *AsPackOptions() const { return type == BuiltinOptions_PackOptions ? reinterpret_cast<const tflite::PackOptionsT *>(value) : nullptr; } tflite::LogicalOrOptionsT *AsLogicalOrOptions() { return type == BuiltinOptions_LogicalOrOptions ? reinterpret_cast<tflite::LogicalOrOptionsT *>(value) : nullptr; } const tflite::LogicalOrOptionsT *AsLogicalOrOptions() const { return type == BuiltinOptions_LogicalOrOptions ? reinterpret_cast<const tflite::LogicalOrOptionsT *>(value) : nullptr; } tflite::OneHotOptionsT *AsOneHotOptions() { return type == BuiltinOptions_OneHotOptions ? reinterpret_cast<tflite::OneHotOptionsT *>(value) : nullptr; } const tflite::OneHotOptionsT *AsOneHotOptions() const { return type == BuiltinOptions_OneHotOptions ? reinterpret_cast<const tflite::OneHotOptionsT *>(value) : nullptr; } tflite::LogicalAndOptionsT *AsLogicalAndOptions() { return type == BuiltinOptions_LogicalAndOptions ? reinterpret_cast<tflite::LogicalAndOptionsT *>(value) : nullptr; } const tflite::LogicalAndOptionsT *AsLogicalAndOptions() const { return type == BuiltinOptions_LogicalAndOptions ? reinterpret_cast<const tflite::LogicalAndOptionsT *>(value) : nullptr; } tflite::LogicalNotOptionsT *AsLogicalNotOptions() { return type == BuiltinOptions_LogicalNotOptions ? reinterpret_cast<tflite::LogicalNotOptionsT *>(value) : nullptr; } const tflite::LogicalNotOptionsT *AsLogicalNotOptions() const { return type == BuiltinOptions_LogicalNotOptions ? reinterpret_cast<const tflite::LogicalNotOptionsT *>(value) : nullptr; } tflite::UnpackOptionsT *AsUnpackOptions() { return type == BuiltinOptions_UnpackOptions ? reinterpret_cast<tflite::UnpackOptionsT *>(value) : nullptr; } const tflite::UnpackOptionsT *AsUnpackOptions() const { return type == BuiltinOptions_UnpackOptions ? reinterpret_cast<const tflite::UnpackOptionsT *>(value) : nullptr; } tflite::FloorDivOptionsT *AsFloorDivOptions() { return type == BuiltinOptions_FloorDivOptions ? reinterpret_cast<tflite::FloorDivOptionsT *>(value) : nullptr; } const tflite::FloorDivOptionsT *AsFloorDivOptions() const { return type == BuiltinOptions_FloorDivOptions ? reinterpret_cast<const tflite::FloorDivOptionsT *>(value) : nullptr; } tflite::SquareOptionsT *AsSquareOptions() { return type == BuiltinOptions_SquareOptions ? reinterpret_cast<tflite::SquareOptionsT *>(value) : nullptr; } const tflite::SquareOptionsT *AsSquareOptions() const { return type == BuiltinOptions_SquareOptions ? reinterpret_cast<const tflite::SquareOptionsT *>(value) : nullptr; } tflite::ZerosLikeOptionsT *AsZerosLikeOptions() { return type == BuiltinOptions_ZerosLikeOptions ? reinterpret_cast<tflite::ZerosLikeOptionsT *>(value) : nullptr; } const tflite::ZerosLikeOptionsT *AsZerosLikeOptions() const { return type == BuiltinOptions_ZerosLikeOptions ? reinterpret_cast<const tflite::ZerosLikeOptionsT *>(value) : nullptr; } tflite::FillOptionsT *AsFillOptions() { return type == BuiltinOptions_FillOptions ? reinterpret_cast<tflite::FillOptionsT *>(value) : nullptr; } const tflite::FillOptionsT *AsFillOptions() const { return type == BuiltinOptions_FillOptions ? reinterpret_cast<const tflite::FillOptionsT *>(value) : nullptr; } tflite::BidirectionalSequenceLSTMOptionsT *AsBidirectionalSequenceLSTMOptions() { return type == BuiltinOptions_BidirectionalSequenceLSTMOptions ? reinterpret_cast<tflite::BidirectionalSequenceLSTMOptionsT *>(value) : nullptr; } const tflite::BidirectionalSequenceLSTMOptionsT *AsBidirectionalSequenceLSTMOptions() const { return type == BuiltinOptions_BidirectionalSequenceLSTMOptions ? reinterpret_cast<const tflite::BidirectionalSequenceLSTMOptionsT *>(value) : nullptr; } tflite::BidirectionalSequenceRNNOptionsT *AsBidirectionalSequenceRNNOptions() { return type == BuiltinOptions_BidirectionalSequenceRNNOptions ? reinterpret_cast<tflite::BidirectionalSequenceRNNOptionsT *>(value) : nullptr; } const tflite::BidirectionalSequenceRNNOptionsT *AsBidirectionalSequenceRNNOptions() const { return type == BuiltinOptions_BidirectionalSequenceRNNOptions ? reinterpret_cast<const tflite::BidirectionalSequenceRNNOptionsT *>(value) : nullptr; } tflite::UnidirectionalSequenceLSTMOptionsT *AsUnidirectionalSequenceLSTMOptions() { return type == BuiltinOptions_UnidirectionalSequenceLSTMOptions ? reinterpret_cast<tflite::UnidirectionalSequenceLSTMOptionsT *>(value) : nullptr; } const tflite::UnidirectionalSequenceLSTMOptionsT *AsUnidirectionalSequenceLSTMOptions() const { return type == BuiltinOptions_UnidirectionalSequenceLSTMOptions ? reinterpret_cast<const tflite::UnidirectionalSequenceLSTMOptionsT *>(value) : nullptr; } tflite::FloorModOptionsT *AsFloorModOptions() { return type == BuiltinOptions_FloorModOptions ? reinterpret_cast<tflite::FloorModOptionsT *>(value) : nullptr; } const tflite::FloorModOptionsT *AsFloorModOptions() const { return type == BuiltinOptions_FloorModOptions ? reinterpret_cast<const tflite::FloorModOptionsT *>(value) : nullptr; } tflite::RangeOptionsT *AsRangeOptions() { return type == BuiltinOptions_RangeOptions ? reinterpret_cast<tflite::RangeOptionsT *>(value) : nullptr; } const tflite::RangeOptionsT *AsRangeOptions() const { return type == BuiltinOptions_RangeOptions ? reinterpret_cast<const tflite::RangeOptionsT *>(value) : nullptr; } tflite::ResizeNearestNeighborOptionsT *AsResizeNearestNeighborOptions() { return type == BuiltinOptions_ResizeNearestNeighborOptions ? reinterpret_cast<tflite::ResizeNearestNeighborOptionsT *>(value) : nullptr; } const tflite::ResizeNearestNeighborOptionsT *AsResizeNearestNeighborOptions() const { return type == BuiltinOptions_ResizeNearestNeighborOptions ? reinterpret_cast<const tflite::ResizeNearestNeighborOptionsT *>(value) : nullptr; } tflite::LeakyReluOptionsT *AsLeakyReluOptions() { return type == BuiltinOptions_LeakyReluOptions ? reinterpret_cast<tflite::LeakyReluOptionsT *>(value) : nullptr; } const tflite::LeakyReluOptionsT *AsLeakyReluOptions() const { return type == BuiltinOptions_LeakyReluOptions ? reinterpret_cast<const tflite::LeakyReluOptionsT *>(value) : nullptr; } tflite::SquaredDifferenceOptionsT *AsSquaredDifferenceOptions() { return type == BuiltinOptions_SquaredDifferenceOptions ? reinterpret_cast<tflite::SquaredDifferenceOptionsT *>(value) : nullptr; } const tflite::SquaredDifferenceOptionsT *AsSquaredDifferenceOptions() const { return type == BuiltinOptions_SquaredDifferenceOptions ? reinterpret_cast<const tflite::SquaredDifferenceOptionsT *>(value) : nullptr; } tflite::MirrorPadOptionsT *AsMirrorPadOptions() { return type == BuiltinOptions_MirrorPadOptions ? reinterpret_cast<tflite::MirrorPadOptionsT *>(value) : nullptr; } const tflite::MirrorPadOptionsT *AsMirrorPadOptions() const { return type == BuiltinOptions_MirrorPadOptions ? reinterpret_cast<const tflite::MirrorPadOptionsT *>(value) : nullptr; } tflite::AbsOptionsT *AsAbsOptions() { return type == BuiltinOptions_AbsOptions ? reinterpret_cast<tflite::AbsOptionsT *>(value) : nullptr; } const tflite::AbsOptionsT *AsAbsOptions() const { return type == BuiltinOptions_AbsOptions ? reinterpret_cast<const tflite::AbsOptionsT *>(value) : nullptr; } tflite::SplitVOptionsT *AsSplitVOptions() { return type == BuiltinOptions_SplitVOptions ? reinterpret_cast<tflite::SplitVOptionsT *>(value) : nullptr; } const tflite::SplitVOptionsT *AsSplitVOptions() const { return type == BuiltinOptions_SplitVOptions ? reinterpret_cast<const tflite::SplitVOptionsT *>(value) : nullptr; } tflite::UniqueOptionsT *AsUniqueOptions() { return type == BuiltinOptions_UniqueOptions ? reinterpret_cast<tflite::UniqueOptionsT *>(value) : nullptr; } const tflite::UniqueOptionsT *AsUniqueOptions() const { return type == BuiltinOptions_UniqueOptions ? reinterpret_cast<const tflite::UniqueOptionsT *>(value) : nullptr; } tflite::ReverseV2OptionsT *AsReverseV2Options() { return type == BuiltinOptions_ReverseV2Options ? reinterpret_cast<tflite::ReverseV2OptionsT *>(value) : nullptr; } const tflite::ReverseV2OptionsT *AsReverseV2Options() const { return type == BuiltinOptions_ReverseV2Options ? reinterpret_cast<const tflite::ReverseV2OptionsT *>(value) : nullptr; } tflite::AddNOptionsT *AsAddNOptions() { return type == BuiltinOptions_AddNOptions ? reinterpret_cast<tflite::AddNOptionsT *>(value) : nullptr; } const tflite::AddNOptionsT *AsAddNOptions() const { return type == BuiltinOptions_AddNOptions ? reinterpret_cast<const tflite::AddNOptionsT *>(value) : nullptr; } tflite::GatherNdOptionsT *AsGatherNdOptions() { return type == BuiltinOptions_GatherNdOptions ? reinterpret_cast<tflite::GatherNdOptionsT *>(value) : nullptr; } const tflite::GatherNdOptionsT *AsGatherNdOptions() const { return type == BuiltinOptions_GatherNdOptions ? reinterpret_cast<const tflite::GatherNdOptionsT *>(value) : nullptr; } tflite::CosOptionsT *AsCosOptions() { return type == BuiltinOptions_CosOptions ? reinterpret_cast<tflite::CosOptionsT *>(value) : nullptr; } const tflite::CosOptionsT *AsCosOptions() const { return type == BuiltinOptions_CosOptions ? reinterpret_cast<const tflite::CosOptionsT *>(value) : nullptr; } tflite::WhereOptionsT *AsWhereOptions() { return type == BuiltinOptions_WhereOptions ? reinterpret_cast<tflite::WhereOptionsT *>(value) : nullptr; } const tflite::WhereOptionsT *AsWhereOptions() const { return type == BuiltinOptions_WhereOptions ? reinterpret_cast<const tflite::WhereOptionsT *>(value) : nullptr; } tflite::RankOptionsT *AsRankOptions() { return type == BuiltinOptions_RankOptions ? reinterpret_cast<tflite::RankOptionsT *>(value) : nullptr; } const tflite::RankOptionsT *AsRankOptions() const { return type == BuiltinOptions_RankOptions ? reinterpret_cast<const tflite::RankOptionsT *>(value) : nullptr; } tflite::ReverseSequenceOptionsT *AsReverseSequenceOptions() { return type == BuiltinOptions_ReverseSequenceOptions ? reinterpret_cast<tflite::ReverseSequenceOptionsT *>(value) : nullptr; } const tflite::ReverseSequenceOptionsT *AsReverseSequenceOptions() const { return type == BuiltinOptions_ReverseSequenceOptions ? reinterpret_cast<const tflite::ReverseSequenceOptionsT *>(value) : nullptr; } tflite::MatrixDiagOptionsT *AsMatrixDiagOptions() { return type == BuiltinOptions_MatrixDiagOptions ? reinterpret_cast<tflite::MatrixDiagOptionsT *>(value) : nullptr; } const tflite::MatrixDiagOptionsT *AsMatrixDiagOptions() const { return type == BuiltinOptions_MatrixDiagOptions ? reinterpret_cast<const tflite::MatrixDiagOptionsT *>(value) : nullptr; } tflite::QuantizeOptionsT *AsQuantizeOptions() { return type == BuiltinOptions_QuantizeOptions ? reinterpret_cast<tflite::QuantizeOptionsT *>(value) : nullptr; } const tflite::QuantizeOptionsT *AsQuantizeOptions() const { return type == BuiltinOptions_QuantizeOptions ? reinterpret_cast<const tflite::QuantizeOptionsT *>(value) : nullptr; } tflite::MatrixSetDiagOptionsT *AsMatrixSetDiagOptions() { return type == BuiltinOptions_MatrixSetDiagOptions ? reinterpret_cast<tflite::MatrixSetDiagOptionsT *>(value) : nullptr; } const tflite::MatrixSetDiagOptionsT *AsMatrixSetDiagOptions() const { return type == BuiltinOptions_MatrixSetDiagOptions ? reinterpret_cast<const tflite::MatrixSetDiagOptionsT *>(value) : nullptr; } tflite::HardSwishOptionsT *AsHardSwishOptions() { return type == BuiltinOptions_HardSwishOptions ? reinterpret_cast<tflite::HardSwishOptionsT *>(value) : nullptr; } const tflite::HardSwishOptionsT *AsHardSwishOptions() const { return type == BuiltinOptions_HardSwishOptions ? reinterpret_cast<const tflite::HardSwishOptionsT *>(value) : nullptr; } tflite::IfOptionsT *AsIfOptions() { return type == BuiltinOptions_IfOptions ? reinterpret_cast<tflite::IfOptionsT *>(value) : nullptr; } const tflite::IfOptionsT *AsIfOptions() const { return type == BuiltinOptions_IfOptions ? reinterpret_cast<const tflite::IfOptionsT *>(value) : nullptr; } tflite::WhileOptionsT *AsWhileOptions() { return type == BuiltinOptions_WhileOptions ? reinterpret_cast<tflite::WhileOptionsT *>(value) : nullptr; } const tflite::WhileOptionsT *AsWhileOptions() const { return type == BuiltinOptions_WhileOptions ? reinterpret_cast<const tflite::WhileOptionsT *>(value) : nullptr; } tflite::DepthToSpaceOptionsT *AsDepthToSpaceOptions() { return type == BuiltinOptions_DepthToSpaceOptions ? reinterpret_cast<tflite::DepthToSpaceOptionsT *>(value) : nullptr; } const tflite::DepthToSpaceOptionsT *AsDepthToSpaceOptions() const { return type == BuiltinOptions_DepthToSpaceOptions ? reinterpret_cast<const tflite::DepthToSpaceOptionsT *>(value) : nullptr; } tflite::NonMaxSuppressionV4OptionsT *AsNonMaxSuppressionV4Options() { return type == BuiltinOptions_NonMaxSuppressionV4Options ? reinterpret_cast<tflite::NonMaxSuppressionV4OptionsT *>(value) : nullptr; } const tflite::NonMaxSuppressionV4OptionsT *AsNonMaxSuppressionV4Options() const { return type == BuiltinOptions_NonMaxSuppressionV4Options ? reinterpret_cast<const tflite::NonMaxSuppressionV4OptionsT *>(value) : nullptr; } tflite::NonMaxSuppressionV5OptionsT *AsNonMaxSuppressionV5Options() { return type == BuiltinOptions_NonMaxSuppressionV5Options ? reinterpret_cast<tflite::NonMaxSuppressionV5OptionsT *>(value) : nullptr; } const tflite::NonMaxSuppressionV5OptionsT *AsNonMaxSuppressionV5Options() const { return type == BuiltinOptions_NonMaxSuppressionV5Options ? reinterpret_cast<const tflite::NonMaxSuppressionV5OptionsT *>(value) : nullptr; } tflite::ScatterNdOptionsT *AsScatterNdOptions() { return type == BuiltinOptions_ScatterNdOptions ? reinterpret_cast<tflite::ScatterNdOptionsT *>(value) : nullptr; } const tflite::ScatterNdOptionsT *AsScatterNdOptions() const { return type == BuiltinOptions_ScatterNdOptions ? reinterpret_cast<const tflite::ScatterNdOptionsT *>(value) : nullptr; } tflite::SelectV2OptionsT *AsSelectV2Options() { return type == BuiltinOptions_SelectV2Options ? reinterpret_cast<tflite::SelectV2OptionsT *>(value) : nullptr; } const tflite::SelectV2OptionsT *AsSelectV2Options() const { return type == BuiltinOptions_SelectV2Options ? reinterpret_cast<const tflite::SelectV2OptionsT *>(value) : nullptr; } tflite::DensifyOptionsT *AsDensifyOptions() { return type == BuiltinOptions_DensifyOptions ? reinterpret_cast<tflite::DensifyOptionsT *>(value) : nullptr; } const tflite::DensifyOptionsT *AsDensifyOptions() const { return type == BuiltinOptions_DensifyOptions ? reinterpret_cast<const tflite::DensifyOptionsT *>(value) : nullptr; } tflite::SegmentSumOptionsT *AsSegmentSumOptions() { return type == BuiltinOptions_SegmentSumOptions ? reinterpret_cast<tflite::SegmentSumOptionsT *>(value) : nullptr; } const tflite::SegmentSumOptionsT *AsSegmentSumOptions() const { return type == BuiltinOptions_SegmentSumOptions ? reinterpret_cast<const tflite::SegmentSumOptionsT *>(value) : nullptr; } tflite::BatchMatMulOptionsT *AsBatchMatMulOptions() { return type == BuiltinOptions_BatchMatMulOptions ? reinterpret_cast<tflite::BatchMatMulOptionsT *>(value) : nullptr; } const tflite::BatchMatMulOptionsT *AsBatchMatMulOptions() const { return type == BuiltinOptions_BatchMatMulOptions ? reinterpret_cast<const tflite::BatchMatMulOptionsT *>(value) : nullptr; } tflite::CumsumOptionsT *AsCumsumOptions() { return type == BuiltinOptions_CumsumOptions ? reinterpret_cast<tflite::CumsumOptionsT *>(value) : nullptr; } const tflite::CumsumOptionsT *AsCumsumOptions() const { return type == BuiltinOptions_CumsumOptions ? reinterpret_cast<const tflite::CumsumOptionsT *>(value) : nullptr; } tflite::CallOnceOptionsT *AsCallOnceOptions() { return type == BuiltinOptions_CallOnceOptions ? reinterpret_cast<tflite::CallOnceOptionsT *>(value) : nullptr; } const tflite::CallOnceOptionsT *AsCallOnceOptions() const { return type == BuiltinOptions_CallOnceOptions ? reinterpret_cast<const tflite::CallOnceOptionsT *>(value) : nullptr; } tflite::BroadcastToOptionsT *AsBroadcastToOptions() { return type == BuiltinOptions_BroadcastToOptions ? reinterpret_cast<tflite::BroadcastToOptionsT *>(value) : nullptr; } const tflite::BroadcastToOptionsT *AsBroadcastToOptions() const { return type == BuiltinOptions_BroadcastToOptions ? reinterpret_cast<const tflite::BroadcastToOptionsT *>(value) : nullptr; } tflite::Rfft2dOptionsT *AsRfft2dOptions() { return type == BuiltinOptions_Rfft2dOptions ? reinterpret_cast<tflite::Rfft2dOptionsT *>(value) : nullptr; } const tflite::Rfft2dOptionsT *AsRfft2dOptions() const { return type == BuiltinOptions_Rfft2dOptions ? reinterpret_cast<const tflite::Rfft2dOptionsT *>(value) : nullptr; } tflite::Conv3DOptionsT *AsConv3DOptions() { return type == BuiltinOptions_Conv3DOptions ? reinterpret_cast<tflite::Conv3DOptionsT *>(value) : nullptr; } const tflite::Conv3DOptionsT *AsConv3DOptions() const { return type == BuiltinOptions_Conv3DOptions ? reinterpret_cast<const tflite::Conv3DOptionsT *>(value) : nullptr; } tflite::HashtableOptionsT *AsHashtableOptions() { return type == BuiltinOptions_HashtableOptions ? reinterpret_cast<tflite::HashtableOptionsT *>(value) : nullptr; } const tflite::HashtableOptionsT *AsHashtableOptions() const { return type == BuiltinOptions_HashtableOptions ? reinterpret_cast<const tflite::HashtableOptionsT *>(value) : nullptr; } tflite::HashtableFindOptionsT *AsHashtableFindOptions() { return type == BuiltinOptions_HashtableFindOptions ? reinterpret_cast<tflite::HashtableFindOptionsT *>(value) : nullptr; } const tflite::HashtableFindOptionsT *AsHashtableFindOptions() const { return type == BuiltinOptions_HashtableFindOptions ? reinterpret_cast<const tflite::HashtableFindOptionsT *>(value) : nullptr; } tflite::HashtableImportOptionsT *AsHashtableImportOptions() { return type == BuiltinOptions_HashtableImportOptions ? reinterpret_cast<tflite::HashtableImportOptionsT *>(value) : nullptr; } const tflite::HashtableImportOptionsT *AsHashtableImportOptions() const { return type == BuiltinOptions_HashtableImportOptions ? reinterpret_cast<const tflite::HashtableImportOptionsT *>(value) : nullptr; } tflite::HashtableSizeOptionsT *AsHashtableSizeOptions() { return type == BuiltinOptions_HashtableSizeOptions ? reinterpret_cast<tflite::HashtableSizeOptionsT *>(value) : nullptr; } const tflite::HashtableSizeOptionsT *AsHashtableSizeOptions() const { return type == BuiltinOptions_HashtableSizeOptions ? reinterpret_cast<const tflite::HashtableSizeOptionsT *>(value) : nullptr; } }; bool VerifyBuiltinOptions(flatbuffers::Verifier &verifier, const void *obj, BuiltinOptions type); bool VerifyBuiltinOptionsVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types); enum Padding { Padding_SAME = 0, Padding_VALID = 1, Padding_MIN = Padding_SAME, Padding_MAX = Padding_VALID }; inline const Padding (&EnumValuesPadding())[2] { static const Padding values[] = { Padding_SAME, Padding_VALID }; return values; } inline const char * const *EnumNamesPadding() { static const char * const names[3] = { "SAME", "VALID", nullptr }; return names; } inline const char *EnumNamePadding(Padding e) { if (flatbuffers::IsOutRange(e, Padding_SAME, Padding_VALID)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesPadding()[index]; } enum ActivationFunctionType { ActivationFunctionType_NONE = 0, ActivationFunctionType_RELU = 1, ActivationFunctionType_RELU_N1_TO_1 = 2, ActivationFunctionType_RELU6 = 3, ActivationFunctionType_TANH = 4, ActivationFunctionType_SIGN_BIT = 5, ActivationFunctionType_MIN = ActivationFunctionType_NONE, ActivationFunctionType_MAX = ActivationFunctionType_SIGN_BIT }; inline const ActivationFunctionType (&EnumValuesActivationFunctionType())[6] { static const ActivationFunctionType values[] = { ActivationFunctionType_NONE, ActivationFunctionType_RELU, ActivationFunctionType_RELU_N1_TO_1, ActivationFunctionType_RELU6, ActivationFunctionType_TANH, ActivationFunctionType_SIGN_BIT }; return values; } inline const char * const *EnumNamesActivationFunctionType() { static const char * const names[7] = { "NONE", "RELU", "RELU_N1_TO_1", "RELU6", "TANH", "SIGN_BIT", nullptr }; return names; } inline const char *EnumNameActivationFunctionType(ActivationFunctionType e) { if (flatbuffers::IsOutRange(e, ActivationFunctionType_NONE, ActivationFunctionType_SIGN_BIT)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesActivationFunctionType()[index]; } enum LSHProjectionType { LSHProjectionType_UNKNOWN = 0, LSHProjectionType_SPARSE = 1, LSHProjectionType_DENSE = 2, LSHProjectionType_MIN = LSHProjectionType_UNKNOWN, LSHProjectionType_MAX = LSHProjectionType_DENSE }; inline const LSHProjectionType (&EnumValuesLSHProjectionType())[3] { static const LSHProjectionType values[] = { LSHProjectionType_UNKNOWN, LSHProjectionType_SPARSE, LSHProjectionType_DENSE }; return values; } inline const char * const *EnumNamesLSHProjectionType() { static const char * const names[4] = { "UNKNOWN", "SPARSE", "DENSE", nullptr }; return names; } inline const char *EnumNameLSHProjectionType(LSHProjectionType e) { if (flatbuffers::IsOutRange(e, LSHProjectionType_UNKNOWN, LSHProjectionType_DENSE)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesLSHProjectionType()[index]; } enum FullyConnectedOptionsWeightsFormat { FullyConnectedOptionsWeightsFormat_DEFAULT = 0, FullyConnectedOptionsWeightsFormat_SHUFFLED4x16INT8 = 1, FullyConnectedOptionsWeightsFormat_MIN = FullyConnectedOptionsWeightsFormat_DEFAULT, FullyConnectedOptionsWeightsFormat_MAX = FullyConnectedOptionsWeightsFormat_SHUFFLED4x16INT8 }; inline const FullyConnectedOptionsWeightsFormat (&EnumValuesFullyConnectedOptionsWeightsFormat())[2] { static const FullyConnectedOptionsWeightsFormat values[] = { FullyConnectedOptionsWeightsFormat_DEFAULT, FullyConnectedOptionsWeightsFormat_SHUFFLED4x16INT8 }; return values; } inline const char * const *EnumNamesFullyConnectedOptionsWeightsFormat() { static const char * const names[3] = { "DEFAULT", "SHUFFLED4x16INT8", nullptr }; return names; } inline const char *EnumNameFullyConnectedOptionsWeightsFormat(FullyConnectedOptionsWeightsFormat e) { if (flatbuffers::IsOutRange(e, FullyConnectedOptionsWeightsFormat_DEFAULT, FullyConnectedOptionsWeightsFormat_SHUFFLED4x16INT8)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesFullyConnectedOptionsWeightsFormat()[index]; } enum LSTMKernelType { LSTMKernelType_FULL = 0, LSTMKernelType_BASIC = 1, LSTMKernelType_MIN = LSTMKernelType_FULL, LSTMKernelType_MAX = LSTMKernelType_BASIC }; inline const LSTMKernelType (&EnumValuesLSTMKernelType())[2] { static const LSTMKernelType values[] = { LSTMKernelType_FULL, LSTMKernelType_BASIC }; return values; } inline const char * const *EnumNamesLSTMKernelType() { static const char * const names[3] = { "FULL", "BASIC", nullptr }; return names; } inline const char *EnumNameLSTMKernelType(LSTMKernelType e) { if (flatbuffers::IsOutRange(e, LSTMKernelType_FULL, LSTMKernelType_BASIC)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesLSTMKernelType()[index]; } enum CombinerType { CombinerType_SUM = 0, CombinerType_MEAN = 1, CombinerType_SQRTN = 2, CombinerType_MIN = CombinerType_SUM, CombinerType_MAX = CombinerType_SQRTN }; inline const CombinerType (&EnumValuesCombinerType())[3] { static const CombinerType values[] = { CombinerType_SUM, CombinerType_MEAN, CombinerType_SQRTN }; return values; } inline const char * const *EnumNamesCombinerType() { static const char * const names[4] = { "SUM", "MEAN", "SQRTN", nullptr }; return names; } inline const char *EnumNameCombinerType(CombinerType e) { if (flatbuffers::IsOutRange(e, CombinerType_SUM, CombinerType_SQRTN)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesCombinerType()[index]; } enum MirrorPadMode { MirrorPadMode_REFLECT = 0, MirrorPadMode_SYMMETRIC = 1, MirrorPadMode_MIN = MirrorPadMode_REFLECT, MirrorPadMode_MAX = MirrorPadMode_SYMMETRIC }; inline const MirrorPadMode (&EnumValuesMirrorPadMode())[2] { static const MirrorPadMode values[] = { MirrorPadMode_REFLECT, MirrorPadMode_SYMMETRIC }; return values; } inline const char * const *EnumNamesMirrorPadMode() { static const char * const names[3] = { "REFLECT", "SYMMETRIC", nullptr }; return names; } inline const char *EnumNameMirrorPadMode(MirrorPadMode e) { if (flatbuffers::IsOutRange(e, MirrorPadMode_REFLECT, MirrorPadMode_SYMMETRIC)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesMirrorPadMode()[index]; } enum CustomOptionsFormat { CustomOptionsFormat_FLEXBUFFERS = 0, CustomOptionsFormat_MIN = CustomOptionsFormat_FLEXBUFFERS, CustomOptionsFormat_MAX = CustomOptionsFormat_FLEXBUFFERS }; inline const CustomOptionsFormat (&EnumValuesCustomOptionsFormat())[1] { static const CustomOptionsFormat values[] = { CustomOptionsFormat_FLEXBUFFERS }; return values; } inline const char * const *EnumNamesCustomOptionsFormat() { static const char * const names[2] = { "FLEXBUFFERS", nullptr }; return names; } inline const char *EnumNameCustomOptionsFormat(CustomOptionsFormat e) { if (flatbuffers::IsOutRange(e, CustomOptionsFormat_FLEXBUFFERS, CustomOptionsFormat_FLEXBUFFERS)) return ""; const size_t index = static_cast<size_t>(e); return EnumNamesCustomOptionsFormat()[index]; } struct CustomQuantizationT : public flatbuffers::NativeTable { typedef CustomQuantization TableType; std::vector<uint8_t> custom; CustomQuantizationT() { } }; struct CustomQuantization FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef CustomQuantizationT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_CUSTOM = 4 }; const flatbuffers::Vector<uint8_t> *custom() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_CUSTOM); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_CUSTOM) && verifier.VerifyVector(custom()) && verifier.EndTable(); } CustomQuantizationT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(CustomQuantizationT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<CustomQuantization> Pack(flatbuffers::FlatBufferBuilder &_fbb, const CustomQuantizationT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct CustomQuantizationBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_custom(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> custom) { fbb_.AddOffset(CustomQuantization::VT_CUSTOM, custom); } explicit CustomQuantizationBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CustomQuantizationBuilder &operator=(const CustomQuantizationBuilder &); flatbuffers::Offset<CustomQuantization> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<CustomQuantization>(end); return o; } }; inline flatbuffers::Offset<CustomQuantization> CreateCustomQuantization( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> custom = 0) { CustomQuantizationBuilder builder_(_fbb); builder_.add_custom(custom); return builder_.Finish(); } inline flatbuffers::Offset<CustomQuantization> CreateCustomQuantizationDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<uint8_t> *custom = nullptr) { if (custom) { _fbb.ForceVectorAlignment(custom->size(), sizeof(uint8_t), 16); } auto custom__ = custom ? _fbb.CreateVector<uint8_t>(*custom) : 0; return tflite::CreateCustomQuantization( _fbb, custom__); } flatbuffers::Offset<CustomQuantization> CreateCustomQuantization(flatbuffers::FlatBufferBuilder &_fbb, const CustomQuantizationT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct QuantizationParametersT : public flatbuffers::NativeTable { typedef QuantizationParameters TableType; std::vector<float> min; std::vector<float> max; std::vector<float> scale; std::vector<int64_t> zero_point; tflite::QuantizationDetailsUnion details; int32_t quantized_dimension; QuantizationParametersT() : quantized_dimension(0) { } }; struct QuantizationParameters FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef QuantizationParametersT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_MIN = 4, VT_MAX = 6, VT_SCALE = 8, VT_ZERO_POINT = 10, VT_DETAILS_TYPE = 12, VT_DETAILS = 14, VT_QUANTIZED_DIMENSION = 16 }; const flatbuffers::Vector<float> *min() const { return GetPointer<const flatbuffers::Vector<float> *>(VT_MIN); } const flatbuffers::Vector<float> *max() const { return GetPointer<const flatbuffers::Vector<float> *>(VT_MAX); } const flatbuffers::Vector<float> *scale() const { return GetPointer<const flatbuffers::Vector<float> *>(VT_SCALE); } const flatbuffers::Vector<int64_t> *zero_point() const { return GetPointer<const flatbuffers::Vector<int64_t> *>(VT_ZERO_POINT); } tflite::QuantizationDetails details_type() const { return static_cast<tflite::QuantizationDetails>(GetField<uint8_t>(VT_DETAILS_TYPE, 0)); } const void *details() const { return GetPointer<const void *>(VT_DETAILS); } template<typename T> const T *details_as() const; const tflite::CustomQuantization *details_as_CustomQuantization() const { return details_type() == tflite::QuantizationDetails_CustomQuantization ? static_cast<const tflite::CustomQuantization *>(details()) : nullptr; } int32_t quantized_dimension() const { return GetField<int32_t>(VT_QUANTIZED_DIMENSION, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_MIN) && verifier.VerifyVector(min()) && VerifyOffset(verifier, VT_MAX) && verifier.VerifyVector(max()) && VerifyOffset(verifier, VT_SCALE) && verifier.VerifyVector(scale()) && VerifyOffset(verifier, VT_ZERO_POINT) && verifier.VerifyVector(zero_point()) && VerifyField<uint8_t>(verifier, VT_DETAILS_TYPE) && VerifyOffset(verifier, VT_DETAILS) && VerifyQuantizationDetails(verifier, details(), details_type()) && VerifyField<int32_t>(verifier, VT_QUANTIZED_DIMENSION) && verifier.EndTable(); } QuantizationParametersT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(QuantizationParametersT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<QuantizationParameters> Pack(flatbuffers::FlatBufferBuilder &_fbb, const QuantizationParametersT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; template<> inline const tflite::CustomQuantization *QuantizationParameters::details_as<tflite::CustomQuantization>() const { return details_as_CustomQuantization(); } struct QuantizationParametersBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_min(flatbuffers::Offset<flatbuffers::Vector<float>> min) { fbb_.AddOffset(QuantizationParameters::VT_MIN, min); } void add_max(flatbuffers::Offset<flatbuffers::Vector<float>> max) { fbb_.AddOffset(QuantizationParameters::VT_MAX, max); } void add_scale(flatbuffers::Offset<flatbuffers::Vector<float>> scale) { fbb_.AddOffset(QuantizationParameters::VT_SCALE, scale); } void add_zero_point(flatbuffers::Offset<flatbuffers::Vector<int64_t>> zero_point) { fbb_.AddOffset(QuantizationParameters::VT_ZERO_POINT, zero_point); } void add_details_type(tflite::QuantizationDetails details_type) { fbb_.AddElement<uint8_t>(QuantizationParameters::VT_DETAILS_TYPE, static_cast<uint8_t>(details_type), 0); } void add_details(flatbuffers::Offset<void> details) { fbb_.AddOffset(QuantizationParameters::VT_DETAILS, details); } void add_quantized_dimension(int32_t quantized_dimension) { fbb_.AddElement<int32_t>(QuantizationParameters::VT_QUANTIZED_DIMENSION, quantized_dimension, 0); } explicit QuantizationParametersBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } QuantizationParametersBuilder &operator=(const QuantizationParametersBuilder &); flatbuffers::Offset<QuantizationParameters> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<QuantizationParameters>(end); return o; } }; inline flatbuffers::Offset<QuantizationParameters> CreateQuantizationParameters( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<float>> min = 0, flatbuffers::Offset<flatbuffers::Vector<float>> max = 0, flatbuffers::Offset<flatbuffers::Vector<float>> scale = 0, flatbuffers::Offset<flatbuffers::Vector<int64_t>> zero_point = 0, tflite::QuantizationDetails details_type = tflite::QuantizationDetails_NONE, flatbuffers::Offset<void> details = 0, int32_t quantized_dimension = 0) { QuantizationParametersBuilder builder_(_fbb); builder_.add_quantized_dimension(quantized_dimension); builder_.add_details(details); builder_.add_zero_point(zero_point); builder_.add_scale(scale); builder_.add_max(max); builder_.add_min(min); builder_.add_details_type(details_type); return builder_.Finish(); } inline flatbuffers::Offset<QuantizationParameters> CreateQuantizationParametersDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<float> *min = nullptr, const std::vector<float> *max = nullptr, const std::vector<float> *scale = nullptr, const std::vector<int64_t> *zero_point = nullptr, tflite::QuantizationDetails details_type = tflite::QuantizationDetails_NONE, flatbuffers::Offset<void> details = 0, int32_t quantized_dimension = 0) { auto min__ = min ? _fbb.CreateVector<float>(*min) : 0; auto max__ = max ? _fbb.CreateVector<float>(*max) : 0; auto scale__ = scale ? _fbb.CreateVector<float>(*scale) : 0; auto zero_point__ = zero_point ? _fbb.CreateVector<int64_t>(*zero_point) : 0; return tflite::CreateQuantizationParameters( _fbb, min__, max__, scale__, zero_point__, details_type, details, quantized_dimension); } flatbuffers::Offset<QuantizationParameters> CreateQuantizationParameters(flatbuffers::FlatBufferBuilder &_fbb, const QuantizationParametersT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Int32VectorT : public flatbuffers::NativeTable { typedef Int32Vector TableType; std::vector<int32_t> values; Int32VectorT() { } }; struct Int32Vector FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Int32VectorT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUES = 4 }; const flatbuffers::Vector<int32_t> *values() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_VALUES); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUES) && verifier.VerifyVector(values()) && verifier.EndTable(); } Int32VectorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Int32VectorT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Int32Vector> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Int32VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Int32VectorBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_values(flatbuffers::Offset<flatbuffers::Vector<int32_t>> values) { fbb_.AddOffset(Int32Vector::VT_VALUES, values); } explicit Int32VectorBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Int32VectorBuilder &operator=(const Int32VectorBuilder &); flatbuffers::Offset<Int32Vector> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Int32Vector>(end); return o; } }; inline flatbuffers::Offset<Int32Vector> CreateInt32Vector( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<int32_t>> values = 0) { Int32VectorBuilder builder_(_fbb); builder_.add_values(values); return builder_.Finish(); } inline flatbuffers::Offset<Int32Vector> CreateInt32VectorDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<int32_t> *values = nullptr) { auto values__ = values ? _fbb.CreateVector<int32_t>(*values) : 0; return tflite::CreateInt32Vector( _fbb, values__); } flatbuffers::Offset<Int32Vector> CreateInt32Vector(flatbuffers::FlatBufferBuilder &_fbb, const Int32VectorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Uint16VectorT : public flatbuffers::NativeTable { typedef Uint16Vector TableType; std::vector<uint16_t> values; Uint16VectorT() { } }; struct Uint16Vector FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Uint16VectorT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUES = 4 }; const flatbuffers::Vector<uint16_t> *values() const { return GetPointer<const flatbuffers::Vector<uint16_t> *>(VT_VALUES); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUES) && verifier.VerifyVector(values()) && verifier.EndTable(); } Uint16VectorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Uint16VectorT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Uint16Vector> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Uint16VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Uint16VectorBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_values(flatbuffers::Offset<flatbuffers::Vector<uint16_t>> values) { fbb_.AddOffset(Uint16Vector::VT_VALUES, values); } explicit Uint16VectorBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Uint16VectorBuilder &operator=(const Uint16VectorBuilder &); flatbuffers::Offset<Uint16Vector> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Uint16Vector>(end); return o; } }; inline flatbuffers::Offset<Uint16Vector> CreateUint16Vector( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<uint16_t>> values = 0) { Uint16VectorBuilder builder_(_fbb); builder_.add_values(values); return builder_.Finish(); } inline flatbuffers::Offset<Uint16Vector> CreateUint16VectorDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<uint16_t> *values = nullptr) { if (values) { _fbb.ForceVectorAlignment(values->size(), sizeof(uint16_t), 4); } auto values__ = values ? _fbb.CreateVector<uint16_t>(*values) : 0; return tflite::CreateUint16Vector( _fbb, values__); } flatbuffers::Offset<Uint16Vector> CreateUint16Vector(flatbuffers::FlatBufferBuilder &_fbb, const Uint16VectorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Uint8VectorT : public flatbuffers::NativeTable { typedef Uint8Vector TableType; std::vector<uint8_t> values; Uint8VectorT() { } }; struct Uint8Vector FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Uint8VectorT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUES = 4 }; const flatbuffers::Vector<uint8_t> *values() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_VALUES); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VALUES) && verifier.VerifyVector(values()) && verifier.EndTable(); } Uint8VectorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Uint8VectorT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Uint8Vector> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Uint8VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Uint8VectorBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_values(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> values) { fbb_.AddOffset(Uint8Vector::VT_VALUES, values); } explicit Uint8VectorBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Uint8VectorBuilder &operator=(const Uint8VectorBuilder &); flatbuffers::Offset<Uint8Vector> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Uint8Vector>(end); return o; } }; inline flatbuffers::Offset<Uint8Vector> CreateUint8Vector( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> values = 0) { Uint8VectorBuilder builder_(_fbb); builder_.add_values(values); return builder_.Finish(); } inline flatbuffers::Offset<Uint8Vector> CreateUint8VectorDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<uint8_t> *values = nullptr) { if (values) { _fbb.ForceVectorAlignment(values->size(), sizeof(uint8_t), 4); } auto values__ = values ? _fbb.CreateVector<uint8_t>(*values) : 0; return tflite::CreateUint8Vector( _fbb, values__); } flatbuffers::Offset<Uint8Vector> CreateUint8Vector(flatbuffers::FlatBufferBuilder &_fbb, const Uint8VectorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct DimensionMetadataT : public flatbuffers::NativeTable { typedef DimensionMetadata TableType; tflite::DimensionType format; int32_t dense_size; tflite::SparseIndexVectorUnion array_segments; tflite::SparseIndexVectorUnion array_indices; DimensionMetadataT() : format(tflite::DimensionType_DENSE), dense_size(0) { } }; struct DimensionMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef DimensionMetadataT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FORMAT = 4, VT_DENSE_SIZE = 6, VT_ARRAY_SEGMENTS_TYPE = 8, VT_ARRAY_SEGMENTS = 10, VT_ARRAY_INDICES_TYPE = 12, VT_ARRAY_INDICES = 14 }; tflite::DimensionType format() const { return static_cast<tflite::DimensionType>(GetField<int8_t>(VT_FORMAT, 0)); } int32_t dense_size() const { return GetField<int32_t>(VT_DENSE_SIZE, 0); } tflite::SparseIndexVector array_segments_type() const { return static_cast<tflite::SparseIndexVector>(GetField<uint8_t>(VT_ARRAY_SEGMENTS_TYPE, 0)); } const void *array_segments() const { return GetPointer<const void *>(VT_ARRAY_SEGMENTS); } template<typename T> const T *array_segments_as() const; const tflite::Int32Vector *array_segments_as_Int32Vector() const { return array_segments_type() == tflite::SparseIndexVector_Int32Vector ? static_cast<const tflite::Int32Vector *>(array_segments()) : nullptr; } const tflite::Uint16Vector *array_segments_as_Uint16Vector() const { return array_segments_type() == tflite::SparseIndexVector_Uint16Vector ? static_cast<const tflite::Uint16Vector *>(array_segments()) : nullptr; } const tflite::Uint8Vector *array_segments_as_Uint8Vector() const { return array_segments_type() == tflite::SparseIndexVector_Uint8Vector ? static_cast<const tflite::Uint8Vector *>(array_segments()) : nullptr; } tflite::SparseIndexVector array_indices_type() const { return static_cast<tflite::SparseIndexVector>(GetField<uint8_t>(VT_ARRAY_INDICES_TYPE, 0)); } const void *array_indices() const { return GetPointer<const void *>(VT_ARRAY_INDICES); } template<typename T> const T *array_indices_as() const; const tflite::Int32Vector *array_indices_as_Int32Vector() const { return array_indices_type() == tflite::SparseIndexVector_Int32Vector ? static_cast<const tflite::Int32Vector *>(array_indices()) : nullptr; } const tflite::Uint16Vector *array_indices_as_Uint16Vector() const { return array_indices_type() == tflite::SparseIndexVector_Uint16Vector ? static_cast<const tflite::Uint16Vector *>(array_indices()) : nullptr; } const tflite::Uint8Vector *array_indices_as_Uint8Vector() const { return array_indices_type() == tflite::SparseIndexVector_Uint8Vector ? static_cast<const tflite::Uint8Vector *>(array_indices()) : nullptr; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FORMAT) && VerifyField<int32_t>(verifier, VT_DENSE_SIZE) && VerifyField<uint8_t>(verifier, VT_ARRAY_SEGMENTS_TYPE) && VerifyOffset(verifier, VT_ARRAY_SEGMENTS) && VerifySparseIndexVector(verifier, array_segments(), array_segments_type()) && VerifyField<uint8_t>(verifier, VT_ARRAY_INDICES_TYPE) && VerifyOffset(verifier, VT_ARRAY_INDICES) && VerifySparseIndexVector(verifier, array_indices(), array_indices_type()) && verifier.EndTable(); } DimensionMetadataT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(DimensionMetadataT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<DimensionMetadata> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DimensionMetadataT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; template<> inline const tflite::Int32Vector *DimensionMetadata::array_segments_as<tflite::Int32Vector>() const { return array_segments_as_Int32Vector(); } template<> inline const tflite::Uint16Vector *DimensionMetadata::array_segments_as<tflite::Uint16Vector>() const { return array_segments_as_Uint16Vector(); } template<> inline const tflite::Uint8Vector *DimensionMetadata::array_segments_as<tflite::Uint8Vector>() const { return array_segments_as_Uint8Vector(); } template<> inline const tflite::Int32Vector *DimensionMetadata::array_indices_as<tflite::Int32Vector>() const { return array_indices_as_Int32Vector(); } template<> inline const tflite::Uint16Vector *DimensionMetadata::array_indices_as<tflite::Uint16Vector>() const { return array_indices_as_Uint16Vector(); } template<> inline const tflite::Uint8Vector *DimensionMetadata::array_indices_as<tflite::Uint8Vector>() const { return array_indices_as_Uint8Vector(); } struct DimensionMetadataBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_format(tflite::DimensionType format) { fbb_.AddElement<int8_t>(DimensionMetadata::VT_FORMAT, static_cast<int8_t>(format), 0); } void add_dense_size(int32_t dense_size) { fbb_.AddElement<int32_t>(DimensionMetadata::VT_DENSE_SIZE, dense_size, 0); } void add_array_segments_type(tflite::SparseIndexVector array_segments_type) { fbb_.AddElement<uint8_t>(DimensionMetadata::VT_ARRAY_SEGMENTS_TYPE, static_cast<uint8_t>(array_segments_type), 0); } void add_array_segments(flatbuffers::Offset<void> array_segments) { fbb_.AddOffset(DimensionMetadata::VT_ARRAY_SEGMENTS, array_segments); } void add_array_indices_type(tflite::SparseIndexVector array_indices_type) { fbb_.AddElement<uint8_t>(DimensionMetadata::VT_ARRAY_INDICES_TYPE, static_cast<uint8_t>(array_indices_type), 0); } void add_array_indices(flatbuffers::Offset<void> array_indices) { fbb_.AddOffset(DimensionMetadata::VT_ARRAY_INDICES, array_indices); } explicit DimensionMetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DimensionMetadataBuilder &operator=(const DimensionMetadataBuilder &); flatbuffers::Offset<DimensionMetadata> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<DimensionMetadata>(end); return o; } }; inline flatbuffers::Offset<DimensionMetadata> CreateDimensionMetadata( flatbuffers::FlatBufferBuilder &_fbb, tflite::DimensionType format = tflite::DimensionType_DENSE, int32_t dense_size = 0, tflite::SparseIndexVector array_segments_type = tflite::SparseIndexVector_NONE, flatbuffers::Offset<void> array_segments = 0, tflite::SparseIndexVector array_indices_type = tflite::SparseIndexVector_NONE, flatbuffers::Offset<void> array_indices = 0) { DimensionMetadataBuilder builder_(_fbb); builder_.add_array_indices(array_indices); builder_.add_array_segments(array_segments); builder_.add_dense_size(dense_size); builder_.add_array_indices_type(array_indices_type); builder_.add_array_segments_type(array_segments_type); builder_.add_format(format); return builder_.Finish(); } flatbuffers::Offset<DimensionMetadata> CreateDimensionMetadata(flatbuffers::FlatBufferBuilder &_fbb, const DimensionMetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SparsityParametersT : public flatbuffers::NativeTable { typedef SparsityParameters TableType; std::vector<int32_t> traversal_order; std::vector<int32_t> block_map; std::vector<std::unique_ptr<tflite::DimensionMetadataT>> dim_metadata; SparsityParametersT() { } }; struct SparsityParameters FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SparsityParametersT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TRAVERSAL_ORDER = 4, VT_BLOCK_MAP = 6, VT_DIM_METADATA = 8 }; const flatbuffers::Vector<int32_t> *traversal_order() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_TRAVERSAL_ORDER); } const flatbuffers::Vector<int32_t> *block_map() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_BLOCK_MAP); } const flatbuffers::Vector<flatbuffers::Offset<tflite::DimensionMetadata>> *dim_metadata() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::DimensionMetadata>> *>(VT_DIM_METADATA); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_TRAVERSAL_ORDER) && verifier.VerifyVector(traversal_order()) && VerifyOffset(verifier, VT_BLOCK_MAP) && verifier.VerifyVector(block_map()) && VerifyOffset(verifier, VT_DIM_METADATA) && verifier.VerifyVector(dim_metadata()) && verifier.VerifyVectorOfTables(dim_metadata()) && verifier.EndTable(); } SparsityParametersT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SparsityParametersT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SparsityParameters> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SparsityParametersT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SparsityParametersBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_traversal_order(flatbuffers::Offset<flatbuffers::Vector<int32_t>> traversal_order) { fbb_.AddOffset(SparsityParameters::VT_TRAVERSAL_ORDER, traversal_order); } void add_block_map(flatbuffers::Offset<flatbuffers::Vector<int32_t>> block_map) { fbb_.AddOffset(SparsityParameters::VT_BLOCK_MAP, block_map); } void add_dim_metadata(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::DimensionMetadata>>> dim_metadata) { fbb_.AddOffset(SparsityParameters::VT_DIM_METADATA, dim_metadata); } explicit SparsityParametersBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SparsityParametersBuilder &operator=(const SparsityParametersBuilder &); flatbuffers::Offset<SparsityParameters> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SparsityParameters>(end); return o; } }; inline flatbuffers::Offset<SparsityParameters> CreateSparsityParameters( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<int32_t>> traversal_order = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> block_map = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::DimensionMetadata>>> dim_metadata = 0) { SparsityParametersBuilder builder_(_fbb); builder_.add_dim_metadata(dim_metadata); builder_.add_block_map(block_map); builder_.add_traversal_order(traversal_order); return builder_.Finish(); } inline flatbuffers::Offset<SparsityParameters> CreateSparsityParametersDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<int32_t> *traversal_order = nullptr, const std::vector<int32_t> *block_map = nullptr, const std::vector<flatbuffers::Offset<tflite::DimensionMetadata>> *dim_metadata = nullptr) { auto traversal_order__ = traversal_order ? _fbb.CreateVector<int32_t>(*traversal_order) : 0; auto block_map__ = block_map ? _fbb.CreateVector<int32_t>(*block_map) : 0; auto dim_metadata__ = dim_metadata ? _fbb.CreateVector<flatbuffers::Offset<tflite::DimensionMetadata>>(*dim_metadata) : 0; return tflite::CreateSparsityParameters( _fbb, traversal_order__, block_map__, dim_metadata__); } flatbuffers::Offset<SparsityParameters> CreateSparsityParameters(flatbuffers::FlatBufferBuilder &_fbb, const SparsityParametersT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct TensorT : public flatbuffers::NativeTable { typedef Tensor TableType; std::vector<int32_t> shape; tflite::TensorType type; uint32_t buffer; std::string name; std::unique_ptr<tflite::QuantizationParametersT> quantization; bool is_variable; std::unique_ptr<tflite::SparsityParametersT> sparsity; std::vector<int32_t> shape_signature; TensorT() : type(tflite::TensorType_FLOAT32), buffer(0), is_variable(false) { } }; struct Tensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TensorT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_SHAPE = 4, VT_TYPE = 6, VT_BUFFER = 8, VT_NAME = 10, VT_QUANTIZATION = 12, VT_IS_VARIABLE = 14, VT_SPARSITY = 16, VT_SHAPE_SIGNATURE = 18 }; const flatbuffers::Vector<int32_t> *shape() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_SHAPE); } tflite::TensorType type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_TYPE, 0)); } uint32_t buffer() const { return GetField<uint32_t>(VT_BUFFER, 0); } const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(VT_NAME); } const tflite::QuantizationParameters *quantization() const { return GetPointer<const tflite::QuantizationParameters *>(VT_QUANTIZATION); } bool is_variable() const { return GetField<uint8_t>(VT_IS_VARIABLE, 0) != 0; } const tflite::SparsityParameters *sparsity() const { return GetPointer<const tflite::SparsityParameters *>(VT_SPARSITY); } const flatbuffers::Vector<int32_t> *shape_signature() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_SHAPE_SIGNATURE); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_SHAPE) && verifier.VerifyVector(shape()) && VerifyField<int8_t>(verifier, VT_TYPE) && VerifyField<uint32_t>(verifier, VT_BUFFER) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && VerifyOffset(verifier, VT_QUANTIZATION) && verifier.VerifyTable(quantization()) && VerifyField<uint8_t>(verifier, VT_IS_VARIABLE) && VerifyOffset(verifier, VT_SPARSITY) && verifier.VerifyTable(sparsity()) && VerifyOffset(verifier, VT_SHAPE_SIGNATURE) && verifier.VerifyVector(shape_signature()) && verifier.EndTable(); } TensorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(TensorT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Tensor> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TensorT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct TensorBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_shape(flatbuffers::Offset<flatbuffers::Vector<int32_t>> shape) { fbb_.AddOffset(Tensor::VT_SHAPE, shape); } void add_type(tflite::TensorType type) { fbb_.AddElement<int8_t>(Tensor::VT_TYPE, static_cast<int8_t>(type), 0); } void add_buffer(uint32_t buffer) { fbb_.AddElement<uint32_t>(Tensor::VT_BUFFER, buffer, 0); } void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(Tensor::VT_NAME, name); } void add_quantization(flatbuffers::Offset<tflite::QuantizationParameters> quantization) { fbb_.AddOffset(Tensor::VT_QUANTIZATION, quantization); } void add_is_variable(bool is_variable) { fbb_.AddElement<uint8_t>(Tensor::VT_IS_VARIABLE, static_cast<uint8_t>(is_variable), 0); } void add_sparsity(flatbuffers::Offset<tflite::SparsityParameters> sparsity) { fbb_.AddOffset(Tensor::VT_SPARSITY, sparsity); } void add_shape_signature(flatbuffers::Offset<flatbuffers::Vector<int32_t>> shape_signature) { fbb_.AddOffset(Tensor::VT_SHAPE_SIGNATURE, shape_signature); } explicit TensorBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TensorBuilder &operator=(const TensorBuilder &); flatbuffers::Offset<Tensor> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Tensor>(end); return o; } }; inline flatbuffers::Offset<Tensor> CreateTensor( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<int32_t>> shape = 0, tflite::TensorType type = tflite::TensorType_FLOAT32, uint32_t buffer = 0, flatbuffers::Offset<flatbuffers::String> name = 0, flatbuffers::Offset<tflite::QuantizationParameters> quantization = 0, bool is_variable = false, flatbuffers::Offset<tflite::SparsityParameters> sparsity = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> shape_signature = 0) { TensorBuilder builder_(_fbb); builder_.add_shape_signature(shape_signature); builder_.add_sparsity(sparsity); builder_.add_quantization(quantization); builder_.add_name(name); builder_.add_buffer(buffer); builder_.add_shape(shape); builder_.add_is_variable(is_variable); builder_.add_type(type); return builder_.Finish(); } inline flatbuffers::Offset<Tensor> CreateTensorDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<int32_t> *shape = nullptr, tflite::TensorType type = tflite::TensorType_FLOAT32, uint32_t buffer = 0, const char *name = nullptr, flatbuffers::Offset<tflite::QuantizationParameters> quantization = 0, bool is_variable = false, flatbuffers::Offset<tflite::SparsityParameters> sparsity = 0, const std::vector<int32_t> *shape_signature = nullptr) { auto shape__ = shape ? _fbb.CreateVector<int32_t>(*shape) : 0; auto name__ = name ? _fbb.CreateString(name) : 0; auto shape_signature__ = shape_signature ? _fbb.CreateVector<int32_t>(*shape_signature) : 0; return tflite::CreateTensor( _fbb, shape__, type, buffer, name__, quantization, is_variable, sparsity, shape_signature__); } flatbuffers::Offset<Tensor> CreateTensor(flatbuffers::FlatBufferBuilder &_fbb, const TensorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Conv2DOptionsT : public flatbuffers::NativeTable { typedef Conv2DOptions TableType; tflite::Padding padding; int32_t stride_w; int32_t stride_h; tflite::ActivationFunctionType fused_activation_function; int32_t dilation_w_factor; int32_t dilation_h_factor; Conv2DOptionsT() : padding(tflite::Padding_SAME), stride_w(0), stride_h(0), fused_activation_function(tflite::ActivationFunctionType_NONE), dilation_w_factor(1), dilation_h_factor(1) { } }; struct Conv2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Conv2DOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_STRIDE_W = 6, VT_STRIDE_H = 8, VT_FUSED_ACTIVATION_FUNCTION = 10, VT_DILATION_W_FACTOR = 12, VT_DILATION_H_FACTOR = 14 }; tflite::Padding padding() const { return static_cast<tflite::Padding>(GetField<int8_t>(VT_PADDING, 0)); } int32_t stride_w() const { return GetField<int32_t>(VT_STRIDE_W, 0); } int32_t stride_h() const { return GetField<int32_t>(VT_STRIDE_H, 0); } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } int32_t dilation_w_factor() const { return GetField<int32_t>(VT_DILATION_W_FACTOR, 1); } int32_t dilation_h_factor() const { return GetField<int32_t>(VT_DILATION_H_FACTOR, 1); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_PADDING) && VerifyField<int32_t>(verifier, VT_STRIDE_W) && VerifyField<int32_t>(verifier, VT_STRIDE_H) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<int32_t>(verifier, VT_DILATION_W_FACTOR) && VerifyField<int32_t>(verifier, VT_DILATION_H_FACTOR) && verifier.EndTable(); } Conv2DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Conv2DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Conv2DOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Conv2DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Conv2DOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(tflite::Padding padding) { fbb_.AddElement<int8_t>(Conv2DOptions::VT_PADDING, static_cast<int8_t>(padding), 0); } void add_stride_w(int32_t stride_w) { fbb_.AddElement<int32_t>(Conv2DOptions::VT_STRIDE_W, stride_w, 0); } void add_stride_h(int32_t stride_h) { fbb_.AddElement<int32_t>(Conv2DOptions::VT_STRIDE_H, stride_h, 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(Conv2DOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_dilation_w_factor(int32_t dilation_w_factor) { fbb_.AddElement<int32_t>(Conv2DOptions::VT_DILATION_W_FACTOR, dilation_w_factor, 1); } void add_dilation_h_factor(int32_t dilation_h_factor) { fbb_.AddElement<int32_t>(Conv2DOptions::VT_DILATION_H_FACTOR, dilation_h_factor, 1); } explicit Conv2DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Conv2DOptionsBuilder &operator=(const Conv2DOptionsBuilder &); flatbuffers::Offset<Conv2DOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Conv2DOptions>(end); return o; } }; inline flatbuffers::Offset<Conv2DOptions> CreateConv2DOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::Padding padding = tflite::Padding_SAME, int32_t stride_w = 0, int32_t stride_h = 0, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, int32_t dilation_w_factor = 1, int32_t dilation_h_factor = 1) { Conv2DOptionsBuilder builder_(_fbb); builder_.add_dilation_h_factor(dilation_h_factor); builder_.add_dilation_w_factor(dilation_w_factor); builder_.add_stride_h(stride_h); builder_.add_stride_w(stride_w); builder_.add_fused_activation_function(fused_activation_function); builder_.add_padding(padding); return builder_.Finish(); } flatbuffers::Offset<Conv2DOptions> CreateConv2DOptions(flatbuffers::FlatBufferBuilder &_fbb, const Conv2DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Conv3DOptionsT : public flatbuffers::NativeTable { typedef Conv3DOptions TableType; tflite::Padding padding; int32_t stride_d; int32_t stride_w; int32_t stride_h; tflite::ActivationFunctionType fused_activation_function; int32_t dilation_d_factor; int32_t dilation_w_factor; int32_t dilation_h_factor; Conv3DOptionsT() : padding(tflite::Padding_SAME), stride_d(0), stride_w(0), stride_h(0), fused_activation_function(tflite::ActivationFunctionType_NONE), dilation_d_factor(1), dilation_w_factor(1), dilation_h_factor(1) { } }; struct Conv3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Conv3DOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_STRIDE_D = 6, VT_STRIDE_W = 8, VT_STRIDE_H = 10, VT_FUSED_ACTIVATION_FUNCTION = 12, VT_DILATION_D_FACTOR = 14, VT_DILATION_W_FACTOR = 16, VT_DILATION_H_FACTOR = 18 }; tflite::Padding padding() const { return static_cast<tflite::Padding>(GetField<int8_t>(VT_PADDING, 0)); } int32_t stride_d() const { return GetField<int32_t>(VT_STRIDE_D, 0); } int32_t stride_w() const { return GetField<int32_t>(VT_STRIDE_W, 0); } int32_t stride_h() const { return GetField<int32_t>(VT_STRIDE_H, 0); } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } int32_t dilation_d_factor() const { return GetField<int32_t>(VT_DILATION_D_FACTOR, 1); } int32_t dilation_w_factor() const { return GetField<int32_t>(VT_DILATION_W_FACTOR, 1); } int32_t dilation_h_factor() const { return GetField<int32_t>(VT_DILATION_H_FACTOR, 1); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_PADDING) && VerifyField<int32_t>(verifier, VT_STRIDE_D) && VerifyField<int32_t>(verifier, VT_STRIDE_W) && VerifyField<int32_t>(verifier, VT_STRIDE_H) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<int32_t>(verifier, VT_DILATION_D_FACTOR) && VerifyField<int32_t>(verifier, VT_DILATION_W_FACTOR) && VerifyField<int32_t>(verifier, VT_DILATION_H_FACTOR) && verifier.EndTable(); } Conv3DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Conv3DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Conv3DOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Conv3DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Conv3DOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(tflite::Padding padding) { fbb_.AddElement<int8_t>(Conv3DOptions::VT_PADDING, static_cast<int8_t>(padding), 0); } void add_stride_d(int32_t stride_d) { fbb_.AddElement<int32_t>(Conv3DOptions::VT_STRIDE_D, stride_d, 0); } void add_stride_w(int32_t stride_w) { fbb_.AddElement<int32_t>(Conv3DOptions::VT_STRIDE_W, stride_w, 0); } void add_stride_h(int32_t stride_h) { fbb_.AddElement<int32_t>(Conv3DOptions::VT_STRIDE_H, stride_h, 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(Conv3DOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_dilation_d_factor(int32_t dilation_d_factor) { fbb_.AddElement<int32_t>(Conv3DOptions::VT_DILATION_D_FACTOR, dilation_d_factor, 1); } void add_dilation_w_factor(int32_t dilation_w_factor) { fbb_.AddElement<int32_t>(Conv3DOptions::VT_DILATION_W_FACTOR, dilation_w_factor, 1); } void add_dilation_h_factor(int32_t dilation_h_factor) { fbb_.AddElement<int32_t>(Conv3DOptions::VT_DILATION_H_FACTOR, dilation_h_factor, 1); } explicit Conv3DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Conv3DOptionsBuilder &operator=(const Conv3DOptionsBuilder &); flatbuffers::Offset<Conv3DOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Conv3DOptions>(end); return o; } }; inline flatbuffers::Offset<Conv3DOptions> CreateConv3DOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::Padding padding = tflite::Padding_SAME, int32_t stride_d = 0, int32_t stride_w = 0, int32_t stride_h = 0, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, int32_t dilation_d_factor = 1, int32_t dilation_w_factor = 1, int32_t dilation_h_factor = 1) { Conv3DOptionsBuilder builder_(_fbb); builder_.add_dilation_h_factor(dilation_h_factor); builder_.add_dilation_w_factor(dilation_w_factor); builder_.add_dilation_d_factor(dilation_d_factor); builder_.add_stride_h(stride_h); builder_.add_stride_w(stride_w); builder_.add_stride_d(stride_d); builder_.add_fused_activation_function(fused_activation_function); builder_.add_padding(padding); return builder_.Finish(); } flatbuffers::Offset<Conv3DOptions> CreateConv3DOptions(flatbuffers::FlatBufferBuilder &_fbb, const Conv3DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Pool2DOptionsT : public flatbuffers::NativeTable { typedef Pool2DOptions TableType; tflite::Padding padding; int32_t stride_w; int32_t stride_h; int32_t filter_width; int32_t filter_height; tflite::ActivationFunctionType fused_activation_function; Pool2DOptionsT() : padding(tflite::Padding_SAME), stride_w(0), stride_h(0), filter_width(0), filter_height(0), fused_activation_function(tflite::ActivationFunctionType_NONE) { } }; struct Pool2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Pool2DOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_STRIDE_W = 6, VT_STRIDE_H = 8, VT_FILTER_WIDTH = 10, VT_FILTER_HEIGHT = 12, VT_FUSED_ACTIVATION_FUNCTION = 14 }; tflite::Padding padding() const { return static_cast<tflite::Padding>(GetField<int8_t>(VT_PADDING, 0)); } int32_t stride_w() const { return GetField<int32_t>(VT_STRIDE_W, 0); } int32_t stride_h() const { return GetField<int32_t>(VT_STRIDE_H, 0); } int32_t filter_width() const { return GetField<int32_t>(VT_FILTER_WIDTH, 0); } int32_t filter_height() const { return GetField<int32_t>(VT_FILTER_HEIGHT, 0); } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_PADDING) && VerifyField<int32_t>(verifier, VT_STRIDE_W) && VerifyField<int32_t>(verifier, VT_STRIDE_H) && VerifyField<int32_t>(verifier, VT_FILTER_WIDTH) && VerifyField<int32_t>(verifier, VT_FILTER_HEIGHT) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && verifier.EndTable(); } Pool2DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Pool2DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Pool2DOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Pool2DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Pool2DOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(tflite::Padding padding) { fbb_.AddElement<int8_t>(Pool2DOptions::VT_PADDING, static_cast<int8_t>(padding), 0); } void add_stride_w(int32_t stride_w) { fbb_.AddElement<int32_t>(Pool2DOptions::VT_STRIDE_W, stride_w, 0); } void add_stride_h(int32_t stride_h) { fbb_.AddElement<int32_t>(Pool2DOptions::VT_STRIDE_H, stride_h, 0); } void add_filter_width(int32_t filter_width) { fbb_.AddElement<int32_t>(Pool2DOptions::VT_FILTER_WIDTH, filter_width, 0); } void add_filter_height(int32_t filter_height) { fbb_.AddElement<int32_t>(Pool2DOptions::VT_FILTER_HEIGHT, filter_height, 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(Pool2DOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } explicit Pool2DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Pool2DOptionsBuilder &operator=(const Pool2DOptionsBuilder &); flatbuffers::Offset<Pool2DOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Pool2DOptions>(end); return o; } }; inline flatbuffers::Offset<Pool2DOptions> CreatePool2DOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::Padding padding = tflite::Padding_SAME, int32_t stride_w = 0, int32_t stride_h = 0, int32_t filter_width = 0, int32_t filter_height = 0, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE) { Pool2DOptionsBuilder builder_(_fbb); builder_.add_filter_height(filter_height); builder_.add_filter_width(filter_width); builder_.add_stride_h(stride_h); builder_.add_stride_w(stride_w); builder_.add_fused_activation_function(fused_activation_function); builder_.add_padding(padding); return builder_.Finish(); } flatbuffers::Offset<Pool2DOptions> CreatePool2DOptions(flatbuffers::FlatBufferBuilder &_fbb, const Pool2DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct DepthwiseConv2DOptionsT : public flatbuffers::NativeTable { typedef DepthwiseConv2DOptions TableType; tflite::Padding padding; int32_t stride_w; int32_t stride_h; int32_t depth_multiplier; tflite::ActivationFunctionType fused_activation_function; int32_t dilation_w_factor; int32_t dilation_h_factor; DepthwiseConv2DOptionsT() : padding(tflite::Padding_SAME), stride_w(0), stride_h(0), depth_multiplier(0), fused_activation_function(tflite::ActivationFunctionType_NONE), dilation_w_factor(1), dilation_h_factor(1) { } }; struct DepthwiseConv2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef DepthwiseConv2DOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_STRIDE_W = 6, VT_STRIDE_H = 8, VT_DEPTH_MULTIPLIER = 10, VT_FUSED_ACTIVATION_FUNCTION = 12, VT_DILATION_W_FACTOR = 14, VT_DILATION_H_FACTOR = 16 }; tflite::Padding padding() const { return static_cast<tflite::Padding>(GetField<int8_t>(VT_PADDING, 0)); } int32_t stride_w() const { return GetField<int32_t>(VT_STRIDE_W, 0); } int32_t stride_h() const { return GetField<int32_t>(VT_STRIDE_H, 0); } int32_t depth_multiplier() const { return GetField<int32_t>(VT_DEPTH_MULTIPLIER, 0); } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } int32_t dilation_w_factor() const { return GetField<int32_t>(VT_DILATION_W_FACTOR, 1); } int32_t dilation_h_factor() const { return GetField<int32_t>(VT_DILATION_H_FACTOR, 1); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_PADDING) && VerifyField<int32_t>(verifier, VT_STRIDE_W) && VerifyField<int32_t>(verifier, VT_STRIDE_H) && VerifyField<int32_t>(verifier, VT_DEPTH_MULTIPLIER) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<int32_t>(verifier, VT_DILATION_W_FACTOR) && VerifyField<int32_t>(verifier, VT_DILATION_H_FACTOR) && verifier.EndTable(); } DepthwiseConv2DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(DepthwiseConv2DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<DepthwiseConv2DOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DepthwiseConv2DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct DepthwiseConv2DOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(tflite::Padding padding) { fbb_.AddElement<int8_t>(DepthwiseConv2DOptions::VT_PADDING, static_cast<int8_t>(padding), 0); } void add_stride_w(int32_t stride_w) { fbb_.AddElement<int32_t>(DepthwiseConv2DOptions::VT_STRIDE_W, stride_w, 0); } void add_stride_h(int32_t stride_h) { fbb_.AddElement<int32_t>(DepthwiseConv2DOptions::VT_STRIDE_H, stride_h, 0); } void add_depth_multiplier(int32_t depth_multiplier) { fbb_.AddElement<int32_t>(DepthwiseConv2DOptions::VT_DEPTH_MULTIPLIER, depth_multiplier, 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(DepthwiseConv2DOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_dilation_w_factor(int32_t dilation_w_factor) { fbb_.AddElement<int32_t>(DepthwiseConv2DOptions::VT_DILATION_W_FACTOR, dilation_w_factor, 1); } void add_dilation_h_factor(int32_t dilation_h_factor) { fbb_.AddElement<int32_t>(DepthwiseConv2DOptions::VT_DILATION_H_FACTOR, dilation_h_factor, 1); } explicit DepthwiseConv2DOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DepthwiseConv2DOptionsBuilder &operator=(const DepthwiseConv2DOptionsBuilder &); flatbuffers::Offset<DepthwiseConv2DOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<DepthwiseConv2DOptions>(end); return o; } }; inline flatbuffers::Offset<DepthwiseConv2DOptions> CreateDepthwiseConv2DOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::Padding padding = tflite::Padding_SAME, int32_t stride_w = 0, int32_t stride_h = 0, int32_t depth_multiplier = 0, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, int32_t dilation_w_factor = 1, int32_t dilation_h_factor = 1) { DepthwiseConv2DOptionsBuilder builder_(_fbb); builder_.add_dilation_h_factor(dilation_h_factor); builder_.add_dilation_w_factor(dilation_w_factor); builder_.add_depth_multiplier(depth_multiplier); builder_.add_stride_h(stride_h); builder_.add_stride_w(stride_w); builder_.add_fused_activation_function(fused_activation_function); builder_.add_padding(padding); return builder_.Finish(); } flatbuffers::Offset<DepthwiseConv2DOptions> CreateDepthwiseConv2DOptions(flatbuffers::FlatBufferBuilder &_fbb, const DepthwiseConv2DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ConcatEmbeddingsOptionsT : public flatbuffers::NativeTable { typedef ConcatEmbeddingsOptions TableType; int32_t num_channels; std::vector<int32_t> num_columns_per_channel; std::vector<int32_t> embedding_dim_per_channel; ConcatEmbeddingsOptionsT() : num_channels(0) { } }; struct ConcatEmbeddingsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ConcatEmbeddingsOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NUM_CHANNELS = 4, VT_NUM_COLUMNS_PER_CHANNEL = 6, VT_EMBEDDING_DIM_PER_CHANNEL = 8 }; int32_t num_channels() const { return GetField<int32_t>(VT_NUM_CHANNELS, 0); } const flatbuffers::Vector<int32_t> *num_columns_per_channel() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_NUM_COLUMNS_PER_CHANNEL); } const flatbuffers::Vector<int32_t> *embedding_dim_per_channel() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_EMBEDDING_DIM_PER_CHANNEL); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_NUM_CHANNELS) && VerifyOffset(verifier, VT_NUM_COLUMNS_PER_CHANNEL) && verifier.VerifyVector(num_columns_per_channel()) && VerifyOffset(verifier, VT_EMBEDDING_DIM_PER_CHANNEL) && verifier.VerifyVector(embedding_dim_per_channel()) && verifier.EndTable(); } ConcatEmbeddingsOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ConcatEmbeddingsOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ConcatEmbeddingsOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ConcatEmbeddingsOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ConcatEmbeddingsOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_num_channels(int32_t num_channels) { fbb_.AddElement<int32_t>(ConcatEmbeddingsOptions::VT_NUM_CHANNELS, num_channels, 0); } void add_num_columns_per_channel(flatbuffers::Offset<flatbuffers::Vector<int32_t>> num_columns_per_channel) { fbb_.AddOffset(ConcatEmbeddingsOptions::VT_NUM_COLUMNS_PER_CHANNEL, num_columns_per_channel); } void add_embedding_dim_per_channel(flatbuffers::Offset<flatbuffers::Vector<int32_t>> embedding_dim_per_channel) { fbb_.AddOffset(ConcatEmbeddingsOptions::VT_EMBEDDING_DIM_PER_CHANNEL, embedding_dim_per_channel); } explicit ConcatEmbeddingsOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ConcatEmbeddingsOptionsBuilder &operator=(const ConcatEmbeddingsOptionsBuilder &); flatbuffers::Offset<ConcatEmbeddingsOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ConcatEmbeddingsOptions>(end); return o; } }; inline flatbuffers::Offset<ConcatEmbeddingsOptions> CreateConcatEmbeddingsOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t num_channels = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> num_columns_per_channel = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> embedding_dim_per_channel = 0) { ConcatEmbeddingsOptionsBuilder builder_(_fbb); builder_.add_embedding_dim_per_channel(embedding_dim_per_channel); builder_.add_num_columns_per_channel(num_columns_per_channel); builder_.add_num_channels(num_channels); return builder_.Finish(); } inline flatbuffers::Offset<ConcatEmbeddingsOptions> CreateConcatEmbeddingsOptionsDirect( flatbuffers::FlatBufferBuilder &_fbb, int32_t num_channels = 0, const std::vector<int32_t> *num_columns_per_channel = nullptr, const std::vector<int32_t> *embedding_dim_per_channel = nullptr) { auto num_columns_per_channel__ = num_columns_per_channel ? _fbb.CreateVector<int32_t>(*num_columns_per_channel) : 0; auto embedding_dim_per_channel__ = embedding_dim_per_channel ? _fbb.CreateVector<int32_t>(*embedding_dim_per_channel) : 0; return tflite::CreateConcatEmbeddingsOptions( _fbb, num_channels, num_columns_per_channel__, embedding_dim_per_channel__); } flatbuffers::Offset<ConcatEmbeddingsOptions> CreateConcatEmbeddingsOptions(flatbuffers::FlatBufferBuilder &_fbb, const ConcatEmbeddingsOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LSHProjectionOptionsT : public flatbuffers::NativeTable { typedef LSHProjectionOptions TableType; tflite::LSHProjectionType type; LSHProjectionOptionsT() : type(tflite::LSHProjectionType_UNKNOWN) { } }; struct LSHProjectionOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LSHProjectionOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TYPE = 4 }; tflite::LSHProjectionType type() const { return static_cast<tflite::LSHProjectionType>(GetField<int8_t>(VT_TYPE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_TYPE) && verifier.EndTable(); } LSHProjectionOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LSHProjectionOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LSHProjectionOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LSHProjectionOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LSHProjectionOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_type(tflite::LSHProjectionType type) { fbb_.AddElement<int8_t>(LSHProjectionOptions::VT_TYPE, static_cast<int8_t>(type), 0); } explicit LSHProjectionOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LSHProjectionOptionsBuilder &operator=(const LSHProjectionOptionsBuilder &); flatbuffers::Offset<LSHProjectionOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LSHProjectionOptions>(end); return o; } }; inline flatbuffers::Offset<LSHProjectionOptions> CreateLSHProjectionOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::LSHProjectionType type = tflite::LSHProjectionType_UNKNOWN) { LSHProjectionOptionsBuilder builder_(_fbb); builder_.add_type(type); return builder_.Finish(); } flatbuffers::Offset<LSHProjectionOptions> CreateLSHProjectionOptions(flatbuffers::FlatBufferBuilder &_fbb, const LSHProjectionOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SVDFOptionsT : public flatbuffers::NativeTable { typedef SVDFOptions TableType; int32_t rank; tflite::ActivationFunctionType fused_activation_function; bool asymmetric_quantize_inputs; SVDFOptionsT() : rank(0), fused_activation_function(tflite::ActivationFunctionType_NONE), asymmetric_quantize_inputs(false) { } }; struct SVDFOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SVDFOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_RANK = 4, VT_FUSED_ACTIVATION_FUNCTION = 6, VT_ASYMMETRIC_QUANTIZE_INPUTS = 8 }; int32_t rank() const { return GetField<int32_t>(VT_RANK, 0); } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_RANK) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } SVDFOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SVDFOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SVDFOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SVDFOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SVDFOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_rank(int32_t rank) { fbb_.AddElement<int32_t>(SVDFOptions::VT_RANK, rank, 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(SVDFOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(SVDFOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit SVDFOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SVDFOptionsBuilder &operator=(const SVDFOptionsBuilder &); flatbuffers::Offset<SVDFOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SVDFOptions>(end); return o; } }; inline flatbuffers::Offset<SVDFOptions> CreateSVDFOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t rank = 0, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, bool asymmetric_quantize_inputs = false) { SVDFOptionsBuilder builder_(_fbb); builder_.add_rank(rank); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<SVDFOptions> CreateSVDFOptions(flatbuffers::FlatBufferBuilder &_fbb, const SVDFOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct RNNOptionsT : public flatbuffers::NativeTable { typedef RNNOptions TableType; tflite::ActivationFunctionType fused_activation_function; bool asymmetric_quantize_inputs; RNNOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), asymmetric_quantize_inputs(false) { } }; struct RNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef RNNOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_ASYMMETRIC_QUANTIZE_INPUTS = 6 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } RNNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(RNNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<RNNOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const RNNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct RNNOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(RNNOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(RNNOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit RNNOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } RNNOptionsBuilder &operator=(const RNNOptionsBuilder &); flatbuffers::Offset<RNNOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<RNNOptions>(end); return o; } }; inline flatbuffers::Offset<RNNOptions> CreateRNNOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, bool asymmetric_quantize_inputs = false) { RNNOptionsBuilder builder_(_fbb); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<RNNOptions> CreateRNNOptions(flatbuffers::FlatBufferBuilder &_fbb, const RNNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SequenceRNNOptionsT : public flatbuffers::NativeTable { typedef SequenceRNNOptions TableType; bool time_major; tflite::ActivationFunctionType fused_activation_function; bool asymmetric_quantize_inputs; SequenceRNNOptionsT() : time_major(false), fused_activation_function(tflite::ActivationFunctionType_NONE), asymmetric_quantize_inputs(false) { } }; struct SequenceRNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SequenceRNNOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TIME_MAJOR = 4, VT_FUSED_ACTIVATION_FUNCTION = 6, VT_ASYMMETRIC_QUANTIZE_INPUTS = 8 }; bool time_major() const { return GetField<uint8_t>(VT_TIME_MAJOR, 0) != 0; } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_TIME_MAJOR) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } SequenceRNNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SequenceRNNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SequenceRNNOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SequenceRNNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SequenceRNNOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_time_major(bool time_major) { fbb_.AddElement<uint8_t>(SequenceRNNOptions::VT_TIME_MAJOR, static_cast<uint8_t>(time_major), 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(SequenceRNNOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(SequenceRNNOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit SequenceRNNOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SequenceRNNOptionsBuilder &operator=(const SequenceRNNOptionsBuilder &); flatbuffers::Offset<SequenceRNNOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SequenceRNNOptions>(end); return o; } }; inline flatbuffers::Offset<SequenceRNNOptions> CreateSequenceRNNOptions( flatbuffers::FlatBufferBuilder &_fbb, bool time_major = false, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, bool asymmetric_quantize_inputs = false) { SequenceRNNOptionsBuilder builder_(_fbb); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_fused_activation_function(fused_activation_function); builder_.add_time_major(time_major); return builder_.Finish(); } flatbuffers::Offset<SequenceRNNOptions> CreateSequenceRNNOptions(flatbuffers::FlatBufferBuilder &_fbb, const SequenceRNNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct BidirectionalSequenceRNNOptionsT : public flatbuffers::NativeTable { typedef BidirectionalSequenceRNNOptions TableType; bool time_major; tflite::ActivationFunctionType fused_activation_function; bool merge_outputs; bool asymmetric_quantize_inputs; BidirectionalSequenceRNNOptionsT() : time_major(false), fused_activation_function(tflite::ActivationFunctionType_NONE), merge_outputs(false), asymmetric_quantize_inputs(false) { } }; struct BidirectionalSequenceRNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BidirectionalSequenceRNNOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TIME_MAJOR = 4, VT_FUSED_ACTIVATION_FUNCTION = 6, VT_MERGE_OUTPUTS = 8, VT_ASYMMETRIC_QUANTIZE_INPUTS = 10 }; bool time_major() const { return GetField<uint8_t>(VT_TIME_MAJOR, 0) != 0; } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool merge_outputs() const { return GetField<uint8_t>(VT_MERGE_OUTPUTS, 0) != 0; } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_TIME_MAJOR) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<uint8_t>(verifier, VT_MERGE_OUTPUTS) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } BidirectionalSequenceRNNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(BidirectionalSequenceRNNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<BidirectionalSequenceRNNOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceRNNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct BidirectionalSequenceRNNOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_time_major(bool time_major) { fbb_.AddElement<uint8_t>(BidirectionalSequenceRNNOptions::VT_TIME_MAJOR, static_cast<uint8_t>(time_major), 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(BidirectionalSequenceRNNOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_merge_outputs(bool merge_outputs) { fbb_.AddElement<uint8_t>(BidirectionalSequenceRNNOptions::VT_MERGE_OUTPUTS, static_cast<uint8_t>(merge_outputs), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(BidirectionalSequenceRNNOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit BidirectionalSequenceRNNOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } BidirectionalSequenceRNNOptionsBuilder &operator=(const BidirectionalSequenceRNNOptionsBuilder &); flatbuffers::Offset<BidirectionalSequenceRNNOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<BidirectionalSequenceRNNOptions>(end); return o; } }; inline flatbuffers::Offset<BidirectionalSequenceRNNOptions> CreateBidirectionalSequenceRNNOptions( flatbuffers::FlatBufferBuilder &_fbb, bool time_major = false, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, bool merge_outputs = false, bool asymmetric_quantize_inputs = false) { BidirectionalSequenceRNNOptionsBuilder builder_(_fbb); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_merge_outputs(merge_outputs); builder_.add_fused_activation_function(fused_activation_function); builder_.add_time_major(time_major); return builder_.Finish(); } flatbuffers::Offset<BidirectionalSequenceRNNOptions> CreateBidirectionalSequenceRNNOptions(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceRNNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct FullyConnectedOptionsT : public flatbuffers::NativeTable { typedef FullyConnectedOptions TableType; tflite::ActivationFunctionType fused_activation_function; tflite::FullyConnectedOptionsWeightsFormat weights_format; bool keep_num_dims; bool asymmetric_quantize_inputs; FullyConnectedOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), weights_format(tflite::FullyConnectedOptionsWeightsFormat_DEFAULT), keep_num_dims(false), asymmetric_quantize_inputs(false) { } }; struct FullyConnectedOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef FullyConnectedOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_WEIGHTS_FORMAT = 6, VT_KEEP_NUM_DIMS = 8, VT_ASYMMETRIC_QUANTIZE_INPUTS = 10 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } tflite::FullyConnectedOptionsWeightsFormat weights_format() const { return static_cast<tflite::FullyConnectedOptionsWeightsFormat>(GetField<int8_t>(VT_WEIGHTS_FORMAT, 0)); } bool keep_num_dims() const { return GetField<uint8_t>(VT_KEEP_NUM_DIMS, 0) != 0; } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<int8_t>(verifier, VT_WEIGHTS_FORMAT) && VerifyField<uint8_t>(verifier, VT_KEEP_NUM_DIMS) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } FullyConnectedOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(FullyConnectedOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<FullyConnectedOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const FullyConnectedOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct FullyConnectedOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(FullyConnectedOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_weights_format(tflite::FullyConnectedOptionsWeightsFormat weights_format) { fbb_.AddElement<int8_t>(FullyConnectedOptions::VT_WEIGHTS_FORMAT, static_cast<int8_t>(weights_format), 0); } void add_keep_num_dims(bool keep_num_dims) { fbb_.AddElement<uint8_t>(FullyConnectedOptions::VT_KEEP_NUM_DIMS, static_cast<uint8_t>(keep_num_dims), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(FullyConnectedOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit FullyConnectedOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } FullyConnectedOptionsBuilder &operator=(const FullyConnectedOptionsBuilder &); flatbuffers::Offset<FullyConnectedOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<FullyConnectedOptions>(end); return o; } }; inline flatbuffers::Offset<FullyConnectedOptions> CreateFullyConnectedOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, tflite::FullyConnectedOptionsWeightsFormat weights_format = tflite::FullyConnectedOptionsWeightsFormat_DEFAULT, bool keep_num_dims = false, bool asymmetric_quantize_inputs = false) { FullyConnectedOptionsBuilder builder_(_fbb); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_keep_num_dims(keep_num_dims); builder_.add_weights_format(weights_format); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<FullyConnectedOptions> CreateFullyConnectedOptions(flatbuffers::FlatBufferBuilder &_fbb, const FullyConnectedOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SoftmaxOptionsT : public flatbuffers::NativeTable { typedef SoftmaxOptions TableType; float beta; SoftmaxOptionsT() : beta(0.0f) { } }; struct SoftmaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SoftmaxOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_BETA = 4 }; float beta() const { return GetField<float>(VT_BETA, 0.0f); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<float>(verifier, VT_BETA) && verifier.EndTable(); } SoftmaxOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SoftmaxOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SoftmaxOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SoftmaxOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SoftmaxOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_beta(float beta) { fbb_.AddElement<float>(SoftmaxOptions::VT_BETA, beta, 0.0f); } explicit SoftmaxOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SoftmaxOptionsBuilder &operator=(const SoftmaxOptionsBuilder &); flatbuffers::Offset<SoftmaxOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SoftmaxOptions>(end); return o; } }; inline flatbuffers::Offset<SoftmaxOptions> CreateSoftmaxOptions( flatbuffers::FlatBufferBuilder &_fbb, float beta = 0.0f) { SoftmaxOptionsBuilder builder_(_fbb); builder_.add_beta(beta); return builder_.Finish(); } flatbuffers::Offset<SoftmaxOptions> CreateSoftmaxOptions(flatbuffers::FlatBufferBuilder &_fbb, const SoftmaxOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ConcatenationOptionsT : public flatbuffers::NativeTable { typedef ConcatenationOptions TableType; int32_t axis; tflite::ActivationFunctionType fused_activation_function; ConcatenationOptionsT() : axis(0), fused_activation_function(tflite::ActivationFunctionType_NONE) { } }; struct ConcatenationOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ConcatenationOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_AXIS = 4, VT_FUSED_ACTIVATION_FUNCTION = 6 }; int32_t axis() const { return GetField<int32_t>(VT_AXIS, 0); } tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_AXIS) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && verifier.EndTable(); } ConcatenationOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ConcatenationOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ConcatenationOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ConcatenationOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ConcatenationOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_axis(int32_t axis) { fbb_.AddElement<int32_t>(ConcatenationOptions::VT_AXIS, axis, 0); } void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(ConcatenationOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } explicit ConcatenationOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ConcatenationOptionsBuilder &operator=(const ConcatenationOptionsBuilder &); flatbuffers::Offset<ConcatenationOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ConcatenationOptions>(end); return o; } }; inline flatbuffers::Offset<ConcatenationOptions> CreateConcatenationOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t axis = 0, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE) { ConcatenationOptionsBuilder builder_(_fbb); builder_.add_axis(axis); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<ConcatenationOptions> CreateConcatenationOptions(flatbuffers::FlatBufferBuilder &_fbb, const ConcatenationOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct AddOptionsT : public flatbuffers::NativeTable { typedef AddOptions TableType; tflite::ActivationFunctionType fused_activation_function; bool pot_scale_int16; AddOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), pot_scale_int16(true) { } }; struct AddOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef AddOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_POT_SCALE_INT16 = 6 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool pot_scale_int16() const { return GetField<uint8_t>(VT_POT_SCALE_INT16, 1) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<uint8_t>(verifier, VT_POT_SCALE_INT16) && verifier.EndTable(); } AddOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(AddOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<AddOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const AddOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct AddOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(AddOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_pot_scale_int16(bool pot_scale_int16) { fbb_.AddElement<uint8_t>(AddOptions::VT_POT_SCALE_INT16, static_cast<uint8_t>(pot_scale_int16), 1); } explicit AddOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } AddOptionsBuilder &operator=(const AddOptionsBuilder &); flatbuffers::Offset<AddOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<AddOptions>(end); return o; } }; inline flatbuffers::Offset<AddOptions> CreateAddOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, bool pot_scale_int16 = true) { AddOptionsBuilder builder_(_fbb); builder_.add_pot_scale_int16(pot_scale_int16); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<AddOptions> CreateAddOptions(flatbuffers::FlatBufferBuilder &_fbb, const AddOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct MulOptionsT : public flatbuffers::NativeTable { typedef MulOptions TableType; tflite::ActivationFunctionType fused_activation_function; MulOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE) { } }; struct MulOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MulOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && verifier.EndTable(); } MulOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(MulOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<MulOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MulOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct MulOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(MulOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } explicit MulOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MulOptionsBuilder &operator=(const MulOptionsBuilder &); flatbuffers::Offset<MulOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<MulOptions>(end); return o; } }; inline flatbuffers::Offset<MulOptions> CreateMulOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE) { MulOptionsBuilder builder_(_fbb); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<MulOptions> CreateMulOptions(flatbuffers::FlatBufferBuilder &_fbb, const MulOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct L2NormOptionsT : public flatbuffers::NativeTable { typedef L2NormOptions TableType; tflite::ActivationFunctionType fused_activation_function; L2NormOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE) { } }; struct L2NormOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef L2NormOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && verifier.EndTable(); } L2NormOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(L2NormOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<L2NormOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const L2NormOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct L2NormOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(L2NormOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } explicit L2NormOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } L2NormOptionsBuilder &operator=(const L2NormOptionsBuilder &); flatbuffers::Offset<L2NormOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<L2NormOptions>(end); return o; } }; inline flatbuffers::Offset<L2NormOptions> CreateL2NormOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE) { L2NormOptionsBuilder builder_(_fbb); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<L2NormOptions> CreateL2NormOptions(flatbuffers::FlatBufferBuilder &_fbb, const L2NormOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LocalResponseNormalizationOptionsT : public flatbuffers::NativeTable { typedef LocalResponseNormalizationOptions TableType; int32_t radius; float bias; float alpha; float beta; LocalResponseNormalizationOptionsT() : radius(0), bias(0.0f), alpha(0.0f), beta(0.0f) { } }; struct LocalResponseNormalizationOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LocalResponseNormalizationOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_RADIUS = 4, VT_BIAS = 6, VT_ALPHA = 8, VT_BETA = 10 }; int32_t radius() const { return GetField<int32_t>(VT_RADIUS, 0); } float bias() const { return GetField<float>(VT_BIAS, 0.0f); } float alpha() const { return GetField<float>(VT_ALPHA, 0.0f); } float beta() const { return GetField<float>(VT_BETA, 0.0f); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_RADIUS) && VerifyField<float>(verifier, VT_BIAS) && VerifyField<float>(verifier, VT_ALPHA) && VerifyField<float>(verifier, VT_BETA) && verifier.EndTable(); } LocalResponseNormalizationOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LocalResponseNormalizationOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LocalResponseNormalizationOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LocalResponseNormalizationOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LocalResponseNormalizationOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_radius(int32_t radius) { fbb_.AddElement<int32_t>(LocalResponseNormalizationOptions::VT_RADIUS, radius, 0); } void add_bias(float bias) { fbb_.AddElement<float>(LocalResponseNormalizationOptions::VT_BIAS, bias, 0.0f); } void add_alpha(float alpha) { fbb_.AddElement<float>(LocalResponseNormalizationOptions::VT_ALPHA, alpha, 0.0f); } void add_beta(float beta) { fbb_.AddElement<float>(LocalResponseNormalizationOptions::VT_BETA, beta, 0.0f); } explicit LocalResponseNormalizationOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LocalResponseNormalizationOptionsBuilder &operator=(const LocalResponseNormalizationOptionsBuilder &); flatbuffers::Offset<LocalResponseNormalizationOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LocalResponseNormalizationOptions>(end); return o; } }; inline flatbuffers::Offset<LocalResponseNormalizationOptions> CreateLocalResponseNormalizationOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t radius = 0, float bias = 0.0f, float alpha = 0.0f, float beta = 0.0f) { LocalResponseNormalizationOptionsBuilder builder_(_fbb); builder_.add_beta(beta); builder_.add_alpha(alpha); builder_.add_bias(bias); builder_.add_radius(radius); return builder_.Finish(); } flatbuffers::Offset<LocalResponseNormalizationOptions> CreateLocalResponseNormalizationOptions(flatbuffers::FlatBufferBuilder &_fbb, const LocalResponseNormalizationOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LSTMOptionsT : public flatbuffers::NativeTable { typedef LSTMOptions TableType; tflite::ActivationFunctionType fused_activation_function; float cell_clip; float proj_clip; tflite::LSTMKernelType kernel_type; bool asymmetric_quantize_inputs; LSTMOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), cell_clip(0.0f), proj_clip(0.0f), kernel_type(tflite::LSTMKernelType_FULL), asymmetric_quantize_inputs(false) { } }; struct LSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LSTMOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_CELL_CLIP = 6, VT_PROJ_CLIP = 8, VT_KERNEL_TYPE = 10, VT_ASYMMETRIC_QUANTIZE_INPUTS = 12 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } float cell_clip() const { return GetField<float>(VT_CELL_CLIP, 0.0f); } float proj_clip() const { return GetField<float>(VT_PROJ_CLIP, 0.0f); } tflite::LSTMKernelType kernel_type() const { return static_cast<tflite::LSTMKernelType>(GetField<int8_t>(VT_KERNEL_TYPE, 0)); } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<float>(verifier, VT_CELL_CLIP) && VerifyField<float>(verifier, VT_PROJ_CLIP) && VerifyField<int8_t>(verifier, VT_KERNEL_TYPE) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } LSTMOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LSTMOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LSTMOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LSTMOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LSTMOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(LSTMOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_cell_clip(float cell_clip) { fbb_.AddElement<float>(LSTMOptions::VT_CELL_CLIP, cell_clip, 0.0f); } void add_proj_clip(float proj_clip) { fbb_.AddElement<float>(LSTMOptions::VT_PROJ_CLIP, proj_clip, 0.0f); } void add_kernel_type(tflite::LSTMKernelType kernel_type) { fbb_.AddElement<int8_t>(LSTMOptions::VT_KERNEL_TYPE, static_cast<int8_t>(kernel_type), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(LSTMOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit LSTMOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LSTMOptionsBuilder &operator=(const LSTMOptionsBuilder &); flatbuffers::Offset<LSTMOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LSTMOptions>(end); return o; } }; inline flatbuffers::Offset<LSTMOptions> CreateLSTMOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, float cell_clip = 0.0f, float proj_clip = 0.0f, tflite::LSTMKernelType kernel_type = tflite::LSTMKernelType_FULL, bool asymmetric_quantize_inputs = false) { LSTMOptionsBuilder builder_(_fbb); builder_.add_proj_clip(proj_clip); builder_.add_cell_clip(cell_clip); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_kernel_type(kernel_type); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<LSTMOptions> CreateLSTMOptions(flatbuffers::FlatBufferBuilder &_fbb, const LSTMOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct UnidirectionalSequenceLSTMOptionsT : public flatbuffers::NativeTable { typedef UnidirectionalSequenceLSTMOptions TableType; tflite::ActivationFunctionType fused_activation_function; float cell_clip; float proj_clip; bool time_major; bool asymmetric_quantize_inputs; UnidirectionalSequenceLSTMOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), cell_clip(0.0f), proj_clip(0.0f), time_major(false), asymmetric_quantize_inputs(false) { } }; struct UnidirectionalSequenceLSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef UnidirectionalSequenceLSTMOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_CELL_CLIP = 6, VT_PROJ_CLIP = 8, VT_TIME_MAJOR = 10, VT_ASYMMETRIC_QUANTIZE_INPUTS = 12 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } float cell_clip() const { return GetField<float>(VT_CELL_CLIP, 0.0f); } float proj_clip() const { return GetField<float>(VT_PROJ_CLIP, 0.0f); } bool time_major() const { return GetField<uint8_t>(VT_TIME_MAJOR, 0) != 0; } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<float>(verifier, VT_CELL_CLIP) && VerifyField<float>(verifier, VT_PROJ_CLIP) && VerifyField<uint8_t>(verifier, VT_TIME_MAJOR) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } UnidirectionalSequenceLSTMOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(UnidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<UnidirectionalSequenceLSTMOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const UnidirectionalSequenceLSTMOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct UnidirectionalSequenceLSTMOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(UnidirectionalSequenceLSTMOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_cell_clip(float cell_clip) { fbb_.AddElement<float>(UnidirectionalSequenceLSTMOptions::VT_CELL_CLIP, cell_clip, 0.0f); } void add_proj_clip(float proj_clip) { fbb_.AddElement<float>(UnidirectionalSequenceLSTMOptions::VT_PROJ_CLIP, proj_clip, 0.0f); } void add_time_major(bool time_major) { fbb_.AddElement<uint8_t>(UnidirectionalSequenceLSTMOptions::VT_TIME_MAJOR, static_cast<uint8_t>(time_major), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(UnidirectionalSequenceLSTMOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit UnidirectionalSequenceLSTMOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } UnidirectionalSequenceLSTMOptionsBuilder &operator=(const UnidirectionalSequenceLSTMOptionsBuilder &); flatbuffers::Offset<UnidirectionalSequenceLSTMOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<UnidirectionalSequenceLSTMOptions>(end); return o; } }; inline flatbuffers::Offset<UnidirectionalSequenceLSTMOptions> CreateUnidirectionalSequenceLSTMOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, float cell_clip = 0.0f, float proj_clip = 0.0f, bool time_major = false, bool asymmetric_quantize_inputs = false) { UnidirectionalSequenceLSTMOptionsBuilder builder_(_fbb); builder_.add_proj_clip(proj_clip); builder_.add_cell_clip(cell_clip); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_time_major(time_major); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<UnidirectionalSequenceLSTMOptions> CreateUnidirectionalSequenceLSTMOptions(flatbuffers::FlatBufferBuilder &_fbb, const UnidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct BidirectionalSequenceLSTMOptionsT : public flatbuffers::NativeTable { typedef BidirectionalSequenceLSTMOptions TableType; tflite::ActivationFunctionType fused_activation_function; float cell_clip; float proj_clip; bool merge_outputs; bool time_major; bool asymmetric_quantize_inputs; BidirectionalSequenceLSTMOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), cell_clip(0.0f), proj_clip(0.0f), merge_outputs(false), time_major(true), asymmetric_quantize_inputs(false) { } }; struct BidirectionalSequenceLSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BidirectionalSequenceLSTMOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_CELL_CLIP = 6, VT_PROJ_CLIP = 8, VT_MERGE_OUTPUTS = 10, VT_TIME_MAJOR = 12, VT_ASYMMETRIC_QUANTIZE_INPUTS = 14 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } float cell_clip() const { return GetField<float>(VT_CELL_CLIP, 0.0f); } float proj_clip() const { return GetField<float>(VT_PROJ_CLIP, 0.0f); } bool merge_outputs() const { return GetField<uint8_t>(VT_MERGE_OUTPUTS, 0) != 0; } bool time_major() const { return GetField<uint8_t>(VT_TIME_MAJOR, 1) != 0; } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<float>(verifier, VT_CELL_CLIP) && VerifyField<float>(verifier, VT_PROJ_CLIP) && VerifyField<uint8_t>(verifier, VT_MERGE_OUTPUTS) && VerifyField<uint8_t>(verifier, VT_TIME_MAJOR) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } BidirectionalSequenceLSTMOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(BidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<BidirectionalSequenceLSTMOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceLSTMOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct BidirectionalSequenceLSTMOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(BidirectionalSequenceLSTMOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_cell_clip(float cell_clip) { fbb_.AddElement<float>(BidirectionalSequenceLSTMOptions::VT_CELL_CLIP, cell_clip, 0.0f); } void add_proj_clip(float proj_clip) { fbb_.AddElement<float>(BidirectionalSequenceLSTMOptions::VT_PROJ_CLIP, proj_clip, 0.0f); } void add_merge_outputs(bool merge_outputs) { fbb_.AddElement<uint8_t>(BidirectionalSequenceLSTMOptions::VT_MERGE_OUTPUTS, static_cast<uint8_t>(merge_outputs), 0); } void add_time_major(bool time_major) { fbb_.AddElement<uint8_t>(BidirectionalSequenceLSTMOptions::VT_TIME_MAJOR, static_cast<uint8_t>(time_major), 1); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(BidirectionalSequenceLSTMOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit BidirectionalSequenceLSTMOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } BidirectionalSequenceLSTMOptionsBuilder &operator=(const BidirectionalSequenceLSTMOptionsBuilder &); flatbuffers::Offset<BidirectionalSequenceLSTMOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<BidirectionalSequenceLSTMOptions>(end); return o; } }; inline flatbuffers::Offset<BidirectionalSequenceLSTMOptions> CreateBidirectionalSequenceLSTMOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, float cell_clip = 0.0f, float proj_clip = 0.0f, bool merge_outputs = false, bool time_major = true, bool asymmetric_quantize_inputs = false) { BidirectionalSequenceLSTMOptionsBuilder builder_(_fbb); builder_.add_proj_clip(proj_clip); builder_.add_cell_clip(cell_clip); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_time_major(time_major); builder_.add_merge_outputs(merge_outputs); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<BidirectionalSequenceLSTMOptions> CreateBidirectionalSequenceLSTMOptions(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ResizeBilinearOptionsT : public flatbuffers::NativeTable { typedef ResizeBilinearOptions TableType; bool align_corners; bool half_pixel_centers; ResizeBilinearOptionsT() : align_corners(false), half_pixel_centers(false) { } }; struct ResizeBilinearOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ResizeBilinearOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_ALIGN_CORNERS = 8, VT_HALF_PIXEL_CENTERS = 10 }; bool align_corners() const { return GetField<uint8_t>(VT_ALIGN_CORNERS, 0) != 0; } bool half_pixel_centers() const { return GetField<uint8_t>(VT_HALF_PIXEL_CENTERS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_ALIGN_CORNERS) && VerifyField<uint8_t>(verifier, VT_HALF_PIXEL_CENTERS) && verifier.EndTable(); } ResizeBilinearOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ResizeBilinearOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ResizeBilinearOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ResizeBilinearOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ResizeBilinearOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_align_corners(bool align_corners) { fbb_.AddElement<uint8_t>(ResizeBilinearOptions::VT_ALIGN_CORNERS, static_cast<uint8_t>(align_corners), 0); } void add_half_pixel_centers(bool half_pixel_centers) { fbb_.AddElement<uint8_t>(ResizeBilinearOptions::VT_HALF_PIXEL_CENTERS, static_cast<uint8_t>(half_pixel_centers), 0); } explicit ResizeBilinearOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ResizeBilinearOptionsBuilder &operator=(const ResizeBilinearOptionsBuilder &); flatbuffers::Offset<ResizeBilinearOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ResizeBilinearOptions>(end); return o; } }; inline flatbuffers::Offset<ResizeBilinearOptions> CreateResizeBilinearOptions( flatbuffers::FlatBufferBuilder &_fbb, bool align_corners = false, bool half_pixel_centers = false) { ResizeBilinearOptionsBuilder builder_(_fbb); builder_.add_half_pixel_centers(half_pixel_centers); builder_.add_align_corners(align_corners); return builder_.Finish(); } flatbuffers::Offset<ResizeBilinearOptions> CreateResizeBilinearOptions(flatbuffers::FlatBufferBuilder &_fbb, const ResizeBilinearOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ResizeNearestNeighborOptionsT : public flatbuffers::NativeTable { typedef ResizeNearestNeighborOptions TableType; bool align_corners; bool half_pixel_centers; ResizeNearestNeighborOptionsT() : align_corners(false), half_pixel_centers(false) { } }; struct ResizeNearestNeighborOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ResizeNearestNeighborOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_ALIGN_CORNERS = 4, VT_HALF_PIXEL_CENTERS = 6 }; bool align_corners() const { return GetField<uint8_t>(VT_ALIGN_CORNERS, 0) != 0; } bool half_pixel_centers() const { return GetField<uint8_t>(VT_HALF_PIXEL_CENTERS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_ALIGN_CORNERS) && VerifyField<uint8_t>(verifier, VT_HALF_PIXEL_CENTERS) && verifier.EndTable(); } ResizeNearestNeighborOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ResizeNearestNeighborOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ResizeNearestNeighborOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ResizeNearestNeighborOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ResizeNearestNeighborOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_align_corners(bool align_corners) { fbb_.AddElement<uint8_t>(ResizeNearestNeighborOptions::VT_ALIGN_CORNERS, static_cast<uint8_t>(align_corners), 0); } void add_half_pixel_centers(bool half_pixel_centers) { fbb_.AddElement<uint8_t>(ResizeNearestNeighborOptions::VT_HALF_PIXEL_CENTERS, static_cast<uint8_t>(half_pixel_centers), 0); } explicit ResizeNearestNeighborOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ResizeNearestNeighborOptionsBuilder &operator=(const ResizeNearestNeighborOptionsBuilder &); flatbuffers::Offset<ResizeNearestNeighborOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ResizeNearestNeighborOptions>(end); return o; } }; inline flatbuffers::Offset<ResizeNearestNeighborOptions> CreateResizeNearestNeighborOptions( flatbuffers::FlatBufferBuilder &_fbb, bool align_corners = false, bool half_pixel_centers = false) { ResizeNearestNeighborOptionsBuilder builder_(_fbb); builder_.add_half_pixel_centers(half_pixel_centers); builder_.add_align_corners(align_corners); return builder_.Finish(); } flatbuffers::Offset<ResizeNearestNeighborOptions> CreateResizeNearestNeighborOptions(flatbuffers::FlatBufferBuilder &_fbb, const ResizeNearestNeighborOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct CallOptionsT : public flatbuffers::NativeTable { typedef CallOptions TableType; uint32_t subgraph; CallOptionsT() : subgraph(0) { } }; struct CallOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef CallOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_SUBGRAPH = 4 }; uint32_t subgraph() const { return GetField<uint32_t>(VT_SUBGRAPH, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint32_t>(verifier, VT_SUBGRAPH) && verifier.EndTable(); } CallOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(CallOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<CallOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const CallOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct CallOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_subgraph(uint32_t subgraph) { fbb_.AddElement<uint32_t>(CallOptions::VT_SUBGRAPH, subgraph, 0); } explicit CallOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CallOptionsBuilder &operator=(const CallOptionsBuilder &); flatbuffers::Offset<CallOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<CallOptions>(end); return o; } }; inline flatbuffers::Offset<CallOptions> CreateCallOptions( flatbuffers::FlatBufferBuilder &_fbb, uint32_t subgraph = 0) { CallOptionsBuilder builder_(_fbb); builder_.add_subgraph(subgraph); return builder_.Finish(); } flatbuffers::Offset<CallOptions> CreateCallOptions(flatbuffers::FlatBufferBuilder &_fbb, const CallOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct PadOptionsT : public flatbuffers::NativeTable { typedef PadOptions TableType; PadOptionsT() { } }; struct PadOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef PadOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } PadOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(PadOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<PadOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const PadOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct PadOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit PadOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } PadOptionsBuilder &operator=(const PadOptionsBuilder &); flatbuffers::Offset<PadOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<PadOptions>(end); return o; } }; inline flatbuffers::Offset<PadOptions> CreatePadOptions( flatbuffers::FlatBufferBuilder &_fbb) { PadOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<PadOptions> CreatePadOptions(flatbuffers::FlatBufferBuilder &_fbb, const PadOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct PadV2OptionsT : public flatbuffers::NativeTable { typedef PadV2Options TableType; PadV2OptionsT() { } }; struct PadV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef PadV2OptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } PadV2OptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(PadV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<PadV2Options> Pack(flatbuffers::FlatBufferBuilder &_fbb, const PadV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct PadV2OptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit PadV2OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } PadV2OptionsBuilder &operator=(const PadV2OptionsBuilder &); flatbuffers::Offset<PadV2Options> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<PadV2Options>(end); return o; } }; inline flatbuffers::Offset<PadV2Options> CreatePadV2Options( flatbuffers::FlatBufferBuilder &_fbb) { PadV2OptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<PadV2Options> CreatePadV2Options(flatbuffers::FlatBufferBuilder &_fbb, const PadV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ReshapeOptionsT : public flatbuffers::NativeTable { typedef ReshapeOptions TableType; std::vector<int32_t> new_shape; ReshapeOptionsT() { } }; struct ReshapeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ReshapeOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NEW_SHAPE = 4 }; const flatbuffers::Vector<int32_t> *new_shape() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_NEW_SHAPE); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NEW_SHAPE) && verifier.VerifyVector(new_shape()) && verifier.EndTable(); } ReshapeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ReshapeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ReshapeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReshapeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ReshapeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_new_shape(flatbuffers::Offset<flatbuffers::Vector<int32_t>> new_shape) { fbb_.AddOffset(ReshapeOptions::VT_NEW_SHAPE, new_shape); } explicit ReshapeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ReshapeOptionsBuilder &operator=(const ReshapeOptionsBuilder &); flatbuffers::Offset<ReshapeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ReshapeOptions>(end); return o; } }; inline flatbuffers::Offset<ReshapeOptions> CreateReshapeOptions( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<int32_t>> new_shape = 0) { ReshapeOptionsBuilder builder_(_fbb); builder_.add_new_shape(new_shape); return builder_.Finish(); } inline flatbuffers::Offset<ReshapeOptions> CreateReshapeOptionsDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<int32_t> *new_shape = nullptr) { auto new_shape__ = new_shape ? _fbb.CreateVector<int32_t>(*new_shape) : 0; return tflite::CreateReshapeOptions( _fbb, new_shape__); } flatbuffers::Offset<ReshapeOptions> CreateReshapeOptions(flatbuffers::FlatBufferBuilder &_fbb, const ReshapeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SpaceToBatchNDOptionsT : public flatbuffers::NativeTable { typedef SpaceToBatchNDOptions TableType; SpaceToBatchNDOptionsT() { } }; struct SpaceToBatchNDOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SpaceToBatchNDOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SpaceToBatchNDOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SpaceToBatchNDOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SpaceToBatchNDOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToBatchNDOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SpaceToBatchNDOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SpaceToBatchNDOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SpaceToBatchNDOptionsBuilder &operator=(const SpaceToBatchNDOptionsBuilder &); flatbuffers::Offset<SpaceToBatchNDOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SpaceToBatchNDOptions>(end); return o; } }; inline flatbuffers::Offset<SpaceToBatchNDOptions> CreateSpaceToBatchNDOptions( flatbuffers::FlatBufferBuilder &_fbb) { SpaceToBatchNDOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SpaceToBatchNDOptions> CreateSpaceToBatchNDOptions(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToBatchNDOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct BatchToSpaceNDOptionsT : public flatbuffers::NativeTable { typedef BatchToSpaceNDOptions TableType; BatchToSpaceNDOptionsT() { } }; struct BatchToSpaceNDOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BatchToSpaceNDOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } BatchToSpaceNDOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(BatchToSpaceNDOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<BatchToSpaceNDOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const BatchToSpaceNDOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct BatchToSpaceNDOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit BatchToSpaceNDOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } BatchToSpaceNDOptionsBuilder &operator=(const BatchToSpaceNDOptionsBuilder &); flatbuffers::Offset<BatchToSpaceNDOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<BatchToSpaceNDOptions>(end); return o; } }; inline flatbuffers::Offset<BatchToSpaceNDOptions> CreateBatchToSpaceNDOptions( flatbuffers::FlatBufferBuilder &_fbb) { BatchToSpaceNDOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<BatchToSpaceNDOptions> CreateBatchToSpaceNDOptions(flatbuffers::FlatBufferBuilder &_fbb, const BatchToSpaceNDOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SkipGramOptionsT : public flatbuffers::NativeTable { typedef SkipGramOptions TableType; int32_t ngram_size; int32_t max_skip_size; bool include_all_ngrams; SkipGramOptionsT() : ngram_size(0), max_skip_size(0), include_all_ngrams(false) { } }; struct SkipGramOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SkipGramOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NGRAM_SIZE = 4, VT_MAX_SKIP_SIZE = 6, VT_INCLUDE_ALL_NGRAMS = 8 }; int32_t ngram_size() const { return GetField<int32_t>(VT_NGRAM_SIZE, 0); } int32_t max_skip_size() const { return GetField<int32_t>(VT_MAX_SKIP_SIZE, 0); } bool include_all_ngrams() const { return GetField<uint8_t>(VT_INCLUDE_ALL_NGRAMS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_NGRAM_SIZE) && VerifyField<int32_t>(verifier, VT_MAX_SKIP_SIZE) && VerifyField<uint8_t>(verifier, VT_INCLUDE_ALL_NGRAMS) && verifier.EndTable(); } SkipGramOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SkipGramOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SkipGramOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SkipGramOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SkipGramOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_ngram_size(int32_t ngram_size) { fbb_.AddElement<int32_t>(SkipGramOptions::VT_NGRAM_SIZE, ngram_size, 0); } void add_max_skip_size(int32_t max_skip_size) { fbb_.AddElement<int32_t>(SkipGramOptions::VT_MAX_SKIP_SIZE, max_skip_size, 0); } void add_include_all_ngrams(bool include_all_ngrams) { fbb_.AddElement<uint8_t>(SkipGramOptions::VT_INCLUDE_ALL_NGRAMS, static_cast<uint8_t>(include_all_ngrams), 0); } explicit SkipGramOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SkipGramOptionsBuilder &operator=(const SkipGramOptionsBuilder &); flatbuffers::Offset<SkipGramOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SkipGramOptions>(end); return o; } }; inline flatbuffers::Offset<SkipGramOptions> CreateSkipGramOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t ngram_size = 0, int32_t max_skip_size = 0, bool include_all_ngrams = false) { SkipGramOptionsBuilder builder_(_fbb); builder_.add_max_skip_size(max_skip_size); builder_.add_ngram_size(ngram_size); builder_.add_include_all_ngrams(include_all_ngrams); return builder_.Finish(); } flatbuffers::Offset<SkipGramOptions> CreateSkipGramOptions(flatbuffers::FlatBufferBuilder &_fbb, const SkipGramOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SpaceToDepthOptionsT : public flatbuffers::NativeTable { typedef SpaceToDepthOptions TableType; int32_t block_size; SpaceToDepthOptionsT() : block_size(0) { } }; struct SpaceToDepthOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SpaceToDepthOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_BLOCK_SIZE = 4 }; int32_t block_size() const { return GetField<int32_t>(VT_BLOCK_SIZE, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_BLOCK_SIZE) && verifier.EndTable(); } SpaceToDepthOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SpaceToDepthOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SpaceToDepthOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToDepthOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SpaceToDepthOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_block_size(int32_t block_size) { fbb_.AddElement<int32_t>(SpaceToDepthOptions::VT_BLOCK_SIZE, block_size, 0); } explicit SpaceToDepthOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SpaceToDepthOptionsBuilder &operator=(const SpaceToDepthOptionsBuilder &); flatbuffers::Offset<SpaceToDepthOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SpaceToDepthOptions>(end); return o; } }; inline flatbuffers::Offset<SpaceToDepthOptions> CreateSpaceToDepthOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t block_size = 0) { SpaceToDepthOptionsBuilder builder_(_fbb); builder_.add_block_size(block_size); return builder_.Finish(); } flatbuffers::Offset<SpaceToDepthOptions> CreateSpaceToDepthOptions(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToDepthOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct DepthToSpaceOptionsT : public flatbuffers::NativeTable { typedef DepthToSpaceOptions TableType; int32_t block_size; DepthToSpaceOptionsT() : block_size(0) { } }; struct DepthToSpaceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef DepthToSpaceOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_BLOCK_SIZE = 4 }; int32_t block_size() const { return GetField<int32_t>(VT_BLOCK_SIZE, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_BLOCK_SIZE) && verifier.EndTable(); } DepthToSpaceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(DepthToSpaceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<DepthToSpaceOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DepthToSpaceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct DepthToSpaceOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_block_size(int32_t block_size) { fbb_.AddElement<int32_t>(DepthToSpaceOptions::VT_BLOCK_SIZE, block_size, 0); } explicit DepthToSpaceOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DepthToSpaceOptionsBuilder &operator=(const DepthToSpaceOptionsBuilder &); flatbuffers::Offset<DepthToSpaceOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<DepthToSpaceOptions>(end); return o; } }; inline flatbuffers::Offset<DepthToSpaceOptions> CreateDepthToSpaceOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t block_size = 0) { DepthToSpaceOptionsBuilder builder_(_fbb); builder_.add_block_size(block_size); return builder_.Finish(); } flatbuffers::Offset<DepthToSpaceOptions> CreateDepthToSpaceOptions(flatbuffers::FlatBufferBuilder &_fbb, const DepthToSpaceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SubOptionsT : public flatbuffers::NativeTable { typedef SubOptions TableType; tflite::ActivationFunctionType fused_activation_function; bool pot_scale_int16; SubOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE), pot_scale_int16(true) { } }; struct SubOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SubOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4, VT_POT_SCALE_INT16 = 6 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool pot_scale_int16() const { return GetField<uint8_t>(VT_POT_SCALE_INT16, 1) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && VerifyField<uint8_t>(verifier, VT_POT_SCALE_INT16) && verifier.EndTable(); } SubOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SubOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SubOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SubOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SubOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(SubOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } void add_pot_scale_int16(bool pot_scale_int16) { fbb_.AddElement<uint8_t>(SubOptions::VT_POT_SCALE_INT16, static_cast<uint8_t>(pot_scale_int16), 1); } explicit SubOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SubOptionsBuilder &operator=(const SubOptionsBuilder &); flatbuffers::Offset<SubOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SubOptions>(end); return o; } }; inline flatbuffers::Offset<SubOptions> CreateSubOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE, bool pot_scale_int16 = true) { SubOptionsBuilder builder_(_fbb); builder_.add_pot_scale_int16(pot_scale_int16); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<SubOptions> CreateSubOptions(flatbuffers::FlatBufferBuilder &_fbb, const SubOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct DivOptionsT : public flatbuffers::NativeTable { typedef DivOptions TableType; tflite::ActivationFunctionType fused_activation_function; DivOptionsT() : fused_activation_function(tflite::ActivationFunctionType_NONE) { } }; struct DivOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef DivOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_FUSED_ACTIVATION_FUNCTION = 4 }; tflite::ActivationFunctionType fused_activation_function() const { return static_cast<tflite::ActivationFunctionType>(GetField<int8_t>(VT_FUSED_ACTIVATION_FUNCTION, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_FUSED_ACTIVATION_FUNCTION) && verifier.EndTable(); } DivOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(DivOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<DivOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DivOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct DivOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_fused_activation_function(tflite::ActivationFunctionType fused_activation_function) { fbb_.AddElement<int8_t>(DivOptions::VT_FUSED_ACTIVATION_FUNCTION, static_cast<int8_t>(fused_activation_function), 0); } explicit DivOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DivOptionsBuilder &operator=(const DivOptionsBuilder &); flatbuffers::Offset<DivOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<DivOptions>(end); return o; } }; inline flatbuffers::Offset<DivOptions> CreateDivOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE) { DivOptionsBuilder builder_(_fbb); builder_.add_fused_activation_function(fused_activation_function); return builder_.Finish(); } flatbuffers::Offset<DivOptions> CreateDivOptions(flatbuffers::FlatBufferBuilder &_fbb, const DivOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct TopKV2OptionsT : public flatbuffers::NativeTable { typedef TopKV2Options TableType; TopKV2OptionsT() { } }; struct TopKV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TopKV2OptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } TopKV2OptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(TopKV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<TopKV2Options> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TopKV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct TopKV2OptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit TopKV2OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TopKV2OptionsBuilder &operator=(const TopKV2OptionsBuilder &); flatbuffers::Offset<TopKV2Options> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<TopKV2Options>(end); return o; } }; inline flatbuffers::Offset<TopKV2Options> CreateTopKV2Options( flatbuffers::FlatBufferBuilder &_fbb) { TopKV2OptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<TopKV2Options> CreateTopKV2Options(flatbuffers::FlatBufferBuilder &_fbb, const TopKV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct EmbeddingLookupSparseOptionsT : public flatbuffers::NativeTable { typedef EmbeddingLookupSparseOptions TableType; tflite::CombinerType combiner; EmbeddingLookupSparseOptionsT() : combiner(tflite::CombinerType_SUM) { } }; struct EmbeddingLookupSparseOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef EmbeddingLookupSparseOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_COMBINER = 4 }; tflite::CombinerType combiner() const { return static_cast<tflite::CombinerType>(GetField<int8_t>(VT_COMBINER, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_COMBINER) && verifier.EndTable(); } EmbeddingLookupSparseOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(EmbeddingLookupSparseOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<EmbeddingLookupSparseOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const EmbeddingLookupSparseOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct EmbeddingLookupSparseOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_combiner(tflite::CombinerType combiner) { fbb_.AddElement<int8_t>(EmbeddingLookupSparseOptions::VT_COMBINER, static_cast<int8_t>(combiner), 0); } explicit EmbeddingLookupSparseOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } EmbeddingLookupSparseOptionsBuilder &operator=(const EmbeddingLookupSparseOptionsBuilder &); flatbuffers::Offset<EmbeddingLookupSparseOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<EmbeddingLookupSparseOptions>(end); return o; } }; inline flatbuffers::Offset<EmbeddingLookupSparseOptions> CreateEmbeddingLookupSparseOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::CombinerType combiner = tflite::CombinerType_SUM) { EmbeddingLookupSparseOptionsBuilder builder_(_fbb); builder_.add_combiner(combiner); return builder_.Finish(); } flatbuffers::Offset<EmbeddingLookupSparseOptions> CreateEmbeddingLookupSparseOptions(flatbuffers::FlatBufferBuilder &_fbb, const EmbeddingLookupSparseOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct GatherOptionsT : public flatbuffers::NativeTable { typedef GatherOptions TableType; int32_t axis; int32_t batch_dims; GatherOptionsT() : axis(0), batch_dims(0) { } }; struct GatherOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef GatherOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_AXIS = 4, VT_BATCH_DIMS = 6 }; int32_t axis() const { return GetField<int32_t>(VT_AXIS, 0); } int32_t batch_dims() const { return GetField<int32_t>(VT_BATCH_DIMS, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_AXIS) && VerifyField<int32_t>(verifier, VT_BATCH_DIMS) && verifier.EndTable(); } GatherOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(GatherOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<GatherOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const GatherOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct GatherOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_axis(int32_t axis) { fbb_.AddElement<int32_t>(GatherOptions::VT_AXIS, axis, 0); } void add_batch_dims(int32_t batch_dims) { fbb_.AddElement<int32_t>(GatherOptions::VT_BATCH_DIMS, batch_dims, 0); } explicit GatherOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } GatherOptionsBuilder &operator=(const GatherOptionsBuilder &); flatbuffers::Offset<GatherOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<GatherOptions>(end); return o; } }; inline flatbuffers::Offset<GatherOptions> CreateGatherOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t axis = 0, int32_t batch_dims = 0) { GatherOptionsBuilder builder_(_fbb); builder_.add_batch_dims(batch_dims); builder_.add_axis(axis); return builder_.Finish(); } flatbuffers::Offset<GatherOptions> CreateGatherOptions(flatbuffers::FlatBufferBuilder &_fbb, const GatherOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct TransposeOptionsT : public flatbuffers::NativeTable { typedef TransposeOptions TableType; TransposeOptionsT() { } }; struct TransposeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TransposeOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } TransposeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(TransposeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<TransposeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TransposeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct TransposeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit TransposeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TransposeOptionsBuilder &operator=(const TransposeOptionsBuilder &); flatbuffers::Offset<TransposeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<TransposeOptions>(end); return o; } }; inline flatbuffers::Offset<TransposeOptions> CreateTransposeOptions( flatbuffers::FlatBufferBuilder &_fbb) { TransposeOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<TransposeOptions> CreateTransposeOptions(flatbuffers::FlatBufferBuilder &_fbb, const TransposeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ExpOptionsT : public flatbuffers::NativeTable { typedef ExpOptions TableType; ExpOptionsT() { } }; struct ExpOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ExpOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } ExpOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ExpOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ExpOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ExpOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ExpOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit ExpOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ExpOptionsBuilder &operator=(const ExpOptionsBuilder &); flatbuffers::Offset<ExpOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ExpOptions>(end); return o; } }; inline flatbuffers::Offset<ExpOptions> CreateExpOptions( flatbuffers::FlatBufferBuilder &_fbb) { ExpOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<ExpOptions> CreateExpOptions(flatbuffers::FlatBufferBuilder &_fbb, const ExpOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct CosOptionsT : public flatbuffers::NativeTable { typedef CosOptions TableType; CosOptionsT() { } }; struct CosOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef CosOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } CosOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(CosOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<CosOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const CosOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct CosOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit CosOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CosOptionsBuilder &operator=(const CosOptionsBuilder &); flatbuffers::Offset<CosOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<CosOptions>(end); return o; } }; inline flatbuffers::Offset<CosOptions> CreateCosOptions( flatbuffers::FlatBufferBuilder &_fbb) { CosOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<CosOptions> CreateCosOptions(flatbuffers::FlatBufferBuilder &_fbb, const CosOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ReducerOptionsT : public flatbuffers::NativeTable { typedef ReducerOptions TableType; bool keep_dims; ReducerOptionsT() : keep_dims(false) { } }; struct ReducerOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ReducerOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_KEEP_DIMS = 4 }; bool keep_dims() const { return GetField<uint8_t>(VT_KEEP_DIMS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_KEEP_DIMS) && verifier.EndTable(); } ReducerOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ReducerOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ReducerOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReducerOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ReducerOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_keep_dims(bool keep_dims) { fbb_.AddElement<uint8_t>(ReducerOptions::VT_KEEP_DIMS, static_cast<uint8_t>(keep_dims), 0); } explicit ReducerOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ReducerOptionsBuilder &operator=(const ReducerOptionsBuilder &); flatbuffers::Offset<ReducerOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ReducerOptions>(end); return o; } }; inline flatbuffers::Offset<ReducerOptions> CreateReducerOptions( flatbuffers::FlatBufferBuilder &_fbb, bool keep_dims = false) { ReducerOptionsBuilder builder_(_fbb); builder_.add_keep_dims(keep_dims); return builder_.Finish(); } flatbuffers::Offset<ReducerOptions> CreateReducerOptions(flatbuffers::FlatBufferBuilder &_fbb, const ReducerOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SqueezeOptionsT : public flatbuffers::NativeTable { typedef SqueezeOptions TableType; std::vector<int32_t> squeeze_dims; SqueezeOptionsT() { } }; struct SqueezeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SqueezeOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_SQUEEZE_DIMS = 4 }; const flatbuffers::Vector<int32_t> *squeeze_dims() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_SQUEEZE_DIMS); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_SQUEEZE_DIMS) && verifier.VerifyVector(squeeze_dims()) && verifier.EndTable(); } SqueezeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SqueezeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SqueezeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SqueezeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SqueezeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_squeeze_dims(flatbuffers::Offset<flatbuffers::Vector<int32_t>> squeeze_dims) { fbb_.AddOffset(SqueezeOptions::VT_SQUEEZE_DIMS, squeeze_dims); } explicit SqueezeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SqueezeOptionsBuilder &operator=(const SqueezeOptionsBuilder &); flatbuffers::Offset<SqueezeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SqueezeOptions>(end); return o; } }; inline flatbuffers::Offset<SqueezeOptions> CreateSqueezeOptions( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<int32_t>> squeeze_dims = 0) { SqueezeOptionsBuilder builder_(_fbb); builder_.add_squeeze_dims(squeeze_dims); return builder_.Finish(); } inline flatbuffers::Offset<SqueezeOptions> CreateSqueezeOptionsDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<int32_t> *squeeze_dims = nullptr) { auto squeeze_dims__ = squeeze_dims ? _fbb.CreateVector<int32_t>(*squeeze_dims) : 0; return tflite::CreateSqueezeOptions( _fbb, squeeze_dims__); } flatbuffers::Offset<SqueezeOptions> CreateSqueezeOptions(flatbuffers::FlatBufferBuilder &_fbb, const SqueezeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SplitOptionsT : public flatbuffers::NativeTable { typedef SplitOptions TableType; int32_t num_splits; SplitOptionsT() : num_splits(0) { } }; struct SplitOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SplitOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NUM_SPLITS = 4 }; int32_t num_splits() const { return GetField<int32_t>(VT_NUM_SPLITS, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_NUM_SPLITS) && verifier.EndTable(); } SplitOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SplitOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SplitOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SplitOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SplitOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_num_splits(int32_t num_splits) { fbb_.AddElement<int32_t>(SplitOptions::VT_NUM_SPLITS, num_splits, 0); } explicit SplitOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SplitOptionsBuilder &operator=(const SplitOptionsBuilder &); flatbuffers::Offset<SplitOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SplitOptions>(end); return o; } }; inline flatbuffers::Offset<SplitOptions> CreateSplitOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t num_splits = 0) { SplitOptionsBuilder builder_(_fbb); builder_.add_num_splits(num_splits); return builder_.Finish(); } flatbuffers::Offset<SplitOptions> CreateSplitOptions(flatbuffers::FlatBufferBuilder &_fbb, const SplitOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SplitVOptionsT : public flatbuffers::NativeTable { typedef SplitVOptions TableType; int32_t num_splits; SplitVOptionsT() : num_splits(0) { } }; struct SplitVOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SplitVOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NUM_SPLITS = 4 }; int32_t num_splits() const { return GetField<int32_t>(VT_NUM_SPLITS, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_NUM_SPLITS) && verifier.EndTable(); } SplitVOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SplitVOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SplitVOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SplitVOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SplitVOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_num_splits(int32_t num_splits) { fbb_.AddElement<int32_t>(SplitVOptions::VT_NUM_SPLITS, num_splits, 0); } explicit SplitVOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SplitVOptionsBuilder &operator=(const SplitVOptionsBuilder &); flatbuffers::Offset<SplitVOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SplitVOptions>(end); return o; } }; inline flatbuffers::Offset<SplitVOptions> CreateSplitVOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t num_splits = 0) { SplitVOptionsBuilder builder_(_fbb); builder_.add_num_splits(num_splits); return builder_.Finish(); } flatbuffers::Offset<SplitVOptions> CreateSplitVOptions(flatbuffers::FlatBufferBuilder &_fbb, const SplitVOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct StridedSliceOptionsT : public flatbuffers::NativeTable { typedef StridedSliceOptions TableType; int32_t begin_mask; int32_t end_mask; int32_t ellipsis_mask; int32_t new_axis_mask; int32_t shrink_axis_mask; StridedSliceOptionsT() : begin_mask(0), end_mask(0), ellipsis_mask(0), new_axis_mask(0), shrink_axis_mask(0) { } }; struct StridedSliceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef StridedSliceOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_BEGIN_MASK = 4, VT_END_MASK = 6, VT_ELLIPSIS_MASK = 8, VT_NEW_AXIS_MASK = 10, VT_SHRINK_AXIS_MASK = 12 }; int32_t begin_mask() const { return GetField<int32_t>(VT_BEGIN_MASK, 0); } int32_t end_mask() const { return GetField<int32_t>(VT_END_MASK, 0); } int32_t ellipsis_mask() const { return GetField<int32_t>(VT_ELLIPSIS_MASK, 0); } int32_t new_axis_mask() const { return GetField<int32_t>(VT_NEW_AXIS_MASK, 0); } int32_t shrink_axis_mask() const { return GetField<int32_t>(VT_SHRINK_AXIS_MASK, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_BEGIN_MASK) && VerifyField<int32_t>(verifier, VT_END_MASK) && VerifyField<int32_t>(verifier, VT_ELLIPSIS_MASK) && VerifyField<int32_t>(verifier, VT_NEW_AXIS_MASK) && VerifyField<int32_t>(verifier, VT_SHRINK_AXIS_MASK) && verifier.EndTable(); } StridedSliceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(StridedSliceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<StridedSliceOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const StridedSliceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct StridedSliceOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_begin_mask(int32_t begin_mask) { fbb_.AddElement<int32_t>(StridedSliceOptions::VT_BEGIN_MASK, begin_mask, 0); } void add_end_mask(int32_t end_mask) { fbb_.AddElement<int32_t>(StridedSliceOptions::VT_END_MASK, end_mask, 0); } void add_ellipsis_mask(int32_t ellipsis_mask) { fbb_.AddElement<int32_t>(StridedSliceOptions::VT_ELLIPSIS_MASK, ellipsis_mask, 0); } void add_new_axis_mask(int32_t new_axis_mask) { fbb_.AddElement<int32_t>(StridedSliceOptions::VT_NEW_AXIS_MASK, new_axis_mask, 0); } void add_shrink_axis_mask(int32_t shrink_axis_mask) { fbb_.AddElement<int32_t>(StridedSliceOptions::VT_SHRINK_AXIS_MASK, shrink_axis_mask, 0); } explicit StridedSliceOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } StridedSliceOptionsBuilder &operator=(const StridedSliceOptionsBuilder &); flatbuffers::Offset<StridedSliceOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<StridedSliceOptions>(end); return o; } }; inline flatbuffers::Offset<StridedSliceOptions> CreateStridedSliceOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t begin_mask = 0, int32_t end_mask = 0, int32_t ellipsis_mask = 0, int32_t new_axis_mask = 0, int32_t shrink_axis_mask = 0) { StridedSliceOptionsBuilder builder_(_fbb); builder_.add_shrink_axis_mask(shrink_axis_mask); builder_.add_new_axis_mask(new_axis_mask); builder_.add_ellipsis_mask(ellipsis_mask); builder_.add_end_mask(end_mask); builder_.add_begin_mask(begin_mask); return builder_.Finish(); } flatbuffers::Offset<StridedSliceOptions> CreateStridedSliceOptions(flatbuffers::FlatBufferBuilder &_fbb, const StridedSliceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LogSoftmaxOptionsT : public flatbuffers::NativeTable { typedef LogSoftmaxOptions TableType; LogSoftmaxOptionsT() { } }; struct LogSoftmaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LogSoftmaxOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } LogSoftmaxOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LogSoftmaxOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LogSoftmaxOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogSoftmaxOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LogSoftmaxOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit LogSoftmaxOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LogSoftmaxOptionsBuilder &operator=(const LogSoftmaxOptionsBuilder &); flatbuffers::Offset<LogSoftmaxOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LogSoftmaxOptions>(end); return o; } }; inline flatbuffers::Offset<LogSoftmaxOptions> CreateLogSoftmaxOptions( flatbuffers::FlatBufferBuilder &_fbb) { LogSoftmaxOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<LogSoftmaxOptions> CreateLogSoftmaxOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogSoftmaxOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct CastOptionsT : public flatbuffers::NativeTable { typedef CastOptions TableType; tflite::TensorType in_data_type; tflite::TensorType out_data_type; CastOptionsT() : in_data_type(tflite::TensorType_FLOAT32), out_data_type(tflite::TensorType_FLOAT32) { } }; struct CastOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef CastOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_IN_DATA_TYPE = 4, VT_OUT_DATA_TYPE = 6 }; tflite::TensorType in_data_type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_IN_DATA_TYPE, 0)); } tflite::TensorType out_data_type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_OUT_DATA_TYPE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_IN_DATA_TYPE) && VerifyField<int8_t>(verifier, VT_OUT_DATA_TYPE) && verifier.EndTable(); } CastOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(CastOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<CastOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const CastOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct CastOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_in_data_type(tflite::TensorType in_data_type) { fbb_.AddElement<int8_t>(CastOptions::VT_IN_DATA_TYPE, static_cast<int8_t>(in_data_type), 0); } void add_out_data_type(tflite::TensorType out_data_type) { fbb_.AddElement<int8_t>(CastOptions::VT_OUT_DATA_TYPE, static_cast<int8_t>(out_data_type), 0); } explicit CastOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CastOptionsBuilder &operator=(const CastOptionsBuilder &); flatbuffers::Offset<CastOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<CastOptions>(end); return o; } }; inline flatbuffers::Offset<CastOptions> CreateCastOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::TensorType in_data_type = tflite::TensorType_FLOAT32, tflite::TensorType out_data_type = tflite::TensorType_FLOAT32) { CastOptionsBuilder builder_(_fbb); builder_.add_out_data_type(out_data_type); builder_.add_in_data_type(in_data_type); return builder_.Finish(); } flatbuffers::Offset<CastOptions> CreateCastOptions(flatbuffers::FlatBufferBuilder &_fbb, const CastOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct DequantizeOptionsT : public flatbuffers::NativeTable { typedef DequantizeOptions TableType; DequantizeOptionsT() { } }; struct DequantizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef DequantizeOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } DequantizeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(DequantizeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<DequantizeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DequantizeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct DequantizeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit DequantizeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DequantizeOptionsBuilder &operator=(const DequantizeOptionsBuilder &); flatbuffers::Offset<DequantizeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<DequantizeOptions>(end); return o; } }; inline flatbuffers::Offset<DequantizeOptions> CreateDequantizeOptions( flatbuffers::FlatBufferBuilder &_fbb) { DequantizeOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<DequantizeOptions> CreateDequantizeOptions(flatbuffers::FlatBufferBuilder &_fbb, const DequantizeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct MaximumMinimumOptionsT : public flatbuffers::NativeTable { typedef MaximumMinimumOptions TableType; MaximumMinimumOptionsT() { } }; struct MaximumMinimumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MaximumMinimumOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } MaximumMinimumOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(MaximumMinimumOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<MaximumMinimumOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MaximumMinimumOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct MaximumMinimumOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit MaximumMinimumOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MaximumMinimumOptionsBuilder &operator=(const MaximumMinimumOptionsBuilder &); flatbuffers::Offset<MaximumMinimumOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<MaximumMinimumOptions>(end); return o; } }; inline flatbuffers::Offset<MaximumMinimumOptions> CreateMaximumMinimumOptions( flatbuffers::FlatBufferBuilder &_fbb) { MaximumMinimumOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<MaximumMinimumOptions> CreateMaximumMinimumOptions(flatbuffers::FlatBufferBuilder &_fbb, const MaximumMinimumOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct TileOptionsT : public flatbuffers::NativeTable { typedef TileOptions TableType; TileOptionsT() { } }; struct TileOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TileOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } TileOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(TileOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<TileOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TileOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct TileOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit TileOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TileOptionsBuilder &operator=(const TileOptionsBuilder &); flatbuffers::Offset<TileOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<TileOptions>(end); return o; } }; inline flatbuffers::Offset<TileOptions> CreateTileOptions( flatbuffers::FlatBufferBuilder &_fbb) { TileOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<TileOptions> CreateTileOptions(flatbuffers::FlatBufferBuilder &_fbb, const TileOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ArgMaxOptionsT : public flatbuffers::NativeTable { typedef ArgMaxOptions TableType; tflite::TensorType output_type; ArgMaxOptionsT() : output_type(tflite::TensorType_FLOAT32) { } }; struct ArgMaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ArgMaxOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_OUTPUT_TYPE = 4 }; tflite::TensorType output_type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_OUTPUT_TYPE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_OUTPUT_TYPE) && verifier.EndTable(); } ArgMaxOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ArgMaxOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ArgMaxOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ArgMaxOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ArgMaxOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_output_type(tflite::TensorType output_type) { fbb_.AddElement<int8_t>(ArgMaxOptions::VT_OUTPUT_TYPE, static_cast<int8_t>(output_type), 0); } explicit ArgMaxOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ArgMaxOptionsBuilder &operator=(const ArgMaxOptionsBuilder &); flatbuffers::Offset<ArgMaxOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ArgMaxOptions>(end); return o; } }; inline flatbuffers::Offset<ArgMaxOptions> CreateArgMaxOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::TensorType output_type = tflite::TensorType_FLOAT32) { ArgMaxOptionsBuilder builder_(_fbb); builder_.add_output_type(output_type); return builder_.Finish(); } flatbuffers::Offset<ArgMaxOptions> CreateArgMaxOptions(flatbuffers::FlatBufferBuilder &_fbb, const ArgMaxOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ArgMinOptionsT : public flatbuffers::NativeTable { typedef ArgMinOptions TableType; tflite::TensorType output_type; ArgMinOptionsT() : output_type(tflite::TensorType_FLOAT32) { } }; struct ArgMinOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ArgMinOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_OUTPUT_TYPE = 4 }; tflite::TensorType output_type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_OUTPUT_TYPE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_OUTPUT_TYPE) && verifier.EndTable(); } ArgMinOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ArgMinOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ArgMinOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ArgMinOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ArgMinOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_output_type(tflite::TensorType output_type) { fbb_.AddElement<int8_t>(ArgMinOptions::VT_OUTPUT_TYPE, static_cast<int8_t>(output_type), 0); } explicit ArgMinOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ArgMinOptionsBuilder &operator=(const ArgMinOptionsBuilder &); flatbuffers::Offset<ArgMinOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ArgMinOptions>(end); return o; } }; inline flatbuffers::Offset<ArgMinOptions> CreateArgMinOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::TensorType output_type = tflite::TensorType_FLOAT32) { ArgMinOptionsBuilder builder_(_fbb); builder_.add_output_type(output_type); return builder_.Finish(); } flatbuffers::Offset<ArgMinOptions> CreateArgMinOptions(flatbuffers::FlatBufferBuilder &_fbb, const ArgMinOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct GreaterOptionsT : public flatbuffers::NativeTable { typedef GreaterOptions TableType; GreaterOptionsT() { } }; struct GreaterOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef GreaterOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } GreaterOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(GreaterOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<GreaterOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const GreaterOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct GreaterOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit GreaterOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } GreaterOptionsBuilder &operator=(const GreaterOptionsBuilder &); flatbuffers::Offset<GreaterOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<GreaterOptions>(end); return o; } }; inline flatbuffers::Offset<GreaterOptions> CreateGreaterOptions( flatbuffers::FlatBufferBuilder &_fbb) { GreaterOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<GreaterOptions> CreateGreaterOptions(flatbuffers::FlatBufferBuilder &_fbb, const GreaterOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct GreaterEqualOptionsT : public flatbuffers::NativeTable { typedef GreaterEqualOptions TableType; GreaterEqualOptionsT() { } }; struct GreaterEqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef GreaterEqualOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } GreaterEqualOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(GreaterEqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<GreaterEqualOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const GreaterEqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct GreaterEqualOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit GreaterEqualOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } GreaterEqualOptionsBuilder &operator=(const GreaterEqualOptionsBuilder &); flatbuffers::Offset<GreaterEqualOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<GreaterEqualOptions>(end); return o; } }; inline flatbuffers::Offset<GreaterEqualOptions> CreateGreaterEqualOptions( flatbuffers::FlatBufferBuilder &_fbb) { GreaterEqualOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<GreaterEqualOptions> CreateGreaterEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const GreaterEqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LessOptionsT : public flatbuffers::NativeTable { typedef LessOptions TableType; LessOptionsT() { } }; struct LessOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LessOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } LessOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LessOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LessOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LessOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LessOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit LessOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LessOptionsBuilder &operator=(const LessOptionsBuilder &); flatbuffers::Offset<LessOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LessOptions>(end); return o; } }; inline flatbuffers::Offset<LessOptions> CreateLessOptions( flatbuffers::FlatBufferBuilder &_fbb) { LessOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<LessOptions> CreateLessOptions(flatbuffers::FlatBufferBuilder &_fbb, const LessOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LessEqualOptionsT : public flatbuffers::NativeTable { typedef LessEqualOptions TableType; LessEqualOptionsT() { } }; struct LessEqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LessEqualOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } LessEqualOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LessEqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LessEqualOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LessEqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LessEqualOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit LessEqualOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LessEqualOptionsBuilder &operator=(const LessEqualOptionsBuilder &); flatbuffers::Offset<LessEqualOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LessEqualOptions>(end); return o; } }; inline flatbuffers::Offset<LessEqualOptions> CreateLessEqualOptions( flatbuffers::FlatBufferBuilder &_fbb) { LessEqualOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<LessEqualOptions> CreateLessEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const LessEqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct NegOptionsT : public flatbuffers::NativeTable { typedef NegOptions TableType; NegOptionsT() { } }; struct NegOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef NegOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } NegOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(NegOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<NegOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const NegOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct NegOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit NegOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } NegOptionsBuilder &operator=(const NegOptionsBuilder &); flatbuffers::Offset<NegOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<NegOptions>(end); return o; } }; inline flatbuffers::Offset<NegOptions> CreateNegOptions( flatbuffers::FlatBufferBuilder &_fbb) { NegOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<NegOptions> CreateNegOptions(flatbuffers::FlatBufferBuilder &_fbb, const NegOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SelectOptionsT : public flatbuffers::NativeTable { typedef SelectOptions TableType; SelectOptionsT() { } }; struct SelectOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SelectOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SelectOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SelectOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SelectOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SelectOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SelectOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SelectOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SelectOptionsBuilder &operator=(const SelectOptionsBuilder &); flatbuffers::Offset<SelectOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SelectOptions>(end); return o; } }; inline flatbuffers::Offset<SelectOptions> CreateSelectOptions( flatbuffers::FlatBufferBuilder &_fbb) { SelectOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SelectOptions> CreateSelectOptions(flatbuffers::FlatBufferBuilder &_fbb, const SelectOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SliceOptionsT : public flatbuffers::NativeTable { typedef SliceOptions TableType; SliceOptionsT() { } }; struct SliceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SliceOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SliceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SliceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SliceOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SliceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SliceOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SliceOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SliceOptionsBuilder &operator=(const SliceOptionsBuilder &); flatbuffers::Offset<SliceOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SliceOptions>(end); return o; } }; inline flatbuffers::Offset<SliceOptions> CreateSliceOptions( flatbuffers::FlatBufferBuilder &_fbb) { SliceOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SliceOptions> CreateSliceOptions(flatbuffers::FlatBufferBuilder &_fbb, const SliceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct TransposeConvOptionsT : public flatbuffers::NativeTable { typedef TransposeConvOptions TableType; tflite::Padding padding; int32_t stride_w; int32_t stride_h; TransposeConvOptionsT() : padding(tflite::Padding_SAME), stride_w(0), stride_h(0) { } }; struct TransposeConvOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TransposeConvOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_STRIDE_W = 6, VT_STRIDE_H = 8 }; tflite::Padding padding() const { return static_cast<tflite::Padding>(GetField<int8_t>(VT_PADDING, 0)); } int32_t stride_w() const { return GetField<int32_t>(VT_STRIDE_W, 0); } int32_t stride_h() const { return GetField<int32_t>(VT_STRIDE_H, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_PADDING) && VerifyField<int32_t>(verifier, VT_STRIDE_W) && VerifyField<int32_t>(verifier, VT_STRIDE_H) && verifier.EndTable(); } TransposeConvOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(TransposeConvOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<TransposeConvOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TransposeConvOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct TransposeConvOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(tflite::Padding padding) { fbb_.AddElement<int8_t>(TransposeConvOptions::VT_PADDING, static_cast<int8_t>(padding), 0); } void add_stride_w(int32_t stride_w) { fbb_.AddElement<int32_t>(TransposeConvOptions::VT_STRIDE_W, stride_w, 0); } void add_stride_h(int32_t stride_h) { fbb_.AddElement<int32_t>(TransposeConvOptions::VT_STRIDE_H, stride_h, 0); } explicit TransposeConvOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TransposeConvOptionsBuilder &operator=(const TransposeConvOptionsBuilder &); flatbuffers::Offset<TransposeConvOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<TransposeConvOptions>(end); return o; } }; inline flatbuffers::Offset<TransposeConvOptions> CreateTransposeConvOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::Padding padding = tflite::Padding_SAME, int32_t stride_w = 0, int32_t stride_h = 0) { TransposeConvOptionsBuilder builder_(_fbb); builder_.add_stride_h(stride_h); builder_.add_stride_w(stride_w); builder_.add_padding(padding); return builder_.Finish(); } flatbuffers::Offset<TransposeConvOptions> CreateTransposeConvOptions(flatbuffers::FlatBufferBuilder &_fbb, const TransposeConvOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ExpandDimsOptionsT : public flatbuffers::NativeTable { typedef ExpandDimsOptions TableType; ExpandDimsOptionsT() { } }; struct ExpandDimsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ExpandDimsOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } ExpandDimsOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ExpandDimsOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ExpandDimsOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ExpandDimsOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ExpandDimsOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit ExpandDimsOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ExpandDimsOptionsBuilder &operator=(const ExpandDimsOptionsBuilder &); flatbuffers::Offset<ExpandDimsOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ExpandDimsOptions>(end); return o; } }; inline flatbuffers::Offset<ExpandDimsOptions> CreateExpandDimsOptions( flatbuffers::FlatBufferBuilder &_fbb) { ExpandDimsOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<ExpandDimsOptions> CreateExpandDimsOptions(flatbuffers::FlatBufferBuilder &_fbb, const ExpandDimsOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SparseToDenseOptionsT : public flatbuffers::NativeTable { typedef SparseToDenseOptions TableType; bool validate_indices; SparseToDenseOptionsT() : validate_indices(false) { } }; struct SparseToDenseOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SparseToDenseOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALIDATE_INDICES = 4 }; bool validate_indices() const { return GetField<uint8_t>(VT_VALIDATE_INDICES, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_VALIDATE_INDICES) && verifier.EndTable(); } SparseToDenseOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SparseToDenseOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SparseToDenseOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SparseToDenseOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SparseToDenseOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_validate_indices(bool validate_indices) { fbb_.AddElement<uint8_t>(SparseToDenseOptions::VT_VALIDATE_INDICES, static_cast<uint8_t>(validate_indices), 0); } explicit SparseToDenseOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SparseToDenseOptionsBuilder &operator=(const SparseToDenseOptionsBuilder &); flatbuffers::Offset<SparseToDenseOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SparseToDenseOptions>(end); return o; } }; inline flatbuffers::Offset<SparseToDenseOptions> CreateSparseToDenseOptions( flatbuffers::FlatBufferBuilder &_fbb, bool validate_indices = false) { SparseToDenseOptionsBuilder builder_(_fbb); builder_.add_validate_indices(validate_indices); return builder_.Finish(); } flatbuffers::Offset<SparseToDenseOptions> CreateSparseToDenseOptions(flatbuffers::FlatBufferBuilder &_fbb, const SparseToDenseOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct EqualOptionsT : public flatbuffers::NativeTable { typedef EqualOptions TableType; EqualOptionsT() { } }; struct EqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef EqualOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } EqualOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(EqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<EqualOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const EqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct EqualOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit EqualOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } EqualOptionsBuilder &operator=(const EqualOptionsBuilder &); flatbuffers::Offset<EqualOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<EqualOptions>(end); return o; } }; inline flatbuffers::Offset<EqualOptions> CreateEqualOptions( flatbuffers::FlatBufferBuilder &_fbb) { EqualOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<EqualOptions> CreateEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const EqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct NotEqualOptionsT : public flatbuffers::NativeTable { typedef NotEqualOptions TableType; NotEqualOptionsT() { } }; struct NotEqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef NotEqualOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } NotEqualOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(NotEqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<NotEqualOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const NotEqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct NotEqualOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit NotEqualOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } NotEqualOptionsBuilder &operator=(const NotEqualOptionsBuilder &); flatbuffers::Offset<NotEqualOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<NotEqualOptions>(end); return o; } }; inline flatbuffers::Offset<NotEqualOptions> CreateNotEqualOptions( flatbuffers::FlatBufferBuilder &_fbb) { NotEqualOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<NotEqualOptions> CreateNotEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const NotEqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ShapeOptionsT : public flatbuffers::NativeTable { typedef ShapeOptions TableType; tflite::TensorType out_type; ShapeOptionsT() : out_type(tflite::TensorType_FLOAT32) { } }; struct ShapeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ShapeOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_OUT_TYPE = 4 }; tflite::TensorType out_type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_OUT_TYPE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_OUT_TYPE) && verifier.EndTable(); } ShapeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ShapeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ShapeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ShapeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ShapeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_out_type(tflite::TensorType out_type) { fbb_.AddElement<int8_t>(ShapeOptions::VT_OUT_TYPE, static_cast<int8_t>(out_type), 0); } explicit ShapeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ShapeOptionsBuilder &operator=(const ShapeOptionsBuilder &); flatbuffers::Offset<ShapeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ShapeOptions>(end); return o; } }; inline flatbuffers::Offset<ShapeOptions> CreateShapeOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::TensorType out_type = tflite::TensorType_FLOAT32) { ShapeOptionsBuilder builder_(_fbb); builder_.add_out_type(out_type); return builder_.Finish(); } flatbuffers::Offset<ShapeOptions> CreateShapeOptions(flatbuffers::FlatBufferBuilder &_fbb, const ShapeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct RankOptionsT : public flatbuffers::NativeTable { typedef RankOptions TableType; RankOptionsT() { } }; struct RankOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef RankOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } RankOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(RankOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<RankOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const RankOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct RankOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit RankOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } RankOptionsBuilder &operator=(const RankOptionsBuilder &); flatbuffers::Offset<RankOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<RankOptions>(end); return o; } }; inline flatbuffers::Offset<RankOptions> CreateRankOptions( flatbuffers::FlatBufferBuilder &_fbb) { RankOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<RankOptions> CreateRankOptions(flatbuffers::FlatBufferBuilder &_fbb, const RankOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct PowOptionsT : public flatbuffers::NativeTable { typedef PowOptions TableType; PowOptionsT() { } }; struct PowOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef PowOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } PowOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(PowOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<PowOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const PowOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct PowOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit PowOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } PowOptionsBuilder &operator=(const PowOptionsBuilder &); flatbuffers::Offset<PowOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<PowOptions>(end); return o; } }; inline flatbuffers::Offset<PowOptions> CreatePowOptions( flatbuffers::FlatBufferBuilder &_fbb) { PowOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<PowOptions> CreatePowOptions(flatbuffers::FlatBufferBuilder &_fbb, const PowOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct FakeQuantOptionsT : public flatbuffers::NativeTable { typedef FakeQuantOptions TableType; float min; float max; int32_t num_bits; bool narrow_range; FakeQuantOptionsT() : min(0.0f), max(0.0f), num_bits(0), narrow_range(false) { } }; struct FakeQuantOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef FakeQuantOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_MIN = 4, VT_MAX = 6, VT_NUM_BITS = 8, VT_NARROW_RANGE = 10 }; float min() const { return GetField<float>(VT_MIN, 0.0f); } float max() const { return GetField<float>(VT_MAX, 0.0f); } int32_t num_bits() const { return GetField<int32_t>(VT_NUM_BITS, 0); } bool narrow_range() const { return GetField<uint8_t>(VT_NARROW_RANGE, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<float>(verifier, VT_MIN) && VerifyField<float>(verifier, VT_MAX) && VerifyField<int32_t>(verifier, VT_NUM_BITS) && VerifyField<uint8_t>(verifier, VT_NARROW_RANGE) && verifier.EndTable(); } FakeQuantOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(FakeQuantOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<FakeQuantOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const FakeQuantOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct FakeQuantOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_min(float min) { fbb_.AddElement<float>(FakeQuantOptions::VT_MIN, min, 0.0f); } void add_max(float max) { fbb_.AddElement<float>(FakeQuantOptions::VT_MAX, max, 0.0f); } void add_num_bits(int32_t num_bits) { fbb_.AddElement<int32_t>(FakeQuantOptions::VT_NUM_BITS, num_bits, 0); } void add_narrow_range(bool narrow_range) { fbb_.AddElement<uint8_t>(FakeQuantOptions::VT_NARROW_RANGE, static_cast<uint8_t>(narrow_range), 0); } explicit FakeQuantOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } FakeQuantOptionsBuilder &operator=(const FakeQuantOptionsBuilder &); flatbuffers::Offset<FakeQuantOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<FakeQuantOptions>(end); return o; } }; inline flatbuffers::Offset<FakeQuantOptions> CreateFakeQuantOptions( flatbuffers::FlatBufferBuilder &_fbb, float min = 0.0f, float max = 0.0f, int32_t num_bits = 0, bool narrow_range = false) { FakeQuantOptionsBuilder builder_(_fbb); builder_.add_num_bits(num_bits); builder_.add_max(max); builder_.add_min(min); builder_.add_narrow_range(narrow_range); return builder_.Finish(); } flatbuffers::Offset<FakeQuantOptions> CreateFakeQuantOptions(flatbuffers::FlatBufferBuilder &_fbb, const FakeQuantOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct PackOptionsT : public flatbuffers::NativeTable { typedef PackOptions TableType; int32_t values_count; int32_t axis; PackOptionsT() : values_count(0), axis(0) { } }; struct PackOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef PackOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VALUES_COUNT = 4, VT_AXIS = 6 }; int32_t values_count() const { return GetField<int32_t>(VT_VALUES_COUNT, 0); } int32_t axis() const { return GetField<int32_t>(VT_AXIS, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_VALUES_COUNT) && VerifyField<int32_t>(verifier, VT_AXIS) && verifier.EndTable(); } PackOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(PackOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<PackOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const PackOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct PackOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_values_count(int32_t values_count) { fbb_.AddElement<int32_t>(PackOptions::VT_VALUES_COUNT, values_count, 0); } void add_axis(int32_t axis) { fbb_.AddElement<int32_t>(PackOptions::VT_AXIS, axis, 0); } explicit PackOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } PackOptionsBuilder &operator=(const PackOptionsBuilder &); flatbuffers::Offset<PackOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<PackOptions>(end); return o; } }; inline flatbuffers::Offset<PackOptions> CreatePackOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t values_count = 0, int32_t axis = 0) { PackOptionsBuilder builder_(_fbb); builder_.add_axis(axis); builder_.add_values_count(values_count); return builder_.Finish(); } flatbuffers::Offset<PackOptions> CreatePackOptions(flatbuffers::FlatBufferBuilder &_fbb, const PackOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LogicalOrOptionsT : public flatbuffers::NativeTable { typedef LogicalOrOptions TableType; LogicalOrOptionsT() { } }; struct LogicalOrOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LogicalOrOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } LogicalOrOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LogicalOrOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LogicalOrOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogicalOrOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LogicalOrOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit LogicalOrOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LogicalOrOptionsBuilder &operator=(const LogicalOrOptionsBuilder &); flatbuffers::Offset<LogicalOrOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LogicalOrOptions>(end); return o; } }; inline flatbuffers::Offset<LogicalOrOptions> CreateLogicalOrOptions( flatbuffers::FlatBufferBuilder &_fbb) { LogicalOrOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<LogicalOrOptions> CreateLogicalOrOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogicalOrOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct OneHotOptionsT : public flatbuffers::NativeTable { typedef OneHotOptions TableType; int32_t axis; OneHotOptionsT() : axis(0) { } }; struct OneHotOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef OneHotOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_AXIS = 4 }; int32_t axis() const { return GetField<int32_t>(VT_AXIS, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_AXIS) && verifier.EndTable(); } OneHotOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(OneHotOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<OneHotOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const OneHotOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct OneHotOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_axis(int32_t axis) { fbb_.AddElement<int32_t>(OneHotOptions::VT_AXIS, axis, 0); } explicit OneHotOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } OneHotOptionsBuilder &operator=(const OneHotOptionsBuilder &); flatbuffers::Offset<OneHotOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<OneHotOptions>(end); return o; } }; inline flatbuffers::Offset<OneHotOptions> CreateOneHotOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t axis = 0) { OneHotOptionsBuilder builder_(_fbb); builder_.add_axis(axis); return builder_.Finish(); } flatbuffers::Offset<OneHotOptions> CreateOneHotOptions(flatbuffers::FlatBufferBuilder &_fbb, const OneHotOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct AbsOptionsT : public flatbuffers::NativeTable { typedef AbsOptions TableType; AbsOptionsT() { } }; struct AbsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef AbsOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } AbsOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(AbsOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<AbsOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const AbsOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct AbsOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit AbsOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } AbsOptionsBuilder &operator=(const AbsOptionsBuilder &); flatbuffers::Offset<AbsOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<AbsOptions>(end); return o; } }; inline flatbuffers::Offset<AbsOptions> CreateAbsOptions( flatbuffers::FlatBufferBuilder &_fbb) { AbsOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<AbsOptions> CreateAbsOptions(flatbuffers::FlatBufferBuilder &_fbb, const AbsOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct HardSwishOptionsT : public flatbuffers::NativeTable { typedef HardSwishOptions TableType; HardSwishOptionsT() { } }; struct HardSwishOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef HardSwishOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } HardSwishOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(HardSwishOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<HardSwishOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const HardSwishOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct HardSwishOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit HardSwishOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } HardSwishOptionsBuilder &operator=(const HardSwishOptionsBuilder &); flatbuffers::Offset<HardSwishOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<HardSwishOptions>(end); return o; } }; inline flatbuffers::Offset<HardSwishOptions> CreateHardSwishOptions( flatbuffers::FlatBufferBuilder &_fbb) { HardSwishOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<HardSwishOptions> CreateHardSwishOptions(flatbuffers::FlatBufferBuilder &_fbb, const HardSwishOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LogicalAndOptionsT : public flatbuffers::NativeTable { typedef LogicalAndOptions TableType; LogicalAndOptionsT() { } }; struct LogicalAndOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LogicalAndOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } LogicalAndOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LogicalAndOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LogicalAndOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogicalAndOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LogicalAndOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit LogicalAndOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LogicalAndOptionsBuilder &operator=(const LogicalAndOptionsBuilder &); flatbuffers::Offset<LogicalAndOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LogicalAndOptions>(end); return o; } }; inline flatbuffers::Offset<LogicalAndOptions> CreateLogicalAndOptions( flatbuffers::FlatBufferBuilder &_fbb) { LogicalAndOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<LogicalAndOptions> CreateLogicalAndOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogicalAndOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LogicalNotOptionsT : public flatbuffers::NativeTable { typedef LogicalNotOptions TableType; LogicalNotOptionsT() { } }; struct LogicalNotOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LogicalNotOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } LogicalNotOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LogicalNotOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LogicalNotOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogicalNotOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LogicalNotOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit LogicalNotOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LogicalNotOptionsBuilder &operator=(const LogicalNotOptionsBuilder &); flatbuffers::Offset<LogicalNotOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LogicalNotOptions>(end); return o; } }; inline flatbuffers::Offset<LogicalNotOptions> CreateLogicalNotOptions( flatbuffers::FlatBufferBuilder &_fbb) { LogicalNotOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<LogicalNotOptions> CreateLogicalNotOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogicalNotOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct UnpackOptionsT : public flatbuffers::NativeTable { typedef UnpackOptions TableType; int32_t num; int32_t axis; UnpackOptionsT() : num(0), axis(0) { } }; struct UnpackOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef UnpackOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NUM = 4, VT_AXIS = 6 }; int32_t num() const { return GetField<int32_t>(VT_NUM, 0); } int32_t axis() const { return GetField<int32_t>(VT_AXIS, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_NUM) && VerifyField<int32_t>(verifier, VT_AXIS) && verifier.EndTable(); } UnpackOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(UnpackOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<UnpackOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const UnpackOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct UnpackOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_num(int32_t num) { fbb_.AddElement<int32_t>(UnpackOptions::VT_NUM, num, 0); } void add_axis(int32_t axis) { fbb_.AddElement<int32_t>(UnpackOptions::VT_AXIS, axis, 0); } explicit UnpackOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } UnpackOptionsBuilder &operator=(const UnpackOptionsBuilder &); flatbuffers::Offset<UnpackOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<UnpackOptions>(end); return o; } }; inline flatbuffers::Offset<UnpackOptions> CreateUnpackOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t num = 0, int32_t axis = 0) { UnpackOptionsBuilder builder_(_fbb); builder_.add_axis(axis); builder_.add_num(num); return builder_.Finish(); } flatbuffers::Offset<UnpackOptions> CreateUnpackOptions(flatbuffers::FlatBufferBuilder &_fbb, const UnpackOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct FloorDivOptionsT : public flatbuffers::NativeTable { typedef FloorDivOptions TableType; FloorDivOptionsT() { } }; struct FloorDivOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef FloorDivOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } FloorDivOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(FloorDivOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<FloorDivOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const FloorDivOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct FloorDivOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit FloorDivOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } FloorDivOptionsBuilder &operator=(const FloorDivOptionsBuilder &); flatbuffers::Offset<FloorDivOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<FloorDivOptions>(end); return o; } }; inline flatbuffers::Offset<FloorDivOptions> CreateFloorDivOptions( flatbuffers::FlatBufferBuilder &_fbb) { FloorDivOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<FloorDivOptions> CreateFloorDivOptions(flatbuffers::FlatBufferBuilder &_fbb, const FloorDivOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SquareOptionsT : public flatbuffers::NativeTable { typedef SquareOptions TableType; SquareOptionsT() { } }; struct SquareOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SquareOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SquareOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SquareOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SquareOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SquareOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SquareOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SquareOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SquareOptionsBuilder &operator=(const SquareOptionsBuilder &); flatbuffers::Offset<SquareOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SquareOptions>(end); return o; } }; inline flatbuffers::Offset<SquareOptions> CreateSquareOptions( flatbuffers::FlatBufferBuilder &_fbb) { SquareOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SquareOptions> CreateSquareOptions(flatbuffers::FlatBufferBuilder &_fbb, const SquareOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ZerosLikeOptionsT : public flatbuffers::NativeTable { typedef ZerosLikeOptions TableType; ZerosLikeOptionsT() { } }; struct ZerosLikeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ZerosLikeOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } ZerosLikeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ZerosLikeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ZerosLikeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ZerosLikeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ZerosLikeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit ZerosLikeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ZerosLikeOptionsBuilder &operator=(const ZerosLikeOptionsBuilder &); flatbuffers::Offset<ZerosLikeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ZerosLikeOptions>(end); return o; } }; inline flatbuffers::Offset<ZerosLikeOptions> CreateZerosLikeOptions( flatbuffers::FlatBufferBuilder &_fbb) { ZerosLikeOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<ZerosLikeOptions> CreateZerosLikeOptions(flatbuffers::FlatBufferBuilder &_fbb, const ZerosLikeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct FillOptionsT : public flatbuffers::NativeTable { typedef FillOptions TableType; FillOptionsT() { } }; struct FillOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef FillOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } FillOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(FillOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<FillOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const FillOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct FillOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit FillOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } FillOptionsBuilder &operator=(const FillOptionsBuilder &); flatbuffers::Offset<FillOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<FillOptions>(end); return o; } }; inline flatbuffers::Offset<FillOptions> CreateFillOptions( flatbuffers::FlatBufferBuilder &_fbb) { FillOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<FillOptions> CreateFillOptions(flatbuffers::FlatBufferBuilder &_fbb, const FillOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct FloorModOptionsT : public flatbuffers::NativeTable { typedef FloorModOptions TableType; FloorModOptionsT() { } }; struct FloorModOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef FloorModOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } FloorModOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(FloorModOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<FloorModOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const FloorModOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct FloorModOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit FloorModOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } FloorModOptionsBuilder &operator=(const FloorModOptionsBuilder &); flatbuffers::Offset<FloorModOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<FloorModOptions>(end); return o; } }; inline flatbuffers::Offset<FloorModOptions> CreateFloorModOptions( flatbuffers::FlatBufferBuilder &_fbb) { FloorModOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<FloorModOptions> CreateFloorModOptions(flatbuffers::FlatBufferBuilder &_fbb, const FloorModOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct RangeOptionsT : public flatbuffers::NativeTable { typedef RangeOptions TableType; RangeOptionsT() { } }; struct RangeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef RangeOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } RangeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(RangeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<RangeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const RangeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct RangeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit RangeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } RangeOptionsBuilder &operator=(const RangeOptionsBuilder &); flatbuffers::Offset<RangeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<RangeOptions>(end); return o; } }; inline flatbuffers::Offset<RangeOptions> CreateRangeOptions( flatbuffers::FlatBufferBuilder &_fbb) { RangeOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<RangeOptions> CreateRangeOptions(flatbuffers::FlatBufferBuilder &_fbb, const RangeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct LeakyReluOptionsT : public flatbuffers::NativeTable { typedef LeakyReluOptions TableType; float alpha; LeakyReluOptionsT() : alpha(0.0f) { } }; struct LeakyReluOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LeakyReluOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_ALPHA = 4 }; float alpha() const { return GetField<float>(VT_ALPHA, 0.0f); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<float>(verifier, VT_ALPHA) && verifier.EndTable(); } LeakyReluOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(LeakyReluOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<LeakyReluOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const LeakyReluOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct LeakyReluOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_alpha(float alpha) { fbb_.AddElement<float>(LeakyReluOptions::VT_ALPHA, alpha, 0.0f); } explicit LeakyReluOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } LeakyReluOptionsBuilder &operator=(const LeakyReluOptionsBuilder &); flatbuffers::Offset<LeakyReluOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<LeakyReluOptions>(end); return o; } }; inline flatbuffers::Offset<LeakyReluOptions> CreateLeakyReluOptions( flatbuffers::FlatBufferBuilder &_fbb, float alpha = 0.0f) { LeakyReluOptionsBuilder builder_(_fbb); builder_.add_alpha(alpha); return builder_.Finish(); } flatbuffers::Offset<LeakyReluOptions> CreateLeakyReluOptions(flatbuffers::FlatBufferBuilder &_fbb, const LeakyReluOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SquaredDifferenceOptionsT : public flatbuffers::NativeTable { typedef SquaredDifferenceOptions TableType; SquaredDifferenceOptionsT() { } }; struct SquaredDifferenceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SquaredDifferenceOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SquaredDifferenceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SquaredDifferenceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SquaredDifferenceOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SquaredDifferenceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SquaredDifferenceOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SquaredDifferenceOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SquaredDifferenceOptionsBuilder &operator=(const SquaredDifferenceOptionsBuilder &); flatbuffers::Offset<SquaredDifferenceOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SquaredDifferenceOptions>(end); return o; } }; inline flatbuffers::Offset<SquaredDifferenceOptions> CreateSquaredDifferenceOptions( flatbuffers::FlatBufferBuilder &_fbb) { SquaredDifferenceOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SquaredDifferenceOptions> CreateSquaredDifferenceOptions(flatbuffers::FlatBufferBuilder &_fbb, const SquaredDifferenceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct MirrorPadOptionsT : public flatbuffers::NativeTable { typedef MirrorPadOptions TableType; tflite::MirrorPadMode mode; MirrorPadOptionsT() : mode(tflite::MirrorPadMode_REFLECT) { } }; struct MirrorPadOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MirrorPadOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_MODE = 4 }; tflite::MirrorPadMode mode() const { return static_cast<tflite::MirrorPadMode>(GetField<int8_t>(VT_MODE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_MODE) && verifier.EndTable(); } MirrorPadOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(MirrorPadOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<MirrorPadOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MirrorPadOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct MirrorPadOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_mode(tflite::MirrorPadMode mode) { fbb_.AddElement<int8_t>(MirrorPadOptions::VT_MODE, static_cast<int8_t>(mode), 0); } explicit MirrorPadOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MirrorPadOptionsBuilder &operator=(const MirrorPadOptionsBuilder &); flatbuffers::Offset<MirrorPadOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<MirrorPadOptions>(end); return o; } }; inline flatbuffers::Offset<MirrorPadOptions> CreateMirrorPadOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::MirrorPadMode mode = tflite::MirrorPadMode_REFLECT) { MirrorPadOptionsBuilder builder_(_fbb); builder_.add_mode(mode); return builder_.Finish(); } flatbuffers::Offset<MirrorPadOptions> CreateMirrorPadOptions(flatbuffers::FlatBufferBuilder &_fbb, const MirrorPadOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct UniqueOptionsT : public flatbuffers::NativeTable { typedef UniqueOptions TableType; tflite::TensorType idx_out_type; UniqueOptionsT() : idx_out_type(tflite::TensorType_INT32) { } }; struct UniqueOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef UniqueOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_IDX_OUT_TYPE = 4 }; tflite::TensorType idx_out_type() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_IDX_OUT_TYPE, 2)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_IDX_OUT_TYPE) && verifier.EndTable(); } UniqueOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(UniqueOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<UniqueOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const UniqueOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct UniqueOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_idx_out_type(tflite::TensorType idx_out_type) { fbb_.AddElement<int8_t>(UniqueOptions::VT_IDX_OUT_TYPE, static_cast<int8_t>(idx_out_type), 2); } explicit UniqueOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } UniqueOptionsBuilder &operator=(const UniqueOptionsBuilder &); flatbuffers::Offset<UniqueOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<UniqueOptions>(end); return o; } }; inline flatbuffers::Offset<UniqueOptions> CreateUniqueOptions( flatbuffers::FlatBufferBuilder &_fbb, tflite::TensorType idx_out_type = tflite::TensorType_INT32) { UniqueOptionsBuilder builder_(_fbb); builder_.add_idx_out_type(idx_out_type); return builder_.Finish(); } flatbuffers::Offset<UniqueOptions> CreateUniqueOptions(flatbuffers::FlatBufferBuilder &_fbb, const UniqueOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ReverseV2OptionsT : public flatbuffers::NativeTable { typedef ReverseV2Options TableType; ReverseV2OptionsT() { } }; struct ReverseV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ReverseV2OptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } ReverseV2OptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ReverseV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ReverseV2Options> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReverseV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ReverseV2OptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit ReverseV2OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ReverseV2OptionsBuilder &operator=(const ReverseV2OptionsBuilder &); flatbuffers::Offset<ReverseV2Options> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ReverseV2Options>(end); return o; } }; inline flatbuffers::Offset<ReverseV2Options> CreateReverseV2Options( flatbuffers::FlatBufferBuilder &_fbb) { ReverseV2OptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<ReverseV2Options> CreateReverseV2Options(flatbuffers::FlatBufferBuilder &_fbb, const ReverseV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct AddNOptionsT : public flatbuffers::NativeTable { typedef AddNOptions TableType; AddNOptionsT() { } }; struct AddNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef AddNOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } AddNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(AddNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<AddNOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const AddNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct AddNOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit AddNOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } AddNOptionsBuilder &operator=(const AddNOptionsBuilder &); flatbuffers::Offset<AddNOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<AddNOptions>(end); return o; } }; inline flatbuffers::Offset<AddNOptions> CreateAddNOptions( flatbuffers::FlatBufferBuilder &_fbb) { AddNOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<AddNOptions> CreateAddNOptions(flatbuffers::FlatBufferBuilder &_fbb, const AddNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct GatherNdOptionsT : public flatbuffers::NativeTable { typedef GatherNdOptions TableType; GatherNdOptionsT() { } }; struct GatherNdOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef GatherNdOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } GatherNdOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(GatherNdOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<GatherNdOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const GatherNdOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct GatherNdOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit GatherNdOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } GatherNdOptionsBuilder &operator=(const GatherNdOptionsBuilder &); flatbuffers::Offset<GatherNdOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<GatherNdOptions>(end); return o; } }; inline flatbuffers::Offset<GatherNdOptions> CreateGatherNdOptions( flatbuffers::FlatBufferBuilder &_fbb) { GatherNdOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<GatherNdOptions> CreateGatherNdOptions(flatbuffers::FlatBufferBuilder &_fbb, const GatherNdOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct WhereOptionsT : public flatbuffers::NativeTable { typedef WhereOptions TableType; WhereOptionsT() { } }; struct WhereOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef WhereOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } WhereOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(WhereOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<WhereOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const WhereOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct WhereOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit WhereOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } WhereOptionsBuilder &operator=(const WhereOptionsBuilder &); flatbuffers::Offset<WhereOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<WhereOptions>(end); return o; } }; inline flatbuffers::Offset<WhereOptions> CreateWhereOptions( flatbuffers::FlatBufferBuilder &_fbb) { WhereOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<WhereOptions> CreateWhereOptions(flatbuffers::FlatBufferBuilder &_fbb, const WhereOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ReverseSequenceOptionsT : public flatbuffers::NativeTable { typedef ReverseSequenceOptions TableType; int32_t seq_dim; int32_t batch_dim; ReverseSequenceOptionsT() : seq_dim(0), batch_dim(0) { } }; struct ReverseSequenceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ReverseSequenceOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_SEQ_DIM = 4, VT_BATCH_DIM = 6 }; int32_t seq_dim() const { return GetField<int32_t>(VT_SEQ_DIM, 0); } int32_t batch_dim() const { return GetField<int32_t>(VT_BATCH_DIM, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_SEQ_DIM) && VerifyField<int32_t>(verifier, VT_BATCH_DIM) && verifier.EndTable(); } ReverseSequenceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ReverseSequenceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ReverseSequenceOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReverseSequenceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ReverseSequenceOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_seq_dim(int32_t seq_dim) { fbb_.AddElement<int32_t>(ReverseSequenceOptions::VT_SEQ_DIM, seq_dim, 0); } void add_batch_dim(int32_t batch_dim) { fbb_.AddElement<int32_t>(ReverseSequenceOptions::VT_BATCH_DIM, batch_dim, 0); } explicit ReverseSequenceOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ReverseSequenceOptionsBuilder &operator=(const ReverseSequenceOptionsBuilder &); flatbuffers::Offset<ReverseSequenceOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ReverseSequenceOptions>(end); return o; } }; inline flatbuffers::Offset<ReverseSequenceOptions> CreateReverseSequenceOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t seq_dim = 0, int32_t batch_dim = 0) { ReverseSequenceOptionsBuilder builder_(_fbb); builder_.add_batch_dim(batch_dim); builder_.add_seq_dim(seq_dim); return builder_.Finish(); } flatbuffers::Offset<ReverseSequenceOptions> CreateReverseSequenceOptions(flatbuffers::FlatBufferBuilder &_fbb, const ReverseSequenceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct MatrixDiagOptionsT : public flatbuffers::NativeTable { typedef MatrixDiagOptions TableType; MatrixDiagOptionsT() { } }; struct MatrixDiagOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MatrixDiagOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } MatrixDiagOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(MatrixDiagOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<MatrixDiagOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MatrixDiagOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct MatrixDiagOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit MatrixDiagOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MatrixDiagOptionsBuilder &operator=(const MatrixDiagOptionsBuilder &); flatbuffers::Offset<MatrixDiagOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<MatrixDiagOptions>(end); return o; } }; inline flatbuffers::Offset<MatrixDiagOptions> CreateMatrixDiagOptions( flatbuffers::FlatBufferBuilder &_fbb) { MatrixDiagOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<MatrixDiagOptions> CreateMatrixDiagOptions(flatbuffers::FlatBufferBuilder &_fbb, const MatrixDiagOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct QuantizeOptionsT : public flatbuffers::NativeTable { typedef QuantizeOptions TableType; QuantizeOptionsT() { } }; struct QuantizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef QuantizeOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } QuantizeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(QuantizeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<QuantizeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const QuantizeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct QuantizeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit QuantizeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } QuantizeOptionsBuilder &operator=(const QuantizeOptionsBuilder &); flatbuffers::Offset<QuantizeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<QuantizeOptions>(end); return o; } }; inline flatbuffers::Offset<QuantizeOptions> CreateQuantizeOptions( flatbuffers::FlatBufferBuilder &_fbb) { QuantizeOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<QuantizeOptions> CreateQuantizeOptions(flatbuffers::FlatBufferBuilder &_fbb, const QuantizeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct MatrixSetDiagOptionsT : public flatbuffers::NativeTable { typedef MatrixSetDiagOptions TableType; MatrixSetDiagOptionsT() { } }; struct MatrixSetDiagOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MatrixSetDiagOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } MatrixSetDiagOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(MatrixSetDiagOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<MatrixSetDiagOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MatrixSetDiagOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct MatrixSetDiagOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit MatrixSetDiagOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MatrixSetDiagOptionsBuilder &operator=(const MatrixSetDiagOptionsBuilder &); flatbuffers::Offset<MatrixSetDiagOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<MatrixSetDiagOptions>(end); return o; } }; inline flatbuffers::Offset<MatrixSetDiagOptions> CreateMatrixSetDiagOptions( flatbuffers::FlatBufferBuilder &_fbb) { MatrixSetDiagOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<MatrixSetDiagOptions> CreateMatrixSetDiagOptions(flatbuffers::FlatBufferBuilder &_fbb, const MatrixSetDiagOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct IfOptionsT : public flatbuffers::NativeTable { typedef IfOptions TableType; int32_t then_subgraph_index; int32_t else_subgraph_index; IfOptionsT() : then_subgraph_index(0), else_subgraph_index(0) { } }; struct IfOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef IfOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_THEN_SUBGRAPH_INDEX = 4, VT_ELSE_SUBGRAPH_INDEX = 6 }; int32_t then_subgraph_index() const { return GetField<int32_t>(VT_THEN_SUBGRAPH_INDEX, 0); } int32_t else_subgraph_index() const { return GetField<int32_t>(VT_ELSE_SUBGRAPH_INDEX, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_THEN_SUBGRAPH_INDEX) && VerifyField<int32_t>(verifier, VT_ELSE_SUBGRAPH_INDEX) && verifier.EndTable(); } IfOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(IfOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<IfOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const IfOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct IfOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_then_subgraph_index(int32_t then_subgraph_index) { fbb_.AddElement<int32_t>(IfOptions::VT_THEN_SUBGRAPH_INDEX, then_subgraph_index, 0); } void add_else_subgraph_index(int32_t else_subgraph_index) { fbb_.AddElement<int32_t>(IfOptions::VT_ELSE_SUBGRAPH_INDEX, else_subgraph_index, 0); } explicit IfOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } IfOptionsBuilder &operator=(const IfOptionsBuilder &); flatbuffers::Offset<IfOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<IfOptions>(end); return o; } }; inline flatbuffers::Offset<IfOptions> CreateIfOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t then_subgraph_index = 0, int32_t else_subgraph_index = 0) { IfOptionsBuilder builder_(_fbb); builder_.add_else_subgraph_index(else_subgraph_index); builder_.add_then_subgraph_index(then_subgraph_index); return builder_.Finish(); } flatbuffers::Offset<IfOptions> CreateIfOptions(flatbuffers::FlatBufferBuilder &_fbb, const IfOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct CallOnceOptionsT : public flatbuffers::NativeTable { typedef CallOnceOptions TableType; int32_t init_subgraph_index; CallOnceOptionsT() : init_subgraph_index(0) { } }; struct CallOnceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef CallOnceOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_INIT_SUBGRAPH_INDEX = 4 }; int32_t init_subgraph_index() const { return GetField<int32_t>(VT_INIT_SUBGRAPH_INDEX, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_INIT_SUBGRAPH_INDEX) && verifier.EndTable(); } CallOnceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(CallOnceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<CallOnceOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const CallOnceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct CallOnceOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_init_subgraph_index(int32_t init_subgraph_index) { fbb_.AddElement<int32_t>(CallOnceOptions::VT_INIT_SUBGRAPH_INDEX, init_subgraph_index, 0); } explicit CallOnceOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CallOnceOptionsBuilder &operator=(const CallOnceOptionsBuilder &); flatbuffers::Offset<CallOnceOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<CallOnceOptions>(end); return o; } }; inline flatbuffers::Offset<CallOnceOptions> CreateCallOnceOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t init_subgraph_index = 0) { CallOnceOptionsBuilder builder_(_fbb); builder_.add_init_subgraph_index(init_subgraph_index); return builder_.Finish(); } flatbuffers::Offset<CallOnceOptions> CreateCallOnceOptions(flatbuffers::FlatBufferBuilder &_fbb, const CallOnceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct WhileOptionsT : public flatbuffers::NativeTable { typedef WhileOptions TableType; int32_t cond_subgraph_index; int32_t body_subgraph_index; WhileOptionsT() : cond_subgraph_index(0), body_subgraph_index(0) { } }; struct WhileOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef WhileOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_COND_SUBGRAPH_INDEX = 4, VT_BODY_SUBGRAPH_INDEX = 6 }; int32_t cond_subgraph_index() const { return GetField<int32_t>(VT_COND_SUBGRAPH_INDEX, 0); } int32_t body_subgraph_index() const { return GetField<int32_t>(VT_BODY_SUBGRAPH_INDEX, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_COND_SUBGRAPH_INDEX) && VerifyField<int32_t>(verifier, VT_BODY_SUBGRAPH_INDEX) && verifier.EndTable(); } WhileOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(WhileOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<WhileOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const WhileOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct WhileOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_cond_subgraph_index(int32_t cond_subgraph_index) { fbb_.AddElement<int32_t>(WhileOptions::VT_COND_SUBGRAPH_INDEX, cond_subgraph_index, 0); } void add_body_subgraph_index(int32_t body_subgraph_index) { fbb_.AddElement<int32_t>(WhileOptions::VT_BODY_SUBGRAPH_INDEX, body_subgraph_index, 0); } explicit WhileOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } WhileOptionsBuilder &operator=(const WhileOptionsBuilder &); flatbuffers::Offset<WhileOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<WhileOptions>(end); return o; } }; inline flatbuffers::Offset<WhileOptions> CreateWhileOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t cond_subgraph_index = 0, int32_t body_subgraph_index = 0) { WhileOptionsBuilder builder_(_fbb); builder_.add_body_subgraph_index(body_subgraph_index); builder_.add_cond_subgraph_index(cond_subgraph_index); return builder_.Finish(); } flatbuffers::Offset<WhileOptions> CreateWhileOptions(flatbuffers::FlatBufferBuilder &_fbb, const WhileOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct NonMaxSuppressionV4OptionsT : public flatbuffers::NativeTable { typedef NonMaxSuppressionV4Options TableType; NonMaxSuppressionV4OptionsT() { } }; struct NonMaxSuppressionV4Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef NonMaxSuppressionV4OptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } NonMaxSuppressionV4OptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(NonMaxSuppressionV4OptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<NonMaxSuppressionV4Options> Pack(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV4OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct NonMaxSuppressionV4OptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit NonMaxSuppressionV4OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } NonMaxSuppressionV4OptionsBuilder &operator=(const NonMaxSuppressionV4OptionsBuilder &); flatbuffers::Offset<NonMaxSuppressionV4Options> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<NonMaxSuppressionV4Options>(end); return o; } }; inline flatbuffers::Offset<NonMaxSuppressionV4Options> CreateNonMaxSuppressionV4Options( flatbuffers::FlatBufferBuilder &_fbb) { NonMaxSuppressionV4OptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<NonMaxSuppressionV4Options> CreateNonMaxSuppressionV4Options(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV4OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct NonMaxSuppressionV5OptionsT : public flatbuffers::NativeTable { typedef NonMaxSuppressionV5Options TableType; NonMaxSuppressionV5OptionsT() { } }; struct NonMaxSuppressionV5Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef NonMaxSuppressionV5OptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } NonMaxSuppressionV5OptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(NonMaxSuppressionV5OptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<NonMaxSuppressionV5Options> Pack(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV5OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct NonMaxSuppressionV5OptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit NonMaxSuppressionV5OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } NonMaxSuppressionV5OptionsBuilder &operator=(const NonMaxSuppressionV5OptionsBuilder &); flatbuffers::Offset<NonMaxSuppressionV5Options> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<NonMaxSuppressionV5Options>(end); return o; } }; inline flatbuffers::Offset<NonMaxSuppressionV5Options> CreateNonMaxSuppressionV5Options( flatbuffers::FlatBufferBuilder &_fbb) { NonMaxSuppressionV5OptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<NonMaxSuppressionV5Options> CreateNonMaxSuppressionV5Options(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV5OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ScatterNdOptionsT : public flatbuffers::NativeTable { typedef ScatterNdOptions TableType; ScatterNdOptionsT() { } }; struct ScatterNdOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ScatterNdOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } ScatterNdOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ScatterNdOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<ScatterNdOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ScatterNdOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ScatterNdOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit ScatterNdOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ScatterNdOptionsBuilder &operator=(const ScatterNdOptionsBuilder &); flatbuffers::Offset<ScatterNdOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<ScatterNdOptions>(end); return o; } }; inline flatbuffers::Offset<ScatterNdOptions> CreateScatterNdOptions( flatbuffers::FlatBufferBuilder &_fbb) { ScatterNdOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<ScatterNdOptions> CreateScatterNdOptions(flatbuffers::FlatBufferBuilder &_fbb, const ScatterNdOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SelectV2OptionsT : public flatbuffers::NativeTable { typedef SelectV2Options TableType; SelectV2OptionsT() { } }; struct SelectV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SelectV2OptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SelectV2OptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SelectV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SelectV2Options> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SelectV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SelectV2OptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SelectV2OptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SelectV2OptionsBuilder &operator=(const SelectV2OptionsBuilder &); flatbuffers::Offset<SelectV2Options> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SelectV2Options>(end); return o; } }; inline flatbuffers::Offset<SelectV2Options> CreateSelectV2Options( flatbuffers::FlatBufferBuilder &_fbb) { SelectV2OptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SelectV2Options> CreateSelectV2Options(flatbuffers::FlatBufferBuilder &_fbb, const SelectV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct DensifyOptionsT : public flatbuffers::NativeTable { typedef DensifyOptions TableType; DensifyOptionsT() { } }; struct DensifyOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef DensifyOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } DensifyOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(DensifyOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<DensifyOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const DensifyOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct DensifyOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit DensifyOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } DensifyOptionsBuilder &operator=(const DensifyOptionsBuilder &); flatbuffers::Offset<DensifyOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<DensifyOptions>(end); return o; } }; inline flatbuffers::Offset<DensifyOptions> CreateDensifyOptions( flatbuffers::FlatBufferBuilder &_fbb) { DensifyOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<DensifyOptions> CreateDensifyOptions(flatbuffers::FlatBufferBuilder &_fbb, const DensifyOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SegmentSumOptionsT : public flatbuffers::NativeTable { typedef SegmentSumOptions TableType; SegmentSumOptionsT() { } }; struct SegmentSumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SegmentSumOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } SegmentSumOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SegmentSumOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SegmentSumOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SegmentSumOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SegmentSumOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit SegmentSumOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SegmentSumOptionsBuilder &operator=(const SegmentSumOptionsBuilder &); flatbuffers::Offset<SegmentSumOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SegmentSumOptions>(end); return o; } }; inline flatbuffers::Offset<SegmentSumOptions> CreateSegmentSumOptions( flatbuffers::FlatBufferBuilder &_fbb) { SegmentSumOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<SegmentSumOptions> CreateSegmentSumOptions(flatbuffers::FlatBufferBuilder &_fbb, const SegmentSumOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct BatchMatMulOptionsT : public flatbuffers::NativeTable { typedef BatchMatMulOptions TableType; bool adj_x; bool adj_y; bool asymmetric_quantize_inputs; BatchMatMulOptionsT() : adj_x(false), adj_y(false), asymmetric_quantize_inputs(false) { } }; struct BatchMatMulOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BatchMatMulOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_ADJ_X = 4, VT_ADJ_Y = 6, VT_ASYMMETRIC_QUANTIZE_INPUTS = 8 }; bool adj_x() const { return GetField<uint8_t>(VT_ADJ_X, 0) != 0; } bool adj_y() const { return GetField<uint8_t>(VT_ADJ_Y, 0) != 0; } bool asymmetric_quantize_inputs() const { return GetField<uint8_t>(VT_ASYMMETRIC_QUANTIZE_INPUTS, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_ADJ_X) && VerifyField<uint8_t>(verifier, VT_ADJ_Y) && VerifyField<uint8_t>(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && verifier.EndTable(); } BatchMatMulOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(BatchMatMulOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<BatchMatMulOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const BatchMatMulOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct BatchMatMulOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_adj_x(bool adj_x) { fbb_.AddElement<uint8_t>(BatchMatMulOptions::VT_ADJ_X, static_cast<uint8_t>(adj_x), 0); } void add_adj_y(bool adj_y) { fbb_.AddElement<uint8_t>(BatchMatMulOptions::VT_ADJ_Y, static_cast<uint8_t>(adj_y), 0); } void add_asymmetric_quantize_inputs(bool asymmetric_quantize_inputs) { fbb_.AddElement<uint8_t>(BatchMatMulOptions::VT_ASYMMETRIC_QUANTIZE_INPUTS, static_cast<uint8_t>(asymmetric_quantize_inputs), 0); } explicit BatchMatMulOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } BatchMatMulOptionsBuilder &operator=(const BatchMatMulOptionsBuilder &); flatbuffers::Offset<BatchMatMulOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<BatchMatMulOptions>(end); return o; } }; inline flatbuffers::Offset<BatchMatMulOptions> CreateBatchMatMulOptions( flatbuffers::FlatBufferBuilder &_fbb, bool adj_x = false, bool adj_y = false, bool asymmetric_quantize_inputs = false) { BatchMatMulOptionsBuilder builder_(_fbb); builder_.add_asymmetric_quantize_inputs(asymmetric_quantize_inputs); builder_.add_adj_y(adj_y); builder_.add_adj_x(adj_x); return builder_.Finish(); } flatbuffers::Offset<BatchMatMulOptions> CreateBatchMatMulOptions(flatbuffers::FlatBufferBuilder &_fbb, const BatchMatMulOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct CumsumOptionsT : public flatbuffers::NativeTable { typedef CumsumOptions TableType; bool exclusive; bool reverse; CumsumOptionsT() : exclusive(false), reverse(false) { } }; struct CumsumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef CumsumOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_EXCLUSIVE = 4, VT_REVERSE = 6 }; bool exclusive() const { return GetField<uint8_t>(VT_EXCLUSIVE, 0) != 0; } bool reverse() const { return GetField<uint8_t>(VT_REVERSE, 0) != 0; } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint8_t>(verifier, VT_EXCLUSIVE) && VerifyField<uint8_t>(verifier, VT_REVERSE) && verifier.EndTable(); } CumsumOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(CumsumOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<CumsumOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const CumsumOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct CumsumOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_exclusive(bool exclusive) { fbb_.AddElement<uint8_t>(CumsumOptions::VT_EXCLUSIVE, static_cast<uint8_t>(exclusive), 0); } void add_reverse(bool reverse) { fbb_.AddElement<uint8_t>(CumsumOptions::VT_REVERSE, static_cast<uint8_t>(reverse), 0); } explicit CumsumOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CumsumOptionsBuilder &operator=(const CumsumOptionsBuilder &); flatbuffers::Offset<CumsumOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<CumsumOptions>(end); return o; } }; inline flatbuffers::Offset<CumsumOptions> CreateCumsumOptions( flatbuffers::FlatBufferBuilder &_fbb, bool exclusive = false, bool reverse = false) { CumsumOptionsBuilder builder_(_fbb); builder_.add_reverse(reverse); builder_.add_exclusive(exclusive); return builder_.Finish(); } flatbuffers::Offset<CumsumOptions> CreateCumsumOptions(flatbuffers::FlatBufferBuilder &_fbb, const CumsumOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct BroadcastToOptionsT : public flatbuffers::NativeTable { typedef BroadcastToOptions TableType; BroadcastToOptionsT() { } }; struct BroadcastToOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BroadcastToOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } BroadcastToOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(BroadcastToOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<BroadcastToOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const BroadcastToOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct BroadcastToOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit BroadcastToOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } BroadcastToOptionsBuilder &operator=(const BroadcastToOptionsBuilder &); flatbuffers::Offset<BroadcastToOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<BroadcastToOptions>(end); return o; } }; inline flatbuffers::Offset<BroadcastToOptions> CreateBroadcastToOptions( flatbuffers::FlatBufferBuilder &_fbb) { BroadcastToOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<BroadcastToOptions> CreateBroadcastToOptions(flatbuffers::FlatBufferBuilder &_fbb, const BroadcastToOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Rfft2dOptionsT : public flatbuffers::NativeTable { typedef Rfft2dOptions TableType; Rfft2dOptionsT() { } }; struct Rfft2dOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Rfft2dOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } Rfft2dOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(Rfft2dOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Rfft2dOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const Rfft2dOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct Rfft2dOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit Rfft2dOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } Rfft2dOptionsBuilder &operator=(const Rfft2dOptionsBuilder &); flatbuffers::Offset<Rfft2dOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Rfft2dOptions>(end); return o; } }; inline flatbuffers::Offset<Rfft2dOptions> CreateRfft2dOptions( flatbuffers::FlatBufferBuilder &_fbb) { Rfft2dOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<Rfft2dOptions> CreateRfft2dOptions(flatbuffers::FlatBufferBuilder &_fbb, const Rfft2dOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct HashtableOptionsT : public flatbuffers::NativeTable { typedef HashtableOptions TableType; int32_t table_id; tflite::TensorType key_dtype; tflite::TensorType value_dtype; HashtableOptionsT() : table_id(0), key_dtype(tflite::TensorType_FLOAT32), value_dtype(tflite::TensorType_FLOAT32) { } }; struct HashtableOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef HashtableOptionsT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TABLE_ID = 4, VT_KEY_DTYPE = 6, VT_VALUE_DTYPE = 8 }; int32_t table_id() const { return GetField<int32_t>(VT_TABLE_ID, 0); } tflite::TensorType key_dtype() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_KEY_DTYPE, 0)); } tflite::TensorType value_dtype() const { return static_cast<tflite::TensorType>(GetField<int8_t>(VT_VALUE_DTYPE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int32_t>(verifier, VT_TABLE_ID) && VerifyField<int8_t>(verifier, VT_KEY_DTYPE) && VerifyField<int8_t>(verifier, VT_VALUE_DTYPE) && verifier.EndTable(); } HashtableOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(HashtableOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<HashtableOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct HashtableOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_table_id(int32_t table_id) { fbb_.AddElement<int32_t>(HashtableOptions::VT_TABLE_ID, table_id, 0); } void add_key_dtype(tflite::TensorType key_dtype) { fbb_.AddElement<int8_t>(HashtableOptions::VT_KEY_DTYPE, static_cast<int8_t>(key_dtype), 0); } void add_value_dtype(tflite::TensorType value_dtype) { fbb_.AddElement<int8_t>(HashtableOptions::VT_VALUE_DTYPE, static_cast<int8_t>(value_dtype), 0); } explicit HashtableOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } HashtableOptionsBuilder &operator=(const HashtableOptionsBuilder &); flatbuffers::Offset<HashtableOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<HashtableOptions>(end); return o; } }; inline flatbuffers::Offset<HashtableOptions> CreateHashtableOptions( flatbuffers::FlatBufferBuilder &_fbb, int32_t table_id = 0, tflite::TensorType key_dtype = tflite::TensorType_FLOAT32, tflite::TensorType value_dtype = tflite::TensorType_FLOAT32) { HashtableOptionsBuilder builder_(_fbb); builder_.add_table_id(table_id); builder_.add_value_dtype(value_dtype); builder_.add_key_dtype(key_dtype); return builder_.Finish(); } flatbuffers::Offset<HashtableOptions> CreateHashtableOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct HashtableFindOptionsT : public flatbuffers::NativeTable { typedef HashtableFindOptions TableType; HashtableFindOptionsT() { } }; struct HashtableFindOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef HashtableFindOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } HashtableFindOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(HashtableFindOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<HashtableFindOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableFindOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct HashtableFindOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit HashtableFindOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } HashtableFindOptionsBuilder &operator=(const HashtableFindOptionsBuilder &); flatbuffers::Offset<HashtableFindOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<HashtableFindOptions>(end); return o; } }; inline flatbuffers::Offset<HashtableFindOptions> CreateHashtableFindOptions( flatbuffers::FlatBufferBuilder &_fbb) { HashtableFindOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<HashtableFindOptions> CreateHashtableFindOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableFindOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct HashtableImportOptionsT : public flatbuffers::NativeTable { typedef HashtableImportOptions TableType; HashtableImportOptionsT() { } }; struct HashtableImportOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef HashtableImportOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } HashtableImportOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(HashtableImportOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<HashtableImportOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableImportOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct HashtableImportOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit HashtableImportOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } HashtableImportOptionsBuilder &operator=(const HashtableImportOptionsBuilder &); flatbuffers::Offset<HashtableImportOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<HashtableImportOptions>(end); return o; } }; inline flatbuffers::Offset<HashtableImportOptions> CreateHashtableImportOptions( flatbuffers::FlatBufferBuilder &_fbb) { HashtableImportOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<HashtableImportOptions> CreateHashtableImportOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableImportOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct HashtableSizeOptionsT : public flatbuffers::NativeTable { typedef HashtableSizeOptions TableType; HashtableSizeOptionsT() { } }; struct HashtableSizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef HashtableSizeOptionsT NativeTableType; bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && verifier.EndTable(); } HashtableSizeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(HashtableSizeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<HashtableSizeOptions> Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableSizeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct HashtableSizeOptionsBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; explicit HashtableSizeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } HashtableSizeOptionsBuilder &operator=(const HashtableSizeOptionsBuilder &); flatbuffers::Offset<HashtableSizeOptions> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<HashtableSizeOptions>(end); return o; } }; inline flatbuffers::Offset<HashtableSizeOptions> CreateHashtableSizeOptions( flatbuffers::FlatBufferBuilder &_fbb) { HashtableSizeOptionsBuilder builder_(_fbb); return builder_.Finish(); } flatbuffers::Offset<HashtableSizeOptions> CreateHashtableSizeOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableSizeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct OperatorCodeT : public flatbuffers::NativeTable { typedef OperatorCode TableType; int8_t deprecated_builtin_code; std::string custom_code; int32_t version; tflite::BuiltinOperator builtin_code; OperatorCodeT() : deprecated_builtin_code(0), version(1), builtin_code(tflite::BuiltinOperator_ADD) { } }; struct OperatorCode FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef OperatorCodeT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_DEPRECATED_BUILTIN_CODE = 4, VT_CUSTOM_CODE = 6, VT_VERSION = 8, VT_BUILTIN_CODE = 10 }; int8_t deprecated_builtin_code() const { return GetField<int8_t>(VT_DEPRECATED_BUILTIN_CODE, 0); } const flatbuffers::String *custom_code() const { return GetPointer<const flatbuffers::String *>(VT_CUSTOM_CODE); } int32_t version() const { return GetField<int32_t>(VT_VERSION, 1); } tflite::BuiltinOperator builtin_code() const { return static_cast<tflite::BuiltinOperator>(GetField<int32_t>(VT_BUILTIN_CODE, 0)); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int8_t>(verifier, VT_DEPRECATED_BUILTIN_CODE) && VerifyOffset(verifier, VT_CUSTOM_CODE) && verifier.VerifyString(custom_code()) && VerifyField<int32_t>(verifier, VT_VERSION) && VerifyField<int32_t>(verifier, VT_BUILTIN_CODE) && verifier.EndTable(); } OperatorCodeT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(OperatorCodeT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<OperatorCode> Pack(flatbuffers::FlatBufferBuilder &_fbb, const OperatorCodeT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct OperatorCodeBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_deprecated_builtin_code(int8_t deprecated_builtin_code) { fbb_.AddElement<int8_t>(OperatorCode::VT_DEPRECATED_BUILTIN_CODE, deprecated_builtin_code, 0); } void add_custom_code(flatbuffers::Offset<flatbuffers::String> custom_code) { fbb_.AddOffset(OperatorCode::VT_CUSTOM_CODE, custom_code); } void add_version(int32_t version) { fbb_.AddElement<int32_t>(OperatorCode::VT_VERSION, version, 1); } void add_builtin_code(tflite::BuiltinOperator builtin_code) { fbb_.AddElement<int32_t>(OperatorCode::VT_BUILTIN_CODE, static_cast<int32_t>(builtin_code), 0); } explicit OperatorCodeBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } OperatorCodeBuilder &operator=(const OperatorCodeBuilder &); flatbuffers::Offset<OperatorCode> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<OperatorCode>(end); return o; } }; inline flatbuffers::Offset<OperatorCode> CreateOperatorCode( flatbuffers::FlatBufferBuilder &_fbb, int8_t deprecated_builtin_code = 0, flatbuffers::Offset<flatbuffers::String> custom_code = 0, int32_t version = 1, tflite::BuiltinOperator builtin_code = tflite::BuiltinOperator_ADD) { OperatorCodeBuilder builder_(_fbb); builder_.add_builtin_code(builtin_code); builder_.add_version(version); builder_.add_custom_code(custom_code); builder_.add_deprecated_builtin_code(deprecated_builtin_code); return builder_.Finish(); } inline flatbuffers::Offset<OperatorCode> CreateOperatorCodeDirect( flatbuffers::FlatBufferBuilder &_fbb, int8_t deprecated_builtin_code = 0, const char *custom_code = nullptr, int32_t version = 1, tflite::BuiltinOperator builtin_code = tflite::BuiltinOperator_ADD) { auto custom_code__ = custom_code ? _fbb.CreateString(custom_code) : 0; return tflite::CreateOperatorCode( _fbb, deprecated_builtin_code, custom_code__, version, builtin_code); } flatbuffers::Offset<OperatorCode> CreateOperatorCode(flatbuffers::FlatBufferBuilder &_fbb, const OperatorCodeT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct OperatorT : public flatbuffers::NativeTable { typedef Operator TableType; uint32_t opcode_index; std::vector<int32_t> inputs; std::vector<int32_t> outputs; tflite::BuiltinOptionsUnion builtin_options; std::vector<uint8_t> custom_options; tflite::CustomOptionsFormat custom_options_format; std::vector<bool> mutating_variable_inputs; std::vector<int32_t> intermediates; OperatorT() : opcode_index(0), custom_options_format(tflite::CustomOptionsFormat_FLEXBUFFERS) { } }; struct Operator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef OperatorT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_OPCODE_INDEX = 4, VT_INPUTS = 6, VT_OUTPUTS = 8, VT_BUILTIN_OPTIONS_TYPE = 10, VT_BUILTIN_OPTIONS = 12, VT_CUSTOM_OPTIONS = 14, VT_CUSTOM_OPTIONS_FORMAT = 16, VT_MUTATING_VARIABLE_INPUTS = 18, VT_INTERMEDIATES = 20 }; uint32_t opcode_index() const { return GetField<uint32_t>(VT_OPCODE_INDEX, 0); } const flatbuffers::Vector<int32_t> *inputs() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_INPUTS); } const flatbuffers::Vector<int32_t> *outputs() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_OUTPUTS); } tflite::BuiltinOptions builtin_options_type() const { return static_cast<tflite::BuiltinOptions>(GetField<uint8_t>(VT_BUILTIN_OPTIONS_TYPE, 0)); } const void *builtin_options() const { return GetPointer<const void *>(VT_BUILTIN_OPTIONS); } template<typename T> const T *builtin_options_as() const; const tflite::Conv2DOptions *builtin_options_as_Conv2DOptions() const { return builtin_options_type() == tflite::BuiltinOptions_Conv2DOptions ? static_cast<const tflite::Conv2DOptions *>(builtin_options()) : nullptr; } const tflite::DepthwiseConv2DOptions *builtin_options_as_DepthwiseConv2DOptions() const { return builtin_options_type() == tflite::BuiltinOptions_DepthwiseConv2DOptions ? static_cast<const tflite::DepthwiseConv2DOptions *>(builtin_options()) : nullptr; } const tflite::ConcatEmbeddingsOptions *builtin_options_as_ConcatEmbeddingsOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ConcatEmbeddingsOptions ? static_cast<const tflite::ConcatEmbeddingsOptions *>(builtin_options()) : nullptr; } const tflite::LSHProjectionOptions *builtin_options_as_LSHProjectionOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LSHProjectionOptions ? static_cast<const tflite::LSHProjectionOptions *>(builtin_options()) : nullptr; } const tflite::Pool2DOptions *builtin_options_as_Pool2DOptions() const { return builtin_options_type() == tflite::BuiltinOptions_Pool2DOptions ? static_cast<const tflite::Pool2DOptions *>(builtin_options()) : nullptr; } const tflite::SVDFOptions *builtin_options_as_SVDFOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SVDFOptions ? static_cast<const tflite::SVDFOptions *>(builtin_options()) : nullptr; } const tflite::RNNOptions *builtin_options_as_RNNOptions() const { return builtin_options_type() == tflite::BuiltinOptions_RNNOptions ? static_cast<const tflite::RNNOptions *>(builtin_options()) : nullptr; } const tflite::FullyConnectedOptions *builtin_options_as_FullyConnectedOptions() const { return builtin_options_type() == tflite::BuiltinOptions_FullyConnectedOptions ? static_cast<const tflite::FullyConnectedOptions *>(builtin_options()) : nullptr; } const tflite::SoftmaxOptions *builtin_options_as_SoftmaxOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SoftmaxOptions ? static_cast<const tflite::SoftmaxOptions *>(builtin_options()) : nullptr; } const tflite::ConcatenationOptions *builtin_options_as_ConcatenationOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ConcatenationOptions ? static_cast<const tflite::ConcatenationOptions *>(builtin_options()) : nullptr; } const tflite::AddOptions *builtin_options_as_AddOptions() const { return builtin_options_type() == tflite::BuiltinOptions_AddOptions ? static_cast<const tflite::AddOptions *>(builtin_options()) : nullptr; } const tflite::L2NormOptions *builtin_options_as_L2NormOptions() const { return builtin_options_type() == tflite::BuiltinOptions_L2NormOptions ? static_cast<const tflite::L2NormOptions *>(builtin_options()) : nullptr; } const tflite::LocalResponseNormalizationOptions *builtin_options_as_LocalResponseNormalizationOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LocalResponseNormalizationOptions ? static_cast<const tflite::LocalResponseNormalizationOptions *>(builtin_options()) : nullptr; } const tflite::LSTMOptions *builtin_options_as_LSTMOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LSTMOptions ? static_cast<const tflite::LSTMOptions *>(builtin_options()) : nullptr; } const tflite::ResizeBilinearOptions *builtin_options_as_ResizeBilinearOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ResizeBilinearOptions ? static_cast<const tflite::ResizeBilinearOptions *>(builtin_options()) : nullptr; } const tflite::CallOptions *builtin_options_as_CallOptions() const { return builtin_options_type() == tflite::BuiltinOptions_CallOptions ? static_cast<const tflite::CallOptions *>(builtin_options()) : nullptr; } const tflite::ReshapeOptions *builtin_options_as_ReshapeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ReshapeOptions ? static_cast<const tflite::ReshapeOptions *>(builtin_options()) : nullptr; } const tflite::SkipGramOptions *builtin_options_as_SkipGramOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SkipGramOptions ? static_cast<const tflite::SkipGramOptions *>(builtin_options()) : nullptr; } const tflite::SpaceToDepthOptions *builtin_options_as_SpaceToDepthOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SpaceToDepthOptions ? static_cast<const tflite::SpaceToDepthOptions *>(builtin_options()) : nullptr; } const tflite::EmbeddingLookupSparseOptions *builtin_options_as_EmbeddingLookupSparseOptions() const { return builtin_options_type() == tflite::BuiltinOptions_EmbeddingLookupSparseOptions ? static_cast<const tflite::EmbeddingLookupSparseOptions *>(builtin_options()) : nullptr; } const tflite::MulOptions *builtin_options_as_MulOptions() const { return builtin_options_type() == tflite::BuiltinOptions_MulOptions ? static_cast<const tflite::MulOptions *>(builtin_options()) : nullptr; } const tflite::PadOptions *builtin_options_as_PadOptions() const { return builtin_options_type() == tflite::BuiltinOptions_PadOptions ? static_cast<const tflite::PadOptions *>(builtin_options()) : nullptr; } const tflite::GatherOptions *builtin_options_as_GatherOptions() const { return builtin_options_type() == tflite::BuiltinOptions_GatherOptions ? static_cast<const tflite::GatherOptions *>(builtin_options()) : nullptr; } const tflite::BatchToSpaceNDOptions *builtin_options_as_BatchToSpaceNDOptions() const { return builtin_options_type() == tflite::BuiltinOptions_BatchToSpaceNDOptions ? static_cast<const tflite::BatchToSpaceNDOptions *>(builtin_options()) : nullptr; } const tflite::SpaceToBatchNDOptions *builtin_options_as_SpaceToBatchNDOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SpaceToBatchNDOptions ? static_cast<const tflite::SpaceToBatchNDOptions *>(builtin_options()) : nullptr; } const tflite::TransposeOptions *builtin_options_as_TransposeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_TransposeOptions ? static_cast<const tflite::TransposeOptions *>(builtin_options()) : nullptr; } const tflite::ReducerOptions *builtin_options_as_ReducerOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ReducerOptions ? static_cast<const tflite::ReducerOptions *>(builtin_options()) : nullptr; } const tflite::SubOptions *builtin_options_as_SubOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SubOptions ? static_cast<const tflite::SubOptions *>(builtin_options()) : nullptr; } const tflite::DivOptions *builtin_options_as_DivOptions() const { return builtin_options_type() == tflite::BuiltinOptions_DivOptions ? static_cast<const tflite::DivOptions *>(builtin_options()) : nullptr; } const tflite::SqueezeOptions *builtin_options_as_SqueezeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SqueezeOptions ? static_cast<const tflite::SqueezeOptions *>(builtin_options()) : nullptr; } const tflite::SequenceRNNOptions *builtin_options_as_SequenceRNNOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SequenceRNNOptions ? static_cast<const tflite::SequenceRNNOptions *>(builtin_options()) : nullptr; } const tflite::StridedSliceOptions *builtin_options_as_StridedSliceOptions() const { return builtin_options_type() == tflite::BuiltinOptions_StridedSliceOptions ? static_cast<const tflite::StridedSliceOptions *>(builtin_options()) : nullptr; } const tflite::ExpOptions *builtin_options_as_ExpOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ExpOptions ? static_cast<const tflite::ExpOptions *>(builtin_options()) : nullptr; } const tflite::TopKV2Options *builtin_options_as_TopKV2Options() const { return builtin_options_type() == tflite::BuiltinOptions_TopKV2Options ? static_cast<const tflite::TopKV2Options *>(builtin_options()) : nullptr; } const tflite::SplitOptions *builtin_options_as_SplitOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SplitOptions ? static_cast<const tflite::SplitOptions *>(builtin_options()) : nullptr; } const tflite::LogSoftmaxOptions *builtin_options_as_LogSoftmaxOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LogSoftmaxOptions ? static_cast<const tflite::LogSoftmaxOptions *>(builtin_options()) : nullptr; } const tflite::CastOptions *builtin_options_as_CastOptions() const { return builtin_options_type() == tflite::BuiltinOptions_CastOptions ? static_cast<const tflite::CastOptions *>(builtin_options()) : nullptr; } const tflite::DequantizeOptions *builtin_options_as_DequantizeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_DequantizeOptions ? static_cast<const tflite::DequantizeOptions *>(builtin_options()) : nullptr; } const tflite::MaximumMinimumOptions *builtin_options_as_MaximumMinimumOptions() const { return builtin_options_type() == tflite::BuiltinOptions_MaximumMinimumOptions ? static_cast<const tflite::MaximumMinimumOptions *>(builtin_options()) : nullptr; } const tflite::ArgMaxOptions *builtin_options_as_ArgMaxOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ArgMaxOptions ? static_cast<const tflite::ArgMaxOptions *>(builtin_options()) : nullptr; } const tflite::LessOptions *builtin_options_as_LessOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LessOptions ? static_cast<const tflite::LessOptions *>(builtin_options()) : nullptr; } const tflite::NegOptions *builtin_options_as_NegOptions() const { return builtin_options_type() == tflite::BuiltinOptions_NegOptions ? static_cast<const tflite::NegOptions *>(builtin_options()) : nullptr; } const tflite::PadV2Options *builtin_options_as_PadV2Options() const { return builtin_options_type() == tflite::BuiltinOptions_PadV2Options ? static_cast<const tflite::PadV2Options *>(builtin_options()) : nullptr; } const tflite::GreaterOptions *builtin_options_as_GreaterOptions() const { return builtin_options_type() == tflite::BuiltinOptions_GreaterOptions ? static_cast<const tflite::GreaterOptions *>(builtin_options()) : nullptr; } const tflite::GreaterEqualOptions *builtin_options_as_GreaterEqualOptions() const { return builtin_options_type() == tflite::BuiltinOptions_GreaterEqualOptions ? static_cast<const tflite::GreaterEqualOptions *>(builtin_options()) : nullptr; } const tflite::LessEqualOptions *builtin_options_as_LessEqualOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LessEqualOptions ? static_cast<const tflite::LessEqualOptions *>(builtin_options()) : nullptr; } const tflite::SelectOptions *builtin_options_as_SelectOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SelectOptions ? static_cast<const tflite::SelectOptions *>(builtin_options()) : nullptr; } const tflite::SliceOptions *builtin_options_as_SliceOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SliceOptions ? static_cast<const tflite::SliceOptions *>(builtin_options()) : nullptr; } const tflite::TransposeConvOptions *builtin_options_as_TransposeConvOptions() const { return builtin_options_type() == tflite::BuiltinOptions_TransposeConvOptions ? static_cast<const tflite::TransposeConvOptions *>(builtin_options()) : nullptr; } const tflite::SparseToDenseOptions *builtin_options_as_SparseToDenseOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SparseToDenseOptions ? static_cast<const tflite::SparseToDenseOptions *>(builtin_options()) : nullptr; } const tflite::TileOptions *builtin_options_as_TileOptions() const { return builtin_options_type() == tflite::BuiltinOptions_TileOptions ? static_cast<const tflite::TileOptions *>(builtin_options()) : nullptr; } const tflite::ExpandDimsOptions *builtin_options_as_ExpandDimsOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ExpandDimsOptions ? static_cast<const tflite::ExpandDimsOptions *>(builtin_options()) : nullptr; } const tflite::EqualOptions *builtin_options_as_EqualOptions() const { return builtin_options_type() == tflite::BuiltinOptions_EqualOptions ? static_cast<const tflite::EqualOptions *>(builtin_options()) : nullptr; } const tflite::NotEqualOptions *builtin_options_as_NotEqualOptions() const { return builtin_options_type() == tflite::BuiltinOptions_NotEqualOptions ? static_cast<const tflite::NotEqualOptions *>(builtin_options()) : nullptr; } const tflite::ShapeOptions *builtin_options_as_ShapeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ShapeOptions ? static_cast<const tflite::ShapeOptions *>(builtin_options()) : nullptr; } const tflite::PowOptions *builtin_options_as_PowOptions() const { return builtin_options_type() == tflite::BuiltinOptions_PowOptions ? static_cast<const tflite::PowOptions *>(builtin_options()) : nullptr; } const tflite::ArgMinOptions *builtin_options_as_ArgMinOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ArgMinOptions ? static_cast<const tflite::ArgMinOptions *>(builtin_options()) : nullptr; } const tflite::FakeQuantOptions *builtin_options_as_FakeQuantOptions() const { return builtin_options_type() == tflite::BuiltinOptions_FakeQuantOptions ? static_cast<const tflite::FakeQuantOptions *>(builtin_options()) : nullptr; } const tflite::PackOptions *builtin_options_as_PackOptions() const { return builtin_options_type() == tflite::BuiltinOptions_PackOptions ? static_cast<const tflite::PackOptions *>(builtin_options()) : nullptr; } const tflite::LogicalOrOptions *builtin_options_as_LogicalOrOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LogicalOrOptions ? static_cast<const tflite::LogicalOrOptions *>(builtin_options()) : nullptr; } const tflite::OneHotOptions *builtin_options_as_OneHotOptions() const { return builtin_options_type() == tflite::BuiltinOptions_OneHotOptions ? static_cast<const tflite::OneHotOptions *>(builtin_options()) : nullptr; } const tflite::LogicalAndOptions *builtin_options_as_LogicalAndOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LogicalAndOptions ? static_cast<const tflite::LogicalAndOptions *>(builtin_options()) : nullptr; } const tflite::LogicalNotOptions *builtin_options_as_LogicalNotOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LogicalNotOptions ? static_cast<const tflite::LogicalNotOptions *>(builtin_options()) : nullptr; } const tflite::UnpackOptions *builtin_options_as_UnpackOptions() const { return builtin_options_type() == tflite::BuiltinOptions_UnpackOptions ? static_cast<const tflite::UnpackOptions *>(builtin_options()) : nullptr; } const tflite::FloorDivOptions *builtin_options_as_FloorDivOptions() const { return builtin_options_type() == tflite::BuiltinOptions_FloorDivOptions ? static_cast<const tflite::FloorDivOptions *>(builtin_options()) : nullptr; } const tflite::SquareOptions *builtin_options_as_SquareOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SquareOptions ? static_cast<const tflite::SquareOptions *>(builtin_options()) : nullptr; } const tflite::ZerosLikeOptions *builtin_options_as_ZerosLikeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ZerosLikeOptions ? static_cast<const tflite::ZerosLikeOptions *>(builtin_options()) : nullptr; } const tflite::FillOptions *builtin_options_as_FillOptions() const { return builtin_options_type() == tflite::BuiltinOptions_FillOptions ? static_cast<const tflite::FillOptions *>(builtin_options()) : nullptr; } const tflite::BidirectionalSequenceLSTMOptions *builtin_options_as_BidirectionalSequenceLSTMOptions() const { return builtin_options_type() == tflite::BuiltinOptions_BidirectionalSequenceLSTMOptions ? static_cast<const tflite::BidirectionalSequenceLSTMOptions *>(builtin_options()) : nullptr; } const tflite::BidirectionalSequenceRNNOptions *builtin_options_as_BidirectionalSequenceRNNOptions() const { return builtin_options_type() == tflite::BuiltinOptions_BidirectionalSequenceRNNOptions ? static_cast<const tflite::BidirectionalSequenceRNNOptions *>(builtin_options()) : nullptr; } const tflite::UnidirectionalSequenceLSTMOptions *builtin_options_as_UnidirectionalSequenceLSTMOptions() const { return builtin_options_type() == tflite::BuiltinOptions_UnidirectionalSequenceLSTMOptions ? static_cast<const tflite::UnidirectionalSequenceLSTMOptions *>(builtin_options()) : nullptr; } const tflite::FloorModOptions *builtin_options_as_FloorModOptions() const { return builtin_options_type() == tflite::BuiltinOptions_FloorModOptions ? static_cast<const tflite::FloorModOptions *>(builtin_options()) : nullptr; } const tflite::RangeOptions *builtin_options_as_RangeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_RangeOptions ? static_cast<const tflite::RangeOptions *>(builtin_options()) : nullptr; } const tflite::ResizeNearestNeighborOptions *builtin_options_as_ResizeNearestNeighborOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ResizeNearestNeighborOptions ? static_cast<const tflite::ResizeNearestNeighborOptions *>(builtin_options()) : nullptr; } const tflite::LeakyReluOptions *builtin_options_as_LeakyReluOptions() const { return builtin_options_type() == tflite::BuiltinOptions_LeakyReluOptions ? static_cast<const tflite::LeakyReluOptions *>(builtin_options()) : nullptr; } const tflite::SquaredDifferenceOptions *builtin_options_as_SquaredDifferenceOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SquaredDifferenceOptions ? static_cast<const tflite::SquaredDifferenceOptions *>(builtin_options()) : nullptr; } const tflite::MirrorPadOptions *builtin_options_as_MirrorPadOptions() const { return builtin_options_type() == tflite::BuiltinOptions_MirrorPadOptions ? static_cast<const tflite::MirrorPadOptions *>(builtin_options()) : nullptr; } const tflite::AbsOptions *builtin_options_as_AbsOptions() const { return builtin_options_type() == tflite::BuiltinOptions_AbsOptions ? static_cast<const tflite::AbsOptions *>(builtin_options()) : nullptr; } const tflite::SplitVOptions *builtin_options_as_SplitVOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SplitVOptions ? static_cast<const tflite::SplitVOptions *>(builtin_options()) : nullptr; } const tflite::UniqueOptions *builtin_options_as_UniqueOptions() const { return builtin_options_type() == tflite::BuiltinOptions_UniqueOptions ? static_cast<const tflite::UniqueOptions *>(builtin_options()) : nullptr; } const tflite::ReverseV2Options *builtin_options_as_ReverseV2Options() const { return builtin_options_type() == tflite::BuiltinOptions_ReverseV2Options ? static_cast<const tflite::ReverseV2Options *>(builtin_options()) : nullptr; } const tflite::AddNOptions *builtin_options_as_AddNOptions() const { return builtin_options_type() == tflite::BuiltinOptions_AddNOptions ? static_cast<const tflite::AddNOptions *>(builtin_options()) : nullptr; } const tflite::GatherNdOptions *builtin_options_as_GatherNdOptions() const { return builtin_options_type() == tflite::BuiltinOptions_GatherNdOptions ? static_cast<const tflite::GatherNdOptions *>(builtin_options()) : nullptr; } const tflite::CosOptions *builtin_options_as_CosOptions() const { return builtin_options_type() == tflite::BuiltinOptions_CosOptions ? static_cast<const tflite::CosOptions *>(builtin_options()) : nullptr; } const tflite::WhereOptions *builtin_options_as_WhereOptions() const { return builtin_options_type() == tflite::BuiltinOptions_WhereOptions ? static_cast<const tflite::WhereOptions *>(builtin_options()) : nullptr; } const tflite::RankOptions *builtin_options_as_RankOptions() const { return builtin_options_type() == tflite::BuiltinOptions_RankOptions ? static_cast<const tflite::RankOptions *>(builtin_options()) : nullptr; } const tflite::ReverseSequenceOptions *builtin_options_as_ReverseSequenceOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ReverseSequenceOptions ? static_cast<const tflite::ReverseSequenceOptions *>(builtin_options()) : nullptr; } const tflite::MatrixDiagOptions *builtin_options_as_MatrixDiagOptions() const { return builtin_options_type() == tflite::BuiltinOptions_MatrixDiagOptions ? static_cast<const tflite::MatrixDiagOptions *>(builtin_options()) : nullptr; } const tflite::QuantizeOptions *builtin_options_as_QuantizeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_QuantizeOptions ? static_cast<const tflite::QuantizeOptions *>(builtin_options()) : nullptr; } const tflite::MatrixSetDiagOptions *builtin_options_as_MatrixSetDiagOptions() const { return builtin_options_type() == tflite::BuiltinOptions_MatrixSetDiagOptions ? static_cast<const tflite::MatrixSetDiagOptions *>(builtin_options()) : nullptr; } const tflite::HardSwishOptions *builtin_options_as_HardSwishOptions() const { return builtin_options_type() == tflite::BuiltinOptions_HardSwishOptions ? static_cast<const tflite::HardSwishOptions *>(builtin_options()) : nullptr; } const tflite::IfOptions *builtin_options_as_IfOptions() const { return builtin_options_type() == tflite::BuiltinOptions_IfOptions ? static_cast<const tflite::IfOptions *>(builtin_options()) : nullptr; } const tflite::WhileOptions *builtin_options_as_WhileOptions() const { return builtin_options_type() == tflite::BuiltinOptions_WhileOptions ? static_cast<const tflite::WhileOptions *>(builtin_options()) : nullptr; } const tflite::DepthToSpaceOptions *builtin_options_as_DepthToSpaceOptions() const { return builtin_options_type() == tflite::BuiltinOptions_DepthToSpaceOptions ? static_cast<const tflite::DepthToSpaceOptions *>(builtin_options()) : nullptr; } const tflite::NonMaxSuppressionV4Options *builtin_options_as_NonMaxSuppressionV4Options() const { return builtin_options_type() == tflite::BuiltinOptions_NonMaxSuppressionV4Options ? static_cast<const tflite::NonMaxSuppressionV4Options *>(builtin_options()) : nullptr; } const tflite::NonMaxSuppressionV5Options *builtin_options_as_NonMaxSuppressionV5Options() const { return builtin_options_type() == tflite::BuiltinOptions_NonMaxSuppressionV5Options ? static_cast<const tflite::NonMaxSuppressionV5Options *>(builtin_options()) : nullptr; } const tflite::ScatterNdOptions *builtin_options_as_ScatterNdOptions() const { return builtin_options_type() == tflite::BuiltinOptions_ScatterNdOptions ? static_cast<const tflite::ScatterNdOptions *>(builtin_options()) : nullptr; } const tflite::SelectV2Options *builtin_options_as_SelectV2Options() const { return builtin_options_type() == tflite::BuiltinOptions_SelectV2Options ? static_cast<const tflite::SelectV2Options *>(builtin_options()) : nullptr; } const tflite::DensifyOptions *builtin_options_as_DensifyOptions() const { return builtin_options_type() == tflite::BuiltinOptions_DensifyOptions ? static_cast<const tflite::DensifyOptions *>(builtin_options()) : nullptr; } const tflite::SegmentSumOptions *builtin_options_as_SegmentSumOptions() const { return builtin_options_type() == tflite::BuiltinOptions_SegmentSumOptions ? static_cast<const tflite::SegmentSumOptions *>(builtin_options()) : nullptr; } const tflite::BatchMatMulOptions *builtin_options_as_BatchMatMulOptions() const { return builtin_options_type() == tflite::BuiltinOptions_BatchMatMulOptions ? static_cast<const tflite::BatchMatMulOptions *>(builtin_options()) : nullptr; } const tflite::CumsumOptions *builtin_options_as_CumsumOptions() const { return builtin_options_type() == tflite::BuiltinOptions_CumsumOptions ? static_cast<const tflite::CumsumOptions *>(builtin_options()) : nullptr; } const tflite::CallOnceOptions *builtin_options_as_CallOnceOptions() const { return builtin_options_type() == tflite::BuiltinOptions_CallOnceOptions ? static_cast<const tflite::CallOnceOptions *>(builtin_options()) : nullptr; } const tflite::BroadcastToOptions *builtin_options_as_BroadcastToOptions() const { return builtin_options_type() == tflite::BuiltinOptions_BroadcastToOptions ? static_cast<const tflite::BroadcastToOptions *>(builtin_options()) : nullptr; } const tflite::Rfft2dOptions *builtin_options_as_Rfft2dOptions() const { return builtin_options_type() == tflite::BuiltinOptions_Rfft2dOptions ? static_cast<const tflite::Rfft2dOptions *>(builtin_options()) : nullptr; } const tflite::Conv3DOptions *builtin_options_as_Conv3DOptions() const { return builtin_options_type() == tflite::BuiltinOptions_Conv3DOptions ? static_cast<const tflite::Conv3DOptions *>(builtin_options()) : nullptr; } const tflite::HashtableOptions *builtin_options_as_HashtableOptions() const { return builtin_options_type() == tflite::BuiltinOptions_HashtableOptions ? static_cast<const tflite::HashtableOptions *>(builtin_options()) : nullptr; } const tflite::HashtableFindOptions *builtin_options_as_HashtableFindOptions() const { return builtin_options_type() == tflite::BuiltinOptions_HashtableFindOptions ? static_cast<const tflite::HashtableFindOptions *>(builtin_options()) : nullptr; } const tflite::HashtableImportOptions *builtin_options_as_HashtableImportOptions() const { return builtin_options_type() == tflite::BuiltinOptions_HashtableImportOptions ? static_cast<const tflite::HashtableImportOptions *>(builtin_options()) : nullptr; } const tflite::HashtableSizeOptions *builtin_options_as_HashtableSizeOptions() const { return builtin_options_type() == tflite::BuiltinOptions_HashtableSizeOptions ? static_cast<const tflite::HashtableSizeOptions *>(builtin_options()) : nullptr; } const flatbuffers::Vector<uint8_t> *custom_options() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_CUSTOM_OPTIONS); } tflite::CustomOptionsFormat custom_options_format() const { return static_cast<tflite::CustomOptionsFormat>(GetField<int8_t>(VT_CUSTOM_OPTIONS_FORMAT, 0)); } const flatbuffers::Vector<uint8_t> *mutating_variable_inputs() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_MUTATING_VARIABLE_INPUTS); } const flatbuffers::Vector<int32_t> *intermediates() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_INTERMEDIATES); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint32_t>(verifier, VT_OPCODE_INDEX) && VerifyOffset(verifier, VT_INPUTS) && verifier.VerifyVector(inputs()) && VerifyOffset(verifier, VT_OUTPUTS) && verifier.VerifyVector(outputs()) && VerifyField<uint8_t>(verifier, VT_BUILTIN_OPTIONS_TYPE) && VerifyOffset(verifier, VT_BUILTIN_OPTIONS) && VerifyBuiltinOptions(verifier, builtin_options(), builtin_options_type()) && VerifyOffset(verifier, VT_CUSTOM_OPTIONS) && verifier.VerifyVector(custom_options()) && VerifyField<int8_t>(verifier, VT_CUSTOM_OPTIONS_FORMAT) && VerifyOffset(verifier, VT_MUTATING_VARIABLE_INPUTS) && verifier.VerifyVector(mutating_variable_inputs()) && VerifyOffset(verifier, VT_INTERMEDIATES) && verifier.VerifyVector(intermediates()) && verifier.EndTable(); } OperatorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(OperatorT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Operator> Pack(flatbuffers::FlatBufferBuilder &_fbb, const OperatorT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; template<> inline const tflite::Conv2DOptions *Operator::builtin_options_as<tflite::Conv2DOptions>() const { return builtin_options_as_Conv2DOptions(); } template<> inline const tflite::DepthwiseConv2DOptions *Operator::builtin_options_as<tflite::DepthwiseConv2DOptions>() const { return builtin_options_as_DepthwiseConv2DOptions(); } template<> inline const tflite::ConcatEmbeddingsOptions *Operator::builtin_options_as<tflite::ConcatEmbeddingsOptions>() const { return builtin_options_as_ConcatEmbeddingsOptions(); } template<> inline const tflite::LSHProjectionOptions *Operator::builtin_options_as<tflite::LSHProjectionOptions>() const { return builtin_options_as_LSHProjectionOptions(); } template<> inline const tflite::Pool2DOptions *Operator::builtin_options_as<tflite::Pool2DOptions>() const { return builtin_options_as_Pool2DOptions(); } template<> inline const tflite::SVDFOptions *Operator::builtin_options_as<tflite::SVDFOptions>() const { return builtin_options_as_SVDFOptions(); } template<> inline const tflite::RNNOptions *Operator::builtin_options_as<tflite::RNNOptions>() const { return builtin_options_as_RNNOptions(); } template<> inline const tflite::FullyConnectedOptions *Operator::builtin_options_as<tflite::FullyConnectedOptions>() const { return builtin_options_as_FullyConnectedOptions(); } template<> inline const tflite::SoftmaxOptions *Operator::builtin_options_as<tflite::SoftmaxOptions>() const { return builtin_options_as_SoftmaxOptions(); } template<> inline const tflite::ConcatenationOptions *Operator::builtin_options_as<tflite::ConcatenationOptions>() const { return builtin_options_as_ConcatenationOptions(); } template<> inline const tflite::AddOptions *Operator::builtin_options_as<tflite::AddOptions>() const { return builtin_options_as_AddOptions(); } template<> inline const tflite::L2NormOptions *Operator::builtin_options_as<tflite::L2NormOptions>() const { return builtin_options_as_L2NormOptions(); } template<> inline const tflite::LocalResponseNormalizationOptions *Operator::builtin_options_as<tflite::LocalResponseNormalizationOptions>() const { return builtin_options_as_LocalResponseNormalizationOptions(); } template<> inline const tflite::LSTMOptions *Operator::builtin_options_as<tflite::LSTMOptions>() const { return builtin_options_as_LSTMOptions(); } template<> inline const tflite::ResizeBilinearOptions *Operator::builtin_options_as<tflite::ResizeBilinearOptions>() const { return builtin_options_as_ResizeBilinearOptions(); } template<> inline const tflite::CallOptions *Operator::builtin_options_as<tflite::CallOptions>() const { return builtin_options_as_CallOptions(); } template<> inline const tflite::ReshapeOptions *Operator::builtin_options_as<tflite::ReshapeOptions>() const { return builtin_options_as_ReshapeOptions(); } template<> inline const tflite::SkipGramOptions *Operator::builtin_options_as<tflite::SkipGramOptions>() const { return builtin_options_as_SkipGramOptions(); } template<> inline const tflite::SpaceToDepthOptions *Operator::builtin_options_as<tflite::SpaceToDepthOptions>() const { return builtin_options_as_SpaceToDepthOptions(); } template<> inline const tflite::EmbeddingLookupSparseOptions *Operator::builtin_options_as<tflite::EmbeddingLookupSparseOptions>() const { return builtin_options_as_EmbeddingLookupSparseOptions(); } template<> inline const tflite::MulOptions *Operator::builtin_options_as<tflite::MulOptions>() const { return builtin_options_as_MulOptions(); } template<> inline const tflite::PadOptions *Operator::builtin_options_as<tflite::PadOptions>() const { return builtin_options_as_PadOptions(); } template<> inline const tflite::GatherOptions *Operator::builtin_options_as<tflite::GatherOptions>() const { return builtin_options_as_GatherOptions(); } template<> inline const tflite::BatchToSpaceNDOptions *Operator::builtin_options_as<tflite::BatchToSpaceNDOptions>() const { return builtin_options_as_BatchToSpaceNDOptions(); } template<> inline const tflite::SpaceToBatchNDOptions *Operator::builtin_options_as<tflite::SpaceToBatchNDOptions>() const { return builtin_options_as_SpaceToBatchNDOptions(); } template<> inline const tflite::TransposeOptions *Operator::builtin_options_as<tflite::TransposeOptions>() const { return builtin_options_as_TransposeOptions(); } template<> inline const tflite::ReducerOptions *Operator::builtin_options_as<tflite::ReducerOptions>() const { return builtin_options_as_ReducerOptions(); } template<> inline const tflite::SubOptions *Operator::builtin_options_as<tflite::SubOptions>() const { return builtin_options_as_SubOptions(); } template<> inline const tflite::DivOptions *Operator::builtin_options_as<tflite::DivOptions>() const { return builtin_options_as_DivOptions(); } template<> inline const tflite::SqueezeOptions *Operator::builtin_options_as<tflite::SqueezeOptions>() const { return builtin_options_as_SqueezeOptions(); } template<> inline const tflite::SequenceRNNOptions *Operator::builtin_options_as<tflite::SequenceRNNOptions>() const { return builtin_options_as_SequenceRNNOptions(); } template<> inline const tflite::StridedSliceOptions *Operator::builtin_options_as<tflite::StridedSliceOptions>() const { return builtin_options_as_StridedSliceOptions(); } template<> inline const tflite::ExpOptions *Operator::builtin_options_as<tflite::ExpOptions>() const { return builtin_options_as_ExpOptions(); } template<> inline const tflite::TopKV2Options *Operator::builtin_options_as<tflite::TopKV2Options>() const { return builtin_options_as_TopKV2Options(); } template<> inline const tflite::SplitOptions *Operator::builtin_options_as<tflite::SplitOptions>() const { return builtin_options_as_SplitOptions(); } template<> inline const tflite::LogSoftmaxOptions *Operator::builtin_options_as<tflite::LogSoftmaxOptions>() const { return builtin_options_as_LogSoftmaxOptions(); } template<> inline const tflite::CastOptions *Operator::builtin_options_as<tflite::CastOptions>() const { return builtin_options_as_CastOptions(); } template<> inline const tflite::DequantizeOptions *Operator::builtin_options_as<tflite::DequantizeOptions>() const { return builtin_options_as_DequantizeOptions(); } template<> inline const tflite::MaximumMinimumOptions *Operator::builtin_options_as<tflite::MaximumMinimumOptions>() const { return builtin_options_as_MaximumMinimumOptions(); } template<> inline const tflite::ArgMaxOptions *Operator::builtin_options_as<tflite::ArgMaxOptions>() const { return builtin_options_as_ArgMaxOptions(); } template<> inline const tflite::LessOptions *Operator::builtin_options_as<tflite::LessOptions>() const { return builtin_options_as_LessOptions(); } template<> inline const tflite::NegOptions *Operator::builtin_options_as<tflite::NegOptions>() const { return builtin_options_as_NegOptions(); } template<> inline const tflite::PadV2Options *Operator::builtin_options_as<tflite::PadV2Options>() const { return builtin_options_as_PadV2Options(); } template<> inline const tflite::GreaterOptions *Operator::builtin_options_as<tflite::GreaterOptions>() const { return builtin_options_as_GreaterOptions(); } template<> inline const tflite::GreaterEqualOptions *Operator::builtin_options_as<tflite::GreaterEqualOptions>() const { return builtin_options_as_GreaterEqualOptions(); } template<> inline const tflite::LessEqualOptions *Operator::builtin_options_as<tflite::LessEqualOptions>() const { return builtin_options_as_LessEqualOptions(); } template<> inline const tflite::SelectOptions *Operator::builtin_options_as<tflite::SelectOptions>() const { return builtin_options_as_SelectOptions(); } template<> inline const tflite::SliceOptions *Operator::builtin_options_as<tflite::SliceOptions>() const { return builtin_options_as_SliceOptions(); } template<> inline const tflite::TransposeConvOptions *Operator::builtin_options_as<tflite::TransposeConvOptions>() const { return builtin_options_as_TransposeConvOptions(); } template<> inline const tflite::SparseToDenseOptions *Operator::builtin_options_as<tflite::SparseToDenseOptions>() const { return builtin_options_as_SparseToDenseOptions(); } template<> inline const tflite::TileOptions *Operator::builtin_options_as<tflite::TileOptions>() const { return builtin_options_as_TileOptions(); } template<> inline const tflite::ExpandDimsOptions *Operator::builtin_options_as<tflite::ExpandDimsOptions>() const { return builtin_options_as_ExpandDimsOptions(); } template<> inline const tflite::EqualOptions *Operator::builtin_options_as<tflite::EqualOptions>() const { return builtin_options_as_EqualOptions(); } template<> inline const tflite::NotEqualOptions *Operator::builtin_options_as<tflite::NotEqualOptions>() const { return builtin_options_as_NotEqualOptions(); } template<> inline const tflite::ShapeOptions *Operator::builtin_options_as<tflite::ShapeOptions>() const { return builtin_options_as_ShapeOptions(); } template<> inline const tflite::PowOptions *Operator::builtin_options_as<tflite::PowOptions>() const { return builtin_options_as_PowOptions(); } template<> inline const tflite::ArgMinOptions *Operator::builtin_options_as<tflite::ArgMinOptions>() const { return builtin_options_as_ArgMinOptions(); } template<> inline const tflite::FakeQuantOptions *Operator::builtin_options_as<tflite::FakeQuantOptions>() const { return builtin_options_as_FakeQuantOptions(); } template<> inline const tflite::PackOptions *Operator::builtin_options_as<tflite::PackOptions>() const { return builtin_options_as_PackOptions(); } template<> inline const tflite::LogicalOrOptions *Operator::builtin_options_as<tflite::LogicalOrOptions>() const { return builtin_options_as_LogicalOrOptions(); } template<> inline const tflite::OneHotOptions *Operator::builtin_options_as<tflite::OneHotOptions>() const { return builtin_options_as_OneHotOptions(); } template<> inline const tflite::LogicalAndOptions *Operator::builtin_options_as<tflite::LogicalAndOptions>() const { return builtin_options_as_LogicalAndOptions(); } template<> inline const tflite::LogicalNotOptions *Operator::builtin_options_as<tflite::LogicalNotOptions>() const { return builtin_options_as_LogicalNotOptions(); } template<> inline const tflite::UnpackOptions *Operator::builtin_options_as<tflite::UnpackOptions>() const { return builtin_options_as_UnpackOptions(); } template<> inline const tflite::FloorDivOptions *Operator::builtin_options_as<tflite::FloorDivOptions>() const { return builtin_options_as_FloorDivOptions(); } template<> inline const tflite::SquareOptions *Operator::builtin_options_as<tflite::SquareOptions>() const { return builtin_options_as_SquareOptions(); } template<> inline const tflite::ZerosLikeOptions *Operator::builtin_options_as<tflite::ZerosLikeOptions>() const { return builtin_options_as_ZerosLikeOptions(); } template<> inline const tflite::FillOptions *Operator::builtin_options_as<tflite::FillOptions>() const { return builtin_options_as_FillOptions(); } template<> inline const tflite::BidirectionalSequenceLSTMOptions *Operator::builtin_options_as<tflite::BidirectionalSequenceLSTMOptions>() const { return builtin_options_as_BidirectionalSequenceLSTMOptions(); } template<> inline const tflite::BidirectionalSequenceRNNOptions *Operator::builtin_options_as<tflite::BidirectionalSequenceRNNOptions>() const { return builtin_options_as_BidirectionalSequenceRNNOptions(); } template<> inline const tflite::UnidirectionalSequenceLSTMOptions *Operator::builtin_options_as<tflite::UnidirectionalSequenceLSTMOptions>() const { return builtin_options_as_UnidirectionalSequenceLSTMOptions(); } template<> inline const tflite::FloorModOptions *Operator::builtin_options_as<tflite::FloorModOptions>() const { return builtin_options_as_FloorModOptions(); } template<> inline const tflite::RangeOptions *Operator::builtin_options_as<tflite::RangeOptions>() const { return builtin_options_as_RangeOptions(); } template<> inline const tflite::ResizeNearestNeighborOptions *Operator::builtin_options_as<tflite::ResizeNearestNeighborOptions>() const { return builtin_options_as_ResizeNearestNeighborOptions(); } template<> inline const tflite::LeakyReluOptions *Operator::builtin_options_as<tflite::LeakyReluOptions>() const { return builtin_options_as_LeakyReluOptions(); } template<> inline const tflite::SquaredDifferenceOptions *Operator::builtin_options_as<tflite::SquaredDifferenceOptions>() const { return builtin_options_as_SquaredDifferenceOptions(); } template<> inline const tflite::MirrorPadOptions *Operator::builtin_options_as<tflite::MirrorPadOptions>() const { return builtin_options_as_MirrorPadOptions(); } template<> inline const tflite::AbsOptions *Operator::builtin_options_as<tflite::AbsOptions>() const { return builtin_options_as_AbsOptions(); } template<> inline const tflite::SplitVOptions *Operator::builtin_options_as<tflite::SplitVOptions>() const { return builtin_options_as_SplitVOptions(); } template<> inline const tflite::UniqueOptions *Operator::builtin_options_as<tflite::UniqueOptions>() const { return builtin_options_as_UniqueOptions(); } template<> inline const tflite::ReverseV2Options *Operator::builtin_options_as<tflite::ReverseV2Options>() const { return builtin_options_as_ReverseV2Options(); } template<> inline const tflite::AddNOptions *Operator::builtin_options_as<tflite::AddNOptions>() const { return builtin_options_as_AddNOptions(); } template<> inline const tflite::GatherNdOptions *Operator::builtin_options_as<tflite::GatherNdOptions>() const { return builtin_options_as_GatherNdOptions(); } template<> inline const tflite::CosOptions *Operator::builtin_options_as<tflite::CosOptions>() const { return builtin_options_as_CosOptions(); } template<> inline const tflite::WhereOptions *Operator::builtin_options_as<tflite::WhereOptions>() const { return builtin_options_as_WhereOptions(); } template<> inline const tflite::RankOptions *Operator::builtin_options_as<tflite::RankOptions>() const { return builtin_options_as_RankOptions(); } template<> inline const tflite::ReverseSequenceOptions *Operator::builtin_options_as<tflite::ReverseSequenceOptions>() const { return builtin_options_as_ReverseSequenceOptions(); } template<> inline const tflite::MatrixDiagOptions *Operator::builtin_options_as<tflite::MatrixDiagOptions>() const { return builtin_options_as_MatrixDiagOptions(); } template<> inline const tflite::QuantizeOptions *Operator::builtin_options_as<tflite::QuantizeOptions>() const { return builtin_options_as_QuantizeOptions(); } template<> inline const tflite::MatrixSetDiagOptions *Operator::builtin_options_as<tflite::MatrixSetDiagOptions>() const { return builtin_options_as_MatrixSetDiagOptions(); } template<> inline const tflite::HardSwishOptions *Operator::builtin_options_as<tflite::HardSwishOptions>() const { return builtin_options_as_HardSwishOptions(); } template<> inline const tflite::IfOptions *Operator::builtin_options_as<tflite::IfOptions>() const { return builtin_options_as_IfOptions(); } template<> inline const tflite::WhileOptions *Operator::builtin_options_as<tflite::WhileOptions>() const { return builtin_options_as_WhileOptions(); } template<> inline const tflite::DepthToSpaceOptions *Operator::builtin_options_as<tflite::DepthToSpaceOptions>() const { return builtin_options_as_DepthToSpaceOptions(); } template<> inline const tflite::NonMaxSuppressionV4Options *Operator::builtin_options_as<tflite::NonMaxSuppressionV4Options>() const { return builtin_options_as_NonMaxSuppressionV4Options(); } template<> inline const tflite::NonMaxSuppressionV5Options *Operator::builtin_options_as<tflite::NonMaxSuppressionV5Options>() const { return builtin_options_as_NonMaxSuppressionV5Options(); } template<> inline const tflite::ScatterNdOptions *Operator::builtin_options_as<tflite::ScatterNdOptions>() const { return builtin_options_as_ScatterNdOptions(); } template<> inline const tflite::SelectV2Options *Operator::builtin_options_as<tflite::SelectV2Options>() const { return builtin_options_as_SelectV2Options(); } template<> inline const tflite::DensifyOptions *Operator::builtin_options_as<tflite::DensifyOptions>() const { return builtin_options_as_DensifyOptions(); } template<> inline const tflite::SegmentSumOptions *Operator::builtin_options_as<tflite::SegmentSumOptions>() const { return builtin_options_as_SegmentSumOptions(); } template<> inline const tflite::BatchMatMulOptions *Operator::builtin_options_as<tflite::BatchMatMulOptions>() const { return builtin_options_as_BatchMatMulOptions(); } template<> inline const tflite::CumsumOptions *Operator::builtin_options_as<tflite::CumsumOptions>() const { return builtin_options_as_CumsumOptions(); } template<> inline const tflite::CallOnceOptions *Operator::builtin_options_as<tflite::CallOnceOptions>() const { return builtin_options_as_CallOnceOptions(); } template<> inline const tflite::BroadcastToOptions *Operator::builtin_options_as<tflite::BroadcastToOptions>() const { return builtin_options_as_BroadcastToOptions(); } template<> inline const tflite::Rfft2dOptions *Operator::builtin_options_as<tflite::Rfft2dOptions>() const { return builtin_options_as_Rfft2dOptions(); } template<> inline const tflite::Conv3DOptions *Operator::builtin_options_as<tflite::Conv3DOptions>() const { return builtin_options_as_Conv3DOptions(); } template<> inline const tflite::HashtableOptions *Operator::builtin_options_as<tflite::HashtableOptions>() const { return builtin_options_as_HashtableOptions(); } template<> inline const tflite::HashtableFindOptions *Operator::builtin_options_as<tflite::HashtableFindOptions>() const { return builtin_options_as_HashtableFindOptions(); } template<> inline const tflite::HashtableImportOptions *Operator::builtin_options_as<tflite::HashtableImportOptions>() const { return builtin_options_as_HashtableImportOptions(); } template<> inline const tflite::HashtableSizeOptions *Operator::builtin_options_as<tflite::HashtableSizeOptions>() const { return builtin_options_as_HashtableSizeOptions(); } struct OperatorBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_opcode_index(uint32_t opcode_index) { fbb_.AddElement<uint32_t>(Operator::VT_OPCODE_INDEX, opcode_index, 0); } void add_inputs(flatbuffers::Offset<flatbuffers::Vector<int32_t>> inputs) { fbb_.AddOffset(Operator::VT_INPUTS, inputs); } void add_outputs(flatbuffers::Offset<flatbuffers::Vector<int32_t>> outputs) { fbb_.AddOffset(Operator::VT_OUTPUTS, outputs); } void add_builtin_options_type(tflite::BuiltinOptions builtin_options_type) { fbb_.AddElement<uint8_t>(Operator::VT_BUILTIN_OPTIONS_TYPE, static_cast<uint8_t>(builtin_options_type), 0); } void add_builtin_options(flatbuffers::Offset<void> builtin_options) { fbb_.AddOffset(Operator::VT_BUILTIN_OPTIONS, builtin_options); } void add_custom_options(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> custom_options) { fbb_.AddOffset(Operator::VT_CUSTOM_OPTIONS, custom_options); } void add_custom_options_format(tflite::CustomOptionsFormat custom_options_format) { fbb_.AddElement<int8_t>(Operator::VT_CUSTOM_OPTIONS_FORMAT, static_cast<int8_t>(custom_options_format), 0); } void add_mutating_variable_inputs(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> mutating_variable_inputs) { fbb_.AddOffset(Operator::VT_MUTATING_VARIABLE_INPUTS, mutating_variable_inputs); } void add_intermediates(flatbuffers::Offset<flatbuffers::Vector<int32_t>> intermediates) { fbb_.AddOffset(Operator::VT_INTERMEDIATES, intermediates); } explicit OperatorBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } OperatorBuilder &operator=(const OperatorBuilder &); flatbuffers::Offset<Operator> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Operator>(end); return o; } }; inline flatbuffers::Offset<Operator> CreateOperator( flatbuffers::FlatBufferBuilder &_fbb, uint32_t opcode_index = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> inputs = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> outputs = 0, tflite::BuiltinOptions builtin_options_type = tflite::BuiltinOptions_NONE, flatbuffers::Offset<void> builtin_options = 0, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> custom_options = 0, tflite::CustomOptionsFormat custom_options_format = tflite::CustomOptionsFormat_FLEXBUFFERS, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> mutating_variable_inputs = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> intermediates = 0) { OperatorBuilder builder_(_fbb); builder_.add_intermediates(intermediates); builder_.add_mutating_variable_inputs(mutating_variable_inputs); builder_.add_custom_options(custom_options); builder_.add_builtin_options(builtin_options); builder_.add_outputs(outputs); builder_.add_inputs(inputs); builder_.add_opcode_index(opcode_index); builder_.add_custom_options_format(custom_options_format); builder_.add_builtin_options_type(builtin_options_type); return builder_.Finish(); } inline flatbuffers::Offset<Operator> CreateOperatorDirect( flatbuffers::FlatBufferBuilder &_fbb, uint32_t opcode_index = 0, const std::vector<int32_t> *inputs = nullptr, const std::vector<int32_t> *outputs = nullptr, tflite::BuiltinOptions builtin_options_type = tflite::BuiltinOptions_NONE, flatbuffers::Offset<void> builtin_options = 0, const std::vector<uint8_t> *custom_options = nullptr, tflite::CustomOptionsFormat custom_options_format = tflite::CustomOptionsFormat_FLEXBUFFERS, const std::vector<uint8_t> *mutating_variable_inputs = nullptr, const std::vector<int32_t> *intermediates = nullptr) { auto inputs__ = inputs ? _fbb.CreateVector<int32_t>(*inputs) : 0; auto outputs__ = outputs ? _fbb.CreateVector<int32_t>(*outputs) : 0; auto custom_options__ = custom_options ? _fbb.CreateVector<uint8_t>(*custom_options) : 0; auto mutating_variable_inputs__ = mutating_variable_inputs ? _fbb.CreateVector<uint8_t>(*mutating_variable_inputs) : 0; auto intermediates__ = intermediates ? _fbb.CreateVector<int32_t>(*intermediates) : 0; return tflite::CreateOperator( _fbb, opcode_index, inputs__, outputs__, builtin_options_type, builtin_options, custom_options__, custom_options_format, mutating_variable_inputs__, intermediates__); } flatbuffers::Offset<Operator> CreateOperator(flatbuffers::FlatBufferBuilder &_fbb, const OperatorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SubGraphT : public flatbuffers::NativeTable { typedef SubGraph TableType; std::vector<std::unique_ptr<tflite::TensorT>> tensors; std::vector<int32_t> inputs; std::vector<int32_t> outputs; std::vector<std::unique_ptr<tflite::OperatorT>> operators; std::string name; SubGraphT() { } }; struct SubGraph FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SubGraphT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_TENSORS = 4, VT_INPUTS = 6, VT_OUTPUTS = 8, VT_OPERATORS = 10, VT_NAME = 12 }; const flatbuffers::Vector<flatbuffers::Offset<tflite::Tensor>> *tensors() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::Tensor>> *>(VT_TENSORS); } const flatbuffers::Vector<int32_t> *inputs() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_INPUTS); } const flatbuffers::Vector<int32_t> *outputs() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_OUTPUTS); } const flatbuffers::Vector<flatbuffers::Offset<tflite::Operator>> *operators() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::Operator>> *>(VT_OPERATORS); } const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(VT_NAME); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_TENSORS) && verifier.VerifyVector(tensors()) && verifier.VerifyVectorOfTables(tensors()) && VerifyOffset(verifier, VT_INPUTS) && verifier.VerifyVector(inputs()) && VerifyOffset(verifier, VT_OUTPUTS) && verifier.VerifyVector(outputs()) && VerifyOffset(verifier, VT_OPERATORS) && verifier.VerifyVector(operators()) && verifier.VerifyVectorOfTables(operators()) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && verifier.EndTable(); } SubGraphT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SubGraphT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SubGraph> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SubGraphT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SubGraphBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_tensors(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Tensor>>> tensors) { fbb_.AddOffset(SubGraph::VT_TENSORS, tensors); } void add_inputs(flatbuffers::Offset<flatbuffers::Vector<int32_t>> inputs) { fbb_.AddOffset(SubGraph::VT_INPUTS, inputs); } void add_outputs(flatbuffers::Offset<flatbuffers::Vector<int32_t>> outputs) { fbb_.AddOffset(SubGraph::VT_OUTPUTS, outputs); } void add_operators(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Operator>>> operators) { fbb_.AddOffset(SubGraph::VT_OPERATORS, operators); } void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(SubGraph::VT_NAME, name); } explicit SubGraphBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SubGraphBuilder &operator=(const SubGraphBuilder &); flatbuffers::Offset<SubGraph> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SubGraph>(end); return o; } }; inline flatbuffers::Offset<SubGraph> CreateSubGraph( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Tensor>>> tensors = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> inputs = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> outputs = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Operator>>> operators = 0, flatbuffers::Offset<flatbuffers::String> name = 0) { SubGraphBuilder builder_(_fbb); builder_.add_name(name); builder_.add_operators(operators); builder_.add_outputs(outputs); builder_.add_inputs(inputs); builder_.add_tensors(tensors); return builder_.Finish(); } inline flatbuffers::Offset<SubGraph> CreateSubGraphDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<flatbuffers::Offset<tflite::Tensor>> *tensors = nullptr, const std::vector<int32_t> *inputs = nullptr, const std::vector<int32_t> *outputs = nullptr, const std::vector<flatbuffers::Offset<tflite::Operator>> *operators = nullptr, const char *name = nullptr) { auto tensors__ = tensors ? _fbb.CreateVector<flatbuffers::Offset<tflite::Tensor>>(*tensors) : 0; auto inputs__ = inputs ? _fbb.CreateVector<int32_t>(*inputs) : 0; auto outputs__ = outputs ? _fbb.CreateVector<int32_t>(*outputs) : 0; auto operators__ = operators ? _fbb.CreateVector<flatbuffers::Offset<tflite::Operator>>(*operators) : 0; auto name__ = name ? _fbb.CreateString(name) : 0; return tflite::CreateSubGraph( _fbb, tensors__, inputs__, outputs__, operators__, name__); } flatbuffers::Offset<SubGraph> CreateSubGraph(flatbuffers::FlatBufferBuilder &_fbb, const SubGraphT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct BufferT : public flatbuffers::NativeTable { typedef Buffer TableType; std::vector<uint8_t> data; BufferT() { } }; struct Buffer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BufferT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_DATA = 4 }; const flatbuffers::Vector<uint8_t> *data() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_DATA); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_DATA) && verifier.VerifyVector(data()) && verifier.EndTable(); } BufferT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(BufferT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Buffer> Pack(flatbuffers::FlatBufferBuilder &_fbb, const BufferT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct BufferBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_data(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> data) { fbb_.AddOffset(Buffer::VT_DATA, data); } explicit BufferBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } BufferBuilder &operator=(const BufferBuilder &); flatbuffers::Offset<Buffer> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Buffer>(end); return o; } }; inline flatbuffers::Offset<Buffer> CreateBuffer( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<uint8_t>> data = 0) { BufferBuilder builder_(_fbb); builder_.add_data(data); return builder_.Finish(); } inline flatbuffers::Offset<Buffer> CreateBufferDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<uint8_t> *data = nullptr) { if (data) { _fbb.ForceVectorAlignment(data->size(), sizeof(uint8_t), 16); } auto data__ = data ? _fbb.CreateVector<uint8_t>(*data) : 0; return tflite::CreateBuffer( _fbb, data__); } flatbuffers::Offset<Buffer> CreateBuffer(flatbuffers::FlatBufferBuilder &_fbb, const BufferT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct MetadataT : public flatbuffers::NativeTable { typedef Metadata TableType; std::string name; uint32_t buffer; MetadataT() : buffer(0) { } }; struct Metadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef MetadataT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NAME = 4, VT_BUFFER = 6 }; const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(VT_NAME); } uint32_t buffer() const { return GetField<uint32_t>(VT_BUFFER, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && VerifyField<uint32_t>(verifier, VT_BUFFER) && verifier.EndTable(); } MetadataT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(MetadataT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Metadata> Pack(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct MetadataBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(Metadata::VT_NAME, name); } void add_buffer(uint32_t buffer) { fbb_.AddElement<uint32_t>(Metadata::VT_BUFFER, buffer, 0); } explicit MetadataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } MetadataBuilder &operator=(const MetadataBuilder &); flatbuffers::Offset<Metadata> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Metadata>(end); return o; } }; inline flatbuffers::Offset<Metadata> CreateMetadata( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::String> name = 0, uint32_t buffer = 0) { MetadataBuilder builder_(_fbb); builder_.add_buffer(buffer); builder_.add_name(name); return builder_.Finish(); } inline flatbuffers::Offset<Metadata> CreateMetadataDirect( flatbuffers::FlatBufferBuilder &_fbb, const char *name = nullptr, uint32_t buffer = 0) { auto name__ = name ? _fbb.CreateString(name) : 0; return tflite::CreateMetadata( _fbb, name__, buffer); } flatbuffers::Offset<Metadata> CreateMetadata(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct TensorMapT : public flatbuffers::NativeTable { typedef TensorMap TableType; std::string name; uint32_t tensor_index; TensorMapT() : tensor_index(0) { } }; struct TensorMap FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef TensorMapT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_NAME = 4, VT_TENSOR_INDEX = 6 }; const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(VT_NAME); } uint32_t tensor_index() const { return GetField<uint32_t>(VT_TENSOR_INDEX, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && VerifyField<uint32_t>(verifier, VT_TENSOR_INDEX) && verifier.EndTable(); } TensorMapT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(TensorMapT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<TensorMap> Pack(flatbuffers::FlatBufferBuilder &_fbb, const TensorMapT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct TensorMapBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(TensorMap::VT_NAME, name); } void add_tensor_index(uint32_t tensor_index) { fbb_.AddElement<uint32_t>(TensorMap::VT_TENSOR_INDEX, tensor_index, 0); } explicit TensorMapBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } TensorMapBuilder &operator=(const TensorMapBuilder &); flatbuffers::Offset<TensorMap> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<TensorMap>(end); return o; } }; inline flatbuffers::Offset<TensorMap> CreateTensorMap( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::String> name = 0, uint32_t tensor_index = 0) { TensorMapBuilder builder_(_fbb); builder_.add_tensor_index(tensor_index); builder_.add_name(name); return builder_.Finish(); } inline flatbuffers::Offset<TensorMap> CreateTensorMapDirect( flatbuffers::FlatBufferBuilder &_fbb, const char *name = nullptr, uint32_t tensor_index = 0) { auto name__ = name ? _fbb.CreateString(name) : 0; return tflite::CreateTensorMap( _fbb, name__, tensor_index); } flatbuffers::Offset<TensorMap> CreateTensorMap(flatbuffers::FlatBufferBuilder &_fbb, const TensorMapT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct SignatureDefT : public flatbuffers::NativeTable { typedef SignatureDef TableType; std::vector<std::unique_ptr<tflite::TensorMapT>> inputs; std::vector<std::unique_ptr<tflite::TensorMapT>> outputs; std::string method_name; std::string key; SignatureDefT() { } }; struct SignatureDef FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SignatureDefT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_INPUTS = 4, VT_OUTPUTS = 6, VT_METHOD_NAME = 8, VT_KEY = 10 }; const flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>> *inputs() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>> *>(VT_INPUTS); } const flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>> *outputs() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>> *>(VT_OUTPUTS); } const flatbuffers::String *method_name() const { return GetPointer<const flatbuffers::String *>(VT_METHOD_NAME); } const flatbuffers::String *key() const { return GetPointer<const flatbuffers::String *>(VT_KEY); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_INPUTS) && verifier.VerifyVector(inputs()) && verifier.VerifyVectorOfTables(inputs()) && VerifyOffset(verifier, VT_OUTPUTS) && verifier.VerifyVector(outputs()) && verifier.VerifyVectorOfTables(outputs()) && VerifyOffset(verifier, VT_METHOD_NAME) && verifier.VerifyString(method_name()) && VerifyOffset(verifier, VT_KEY) && verifier.VerifyString(key()) && verifier.EndTable(); } SignatureDefT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(SignatureDefT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<SignatureDef> Pack(flatbuffers::FlatBufferBuilder &_fbb, const SignatureDefT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct SignatureDefBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_inputs(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>>> inputs) { fbb_.AddOffset(SignatureDef::VT_INPUTS, inputs); } void add_outputs(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>>> outputs) { fbb_.AddOffset(SignatureDef::VT_OUTPUTS, outputs); } void add_method_name(flatbuffers::Offset<flatbuffers::String> method_name) { fbb_.AddOffset(SignatureDef::VT_METHOD_NAME, method_name); } void add_key(flatbuffers::Offset<flatbuffers::String> key) { fbb_.AddOffset(SignatureDef::VT_KEY, key); } explicit SignatureDefBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } SignatureDefBuilder &operator=(const SignatureDefBuilder &); flatbuffers::Offset<SignatureDef> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<SignatureDef>(end); return o; } }; inline flatbuffers::Offset<SignatureDef> CreateSignatureDef( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>>> inputs = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMap>>> outputs = 0, flatbuffers::Offset<flatbuffers::String> method_name = 0, flatbuffers::Offset<flatbuffers::String> key = 0) { SignatureDefBuilder builder_(_fbb); builder_.add_key(key); builder_.add_method_name(method_name); builder_.add_outputs(outputs); builder_.add_inputs(inputs); return builder_.Finish(); } inline flatbuffers::Offset<SignatureDef> CreateSignatureDefDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector<flatbuffers::Offset<tflite::TensorMap>> *inputs = nullptr, const std::vector<flatbuffers::Offset<tflite::TensorMap>> *outputs = nullptr, const char *method_name = nullptr, const char *key = nullptr) { auto inputs__ = inputs ? _fbb.CreateVector<flatbuffers::Offset<tflite::TensorMap>>(*inputs) : 0; auto outputs__ = outputs ? _fbb.CreateVector<flatbuffers::Offset<tflite::TensorMap>>(*outputs) : 0; auto method_name__ = method_name ? _fbb.CreateString(method_name) : 0; auto key__ = key ? _fbb.CreateString(key) : 0; return tflite::CreateSignatureDef( _fbb, inputs__, outputs__, method_name__, key__); } flatbuffers::Offset<SignatureDef> CreateSignatureDef(flatbuffers::FlatBufferBuilder &_fbb, const SignatureDefT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct ModelT : public flatbuffers::NativeTable { typedef Model TableType; uint32_t version; std::vector<std::unique_ptr<tflite::OperatorCodeT>> operator_codes; std::vector<std::unique_ptr<tflite::SubGraphT>> subgraphs; std::string description; std::vector<std::unique_ptr<tflite::BufferT>> buffers; std::vector<int32_t> metadata_buffer; std::vector<std::unique_ptr<tflite::MetadataT>> metadata; std::vector<std::unique_ptr<tflite::SignatureDefT>> signature_defs; ModelT() : version(0) { } }; struct Model FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef ModelT NativeTableType; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_VERSION = 4, VT_OPERATOR_CODES = 6, VT_SUBGRAPHS = 8, VT_DESCRIPTION = 10, VT_BUFFERS = 12, VT_METADATA_BUFFER = 14, VT_METADATA = 16, VT_SIGNATURE_DEFS = 18 }; uint32_t version() const { return GetField<uint32_t>(VT_VERSION, 0); } const flatbuffers::Vector<flatbuffers::Offset<tflite::OperatorCode>> *operator_codes() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::OperatorCode>> *>(VT_OPERATOR_CODES); } const flatbuffers::Vector<flatbuffers::Offset<tflite::SubGraph>> *subgraphs() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::SubGraph>> *>(VT_SUBGRAPHS); } const flatbuffers::String *description() const { return GetPointer<const flatbuffers::String *>(VT_DESCRIPTION); } const flatbuffers::Vector<flatbuffers::Offset<tflite::Buffer>> *buffers() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::Buffer>> *>(VT_BUFFERS); } const flatbuffers::Vector<int32_t> *metadata_buffer() const { return GetPointer<const flatbuffers::Vector<int32_t> *>(VT_METADATA_BUFFER); } const flatbuffers::Vector<flatbuffers::Offset<tflite::Metadata>> *metadata() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::Metadata>> *>(VT_METADATA); } const flatbuffers::Vector<flatbuffers::Offset<tflite::SignatureDef>> *signature_defs() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<tflite::SignatureDef>> *>(VT_SIGNATURE_DEFS); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<uint32_t>(verifier, VT_VERSION) && VerifyOffset(verifier, VT_OPERATOR_CODES) && verifier.VerifyVector(operator_codes()) && verifier.VerifyVectorOfTables(operator_codes()) && VerifyOffset(verifier, VT_SUBGRAPHS) && verifier.VerifyVector(subgraphs()) && verifier.VerifyVectorOfTables(subgraphs()) && VerifyOffset(verifier, VT_DESCRIPTION) && verifier.VerifyString(description()) && VerifyOffset(verifier, VT_BUFFERS) && verifier.VerifyVector(buffers()) && verifier.VerifyVectorOfTables(buffers()) && VerifyOffset(verifier, VT_METADATA_BUFFER) && verifier.VerifyVector(metadata_buffer()) && VerifyOffset(verifier, VT_METADATA) && verifier.VerifyVector(metadata()) && verifier.VerifyVectorOfTables(metadata()) && VerifyOffset(verifier, VT_SIGNATURE_DEFS) && verifier.VerifyVector(signature_defs()) && verifier.VerifyVectorOfTables(signature_defs()) && verifier.EndTable(); } ModelT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; void UnPackTo(ModelT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; static flatbuffers::Offset<Model> Pack(flatbuffers::FlatBufferBuilder &_fbb, const ModelT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); }; struct ModelBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_version(uint32_t version) { fbb_.AddElement<uint32_t>(Model::VT_VERSION, version, 0); } void add_operator_codes(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::OperatorCode>>> operator_codes) { fbb_.AddOffset(Model::VT_OPERATOR_CODES, operator_codes); } void add_subgraphs(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::SubGraph>>> subgraphs) { fbb_.AddOffset(Model::VT_SUBGRAPHS, subgraphs); } void add_description(flatbuffers::Offset<flatbuffers::String> description) { fbb_.AddOffset(Model::VT_DESCRIPTION, description); } void add_buffers(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Buffer>>> buffers) { fbb_.AddOffset(Model::VT_BUFFERS, buffers); } void add_metadata_buffer(flatbuffers::Offset<flatbuffers::Vector<int32_t>> metadata_buffer) { fbb_.AddOffset(Model::VT_METADATA_BUFFER, metadata_buffer); } void add_metadata(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Metadata>>> metadata) { fbb_.AddOffset(Model::VT_METADATA, metadata); } void add_signature_defs(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::SignatureDef>>> signature_defs) { fbb_.AddOffset(Model::VT_SIGNATURE_DEFS, signature_defs); } explicit ModelBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ModelBuilder &operator=(const ModelBuilder &); flatbuffers::Offset<Model> Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset<Model>(end); return o; } }; inline flatbuffers::Offset<Model> CreateModel( flatbuffers::FlatBufferBuilder &_fbb, uint32_t version = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::OperatorCode>>> operator_codes = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::SubGraph>>> subgraphs = 0, flatbuffers::Offset<flatbuffers::String> description = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Buffer>>> buffers = 0, flatbuffers::Offset<flatbuffers::Vector<int32_t>> metadata_buffer = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::Metadata>>> metadata = 0, flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<tflite::SignatureDef>>> signature_defs = 0) { ModelBuilder builder_(_fbb); builder_.add_signature_defs(signature_defs); builder_.add_metadata(metadata); builder_.add_metadata_buffer(metadata_buffer); builder_.add_buffers(buffers); builder_.add_description(description); builder_.add_subgraphs(subgraphs); builder_.add_operator_codes(operator_codes); builder_.add_version(version); return builder_.Finish(); } inline flatbuffers::Offset<Model> CreateModelDirect( flatbuffers::FlatBufferBuilder &_fbb, uint32_t version = 0, const std::vector<flatbuffers::Offset<tflite::OperatorCode>> *operator_codes = nullptr, const std::vector<flatbuffers::Offset<tflite::SubGraph>> *subgraphs = nullptr, const char *description = nullptr, const std::vector<flatbuffers::Offset<tflite::Buffer>> *buffers = nullptr, const std::vector<int32_t> *metadata_buffer = nullptr, const std::vector<flatbuffers::Offset<tflite::Metadata>> *metadata = nullptr, const std::vector<flatbuffers::Offset<tflite::SignatureDef>> *signature_defs = nullptr) { auto operator_codes__ = operator_codes ? _fbb.CreateVector<flatbuffers::Offset<tflite::OperatorCode>>(*operator_codes) : 0; auto subgraphs__ = subgraphs ? _fbb.CreateVector<flatbuffers::Offset<tflite::SubGraph>>(*subgraphs) : 0; auto description__ = description ? _fbb.CreateString(description) : 0; auto buffers__ = buffers ? _fbb.CreateVector<flatbuffers::Offset<tflite::Buffer>>(*buffers) : 0; auto metadata_buffer__ = metadata_buffer ? _fbb.CreateVector<int32_t>(*metadata_buffer) : 0; auto metadata__ = metadata ? _fbb.CreateVector<flatbuffers::Offset<tflite::Metadata>>(*metadata) : 0; auto signature_defs__ = signature_defs ? _fbb.CreateVector<flatbuffers::Offset<tflite::SignatureDef>>(*signature_defs) : 0; return tflite::CreateModel( _fbb, version, operator_codes__, subgraphs__, description__, buffers__, metadata_buffer__, metadata__, signature_defs__); } flatbuffers::Offset<Model> CreateModel(flatbuffers::FlatBufferBuilder &_fbb, const ModelT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); inline CustomQuantizationT *CustomQuantization::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new CustomQuantizationT(); UnPackTo(_o, _resolver); return _o; } inline void CustomQuantization::UnPackTo(CustomQuantizationT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = custom(); if (_e) { _o->custom.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->custom.begin()); } } } inline flatbuffers::Offset<CustomQuantization> CustomQuantization::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CustomQuantizationT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateCustomQuantization(_fbb, _o, _rehasher); } inline flatbuffers::Offset<CustomQuantization> CreateCustomQuantization(flatbuffers::FlatBufferBuilder &_fbb, const CustomQuantizationT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const CustomQuantizationT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; _fbb.ForceVectorAlignment(_o->custom.size(), sizeof(uint8_t), 16); auto _custom = _o->custom.size() ? _fbb.CreateVector(_o->custom) : 0; return tflite::CreateCustomQuantization( _fbb, _custom); } inline QuantizationParametersT *QuantizationParameters::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new QuantizationParametersT(); UnPackTo(_o, _resolver); return _o; } inline void QuantizationParameters::UnPackTo(QuantizationParametersT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = min(); if (_e) { _o->min.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->min[_i] = _e->Get(_i); } } } { auto _e = max(); if (_e) { _o->max.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->max[_i] = _e->Get(_i); } } } { auto _e = scale(); if (_e) { _o->scale.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->scale[_i] = _e->Get(_i); } } } { auto _e = zero_point(); if (_e) { _o->zero_point.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->zero_point[_i] = _e->Get(_i); } } } { auto _e = details_type(); _o->details.type = _e; } { auto _e = details(); if (_e) _o->details.value = tflite::QuantizationDetailsUnion::UnPack(_e, details_type(), _resolver); } { auto _e = quantized_dimension(); _o->quantized_dimension = _e; } } inline flatbuffers::Offset<QuantizationParameters> QuantizationParameters::Pack(flatbuffers::FlatBufferBuilder &_fbb, const QuantizationParametersT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateQuantizationParameters(_fbb, _o, _rehasher); } inline flatbuffers::Offset<QuantizationParameters> CreateQuantizationParameters(flatbuffers::FlatBufferBuilder &_fbb, const QuantizationParametersT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const QuantizationParametersT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _min = _o->min.size() ? _fbb.CreateVector(_o->min) : 0; auto _max = _o->max.size() ? _fbb.CreateVector(_o->max) : 0; auto _scale = _o->scale.size() ? _fbb.CreateVector(_o->scale) : 0; auto _zero_point = _o->zero_point.size() ? _fbb.CreateVector(_o->zero_point) : 0; auto _details_type = _o->details.type; auto _details = _o->details.Pack(_fbb); auto _quantized_dimension = _o->quantized_dimension; return tflite::CreateQuantizationParameters( _fbb, _min, _max, _scale, _zero_point, _details_type, _details, _quantized_dimension); } inline Int32VectorT *Int32Vector::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Int32VectorT(); UnPackTo(_o, _resolver); return _o; } inline void Int32Vector::UnPackTo(Int32VectorT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = values(); if (_e) { _o->values.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->values[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<Int32Vector> Int32Vector::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Int32VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateInt32Vector(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Int32Vector> CreateInt32Vector(flatbuffers::FlatBufferBuilder &_fbb, const Int32VectorT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Int32VectorT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _values = _o->values.size() ? _fbb.CreateVector(_o->values) : 0; return tflite::CreateInt32Vector( _fbb, _values); } inline Uint16VectorT *Uint16Vector::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Uint16VectorT(); UnPackTo(_o, _resolver); return _o; } inline void Uint16Vector::UnPackTo(Uint16VectorT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = values(); if (_e) { _o->values.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->values[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<Uint16Vector> Uint16Vector::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Uint16VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateUint16Vector(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Uint16Vector> CreateUint16Vector(flatbuffers::FlatBufferBuilder &_fbb, const Uint16VectorT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Uint16VectorT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; _fbb.ForceVectorAlignment(_o->values.size(), sizeof(uint16_t), 4); auto _values = _o->values.size() ? _fbb.CreateVector(_o->values) : 0; return tflite::CreateUint16Vector( _fbb, _values); } inline Uint8VectorT *Uint8Vector::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Uint8VectorT(); UnPackTo(_o, _resolver); return _o; } inline void Uint8Vector::UnPackTo(Uint8VectorT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = values(); if (_e) { _o->values.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->values.begin()); } } } inline flatbuffers::Offset<Uint8Vector> Uint8Vector::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Uint8VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateUint8Vector(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Uint8Vector> CreateUint8Vector(flatbuffers::FlatBufferBuilder &_fbb, const Uint8VectorT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Uint8VectorT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; _fbb.ForceVectorAlignment(_o->values.size(), sizeof(uint8_t), 4); auto _values = _o->values.size() ? _fbb.CreateVector(_o->values) : 0; return tflite::CreateUint8Vector( _fbb, _values); } inline DimensionMetadataT *DimensionMetadata::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new DimensionMetadataT(); UnPackTo(_o, _resolver); return _o; } inline void DimensionMetadata::UnPackTo(DimensionMetadataT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = format(); _o->format = _e; } { auto _e = dense_size(); _o->dense_size = _e; } { auto _e = array_segments_type(); _o->array_segments.type = _e; } { auto _e = array_segments(); if (_e) _o->array_segments.value = tflite::SparseIndexVectorUnion::UnPack(_e, array_segments_type(), _resolver); } { auto _e = array_indices_type(); _o->array_indices.type = _e; } { auto _e = array_indices(); if (_e) _o->array_indices.value = tflite::SparseIndexVectorUnion::UnPack(_e, array_indices_type(), _resolver); } } inline flatbuffers::Offset<DimensionMetadata> DimensionMetadata::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DimensionMetadataT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateDimensionMetadata(_fbb, _o, _rehasher); } inline flatbuffers::Offset<DimensionMetadata> CreateDimensionMetadata(flatbuffers::FlatBufferBuilder &_fbb, const DimensionMetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DimensionMetadataT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _format = _o->format; auto _dense_size = _o->dense_size; auto _array_segments_type = _o->array_segments.type; auto _array_segments = _o->array_segments.Pack(_fbb); auto _array_indices_type = _o->array_indices.type; auto _array_indices = _o->array_indices.Pack(_fbb); return tflite::CreateDimensionMetadata( _fbb, _format, _dense_size, _array_segments_type, _array_segments, _array_indices_type, _array_indices); } inline SparsityParametersT *SparsityParameters::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SparsityParametersT(); UnPackTo(_o, _resolver); return _o; } inline void SparsityParameters::UnPackTo(SparsityParametersT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = traversal_order(); if (_e) { _o->traversal_order.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->traversal_order[_i] = _e->Get(_i); } } } { auto _e = block_map(); if (_e) { _o->block_map.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->block_map[_i] = _e->Get(_i); } } } { auto _e = dim_metadata(); if (_e) { _o->dim_metadata.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->dim_metadata[_i] = std::unique_ptr<tflite::DimensionMetadataT>(_e->Get(_i)->UnPack(_resolver)); } } } } inline flatbuffers::Offset<SparsityParameters> SparsityParameters::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SparsityParametersT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSparsityParameters(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SparsityParameters> CreateSparsityParameters(flatbuffers::FlatBufferBuilder &_fbb, const SparsityParametersT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SparsityParametersT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _traversal_order = _o->traversal_order.size() ? _fbb.CreateVector(_o->traversal_order) : 0; auto _block_map = _o->block_map.size() ? _fbb.CreateVector(_o->block_map) : 0; auto _dim_metadata = _o->dim_metadata.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::DimensionMetadata>> (_o->dim_metadata.size(), [](size_t i, _VectorArgs *__va) { return CreateDimensionMetadata(*__va->__fbb, __va->__o->dim_metadata[i].get(), __va->__rehasher); }, &_va ) : 0; return tflite::CreateSparsityParameters( _fbb, _traversal_order, _block_map, _dim_metadata); } inline TensorT *Tensor::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new TensorT(); UnPackTo(_o, _resolver); return _o; } inline void Tensor::UnPackTo(TensorT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = shape(); if (_e) { _o->shape.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->shape[_i] = _e->Get(_i); } } } { auto _e = type(); _o->type = _e; } { auto _e = buffer(); _o->buffer = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } { auto _e = quantization(); if (_e) _o->quantization = std::unique_ptr<tflite::QuantizationParametersT>(_e->UnPack(_resolver)); } { auto _e = is_variable(); _o->is_variable = _e; } { auto _e = sparsity(); if (_e) _o->sparsity = std::unique_ptr<tflite::SparsityParametersT>(_e->UnPack(_resolver)); } { auto _e = shape_signature(); if (_e) { _o->shape_signature.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->shape_signature[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<Tensor> Tensor::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TensorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateTensor(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Tensor> CreateTensor(flatbuffers::FlatBufferBuilder &_fbb, const TensorT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TensorT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _shape = _o->shape.size() ? _fbb.CreateVector(_o->shape) : 0; auto _type = _o->type; auto _buffer = _o->buffer; auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name); auto _quantization = _o->quantization ? CreateQuantizationParameters(_fbb, _o->quantization.get(), _rehasher) : 0; auto _is_variable = _o->is_variable; auto _sparsity = _o->sparsity ? CreateSparsityParameters(_fbb, _o->sparsity.get(), _rehasher) : 0; auto _shape_signature = _o->shape_signature.size() ? _fbb.CreateVector(_o->shape_signature) : 0; return tflite::CreateTensor( _fbb, _shape, _type, _buffer, _name, _quantization, _is_variable, _sparsity, _shape_signature); } inline Conv2DOptionsT *Conv2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Conv2DOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void Conv2DOptions::UnPackTo(Conv2DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = padding(); _o->padding = _e; } { auto _e = stride_w(); _o->stride_w = _e; } { auto _e = stride_h(); _o->stride_h = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = dilation_w_factor(); _o->dilation_w_factor = _e; } { auto _e = dilation_h_factor(); _o->dilation_h_factor = _e; } } inline flatbuffers::Offset<Conv2DOptions> Conv2DOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Conv2DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateConv2DOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Conv2DOptions> CreateConv2DOptions(flatbuffers::FlatBufferBuilder &_fbb, const Conv2DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Conv2DOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _padding = _o->padding; auto _stride_w = _o->stride_w; auto _stride_h = _o->stride_h; auto _fused_activation_function = _o->fused_activation_function; auto _dilation_w_factor = _o->dilation_w_factor; auto _dilation_h_factor = _o->dilation_h_factor; return tflite::CreateConv2DOptions( _fbb, _padding, _stride_w, _stride_h, _fused_activation_function, _dilation_w_factor, _dilation_h_factor); } inline Conv3DOptionsT *Conv3DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Conv3DOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void Conv3DOptions::UnPackTo(Conv3DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = padding(); _o->padding = _e; } { auto _e = stride_d(); _o->stride_d = _e; } { auto _e = stride_w(); _o->stride_w = _e; } { auto _e = stride_h(); _o->stride_h = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = dilation_d_factor(); _o->dilation_d_factor = _e; } { auto _e = dilation_w_factor(); _o->dilation_w_factor = _e; } { auto _e = dilation_h_factor(); _o->dilation_h_factor = _e; } } inline flatbuffers::Offset<Conv3DOptions> Conv3DOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Conv3DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateConv3DOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Conv3DOptions> CreateConv3DOptions(flatbuffers::FlatBufferBuilder &_fbb, const Conv3DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Conv3DOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _padding = _o->padding; auto _stride_d = _o->stride_d; auto _stride_w = _o->stride_w; auto _stride_h = _o->stride_h; auto _fused_activation_function = _o->fused_activation_function; auto _dilation_d_factor = _o->dilation_d_factor; auto _dilation_w_factor = _o->dilation_w_factor; auto _dilation_h_factor = _o->dilation_h_factor; return tflite::CreateConv3DOptions( _fbb, _padding, _stride_d, _stride_w, _stride_h, _fused_activation_function, _dilation_d_factor, _dilation_w_factor, _dilation_h_factor); } inline Pool2DOptionsT *Pool2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Pool2DOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void Pool2DOptions::UnPackTo(Pool2DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = padding(); _o->padding = _e; } { auto _e = stride_w(); _o->stride_w = _e; } { auto _e = stride_h(); _o->stride_h = _e; } { auto _e = filter_width(); _o->filter_width = _e; } { auto _e = filter_height(); _o->filter_height = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } } inline flatbuffers::Offset<Pool2DOptions> Pool2DOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Pool2DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreatePool2DOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Pool2DOptions> CreatePool2DOptions(flatbuffers::FlatBufferBuilder &_fbb, const Pool2DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Pool2DOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _padding = _o->padding; auto _stride_w = _o->stride_w; auto _stride_h = _o->stride_h; auto _filter_width = _o->filter_width; auto _filter_height = _o->filter_height; auto _fused_activation_function = _o->fused_activation_function; return tflite::CreatePool2DOptions( _fbb, _padding, _stride_w, _stride_h, _filter_width, _filter_height, _fused_activation_function); } inline DepthwiseConv2DOptionsT *DepthwiseConv2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new DepthwiseConv2DOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void DepthwiseConv2DOptions::UnPackTo(DepthwiseConv2DOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = padding(); _o->padding = _e; } { auto _e = stride_w(); _o->stride_w = _e; } { auto _e = stride_h(); _o->stride_h = _e; } { auto _e = depth_multiplier(); _o->depth_multiplier = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = dilation_w_factor(); _o->dilation_w_factor = _e; } { auto _e = dilation_h_factor(); _o->dilation_h_factor = _e; } } inline flatbuffers::Offset<DepthwiseConv2DOptions> DepthwiseConv2DOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DepthwiseConv2DOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateDepthwiseConv2DOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<DepthwiseConv2DOptions> CreateDepthwiseConv2DOptions(flatbuffers::FlatBufferBuilder &_fbb, const DepthwiseConv2DOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DepthwiseConv2DOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _padding = _o->padding; auto _stride_w = _o->stride_w; auto _stride_h = _o->stride_h; auto _depth_multiplier = _o->depth_multiplier; auto _fused_activation_function = _o->fused_activation_function; auto _dilation_w_factor = _o->dilation_w_factor; auto _dilation_h_factor = _o->dilation_h_factor; return tflite::CreateDepthwiseConv2DOptions( _fbb, _padding, _stride_w, _stride_h, _depth_multiplier, _fused_activation_function, _dilation_w_factor, _dilation_h_factor); } inline ConcatEmbeddingsOptionsT *ConcatEmbeddingsOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ConcatEmbeddingsOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ConcatEmbeddingsOptions::UnPackTo(ConcatEmbeddingsOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = num_channels(); _o->num_channels = _e; } { auto _e = num_columns_per_channel(); if (_e) { _o->num_columns_per_channel.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->num_columns_per_channel[_i] = _e->Get(_i); } } } { auto _e = embedding_dim_per_channel(); if (_e) { _o->embedding_dim_per_channel.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->embedding_dim_per_channel[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<ConcatEmbeddingsOptions> ConcatEmbeddingsOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ConcatEmbeddingsOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateConcatEmbeddingsOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ConcatEmbeddingsOptions> CreateConcatEmbeddingsOptions(flatbuffers::FlatBufferBuilder &_fbb, const ConcatEmbeddingsOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ConcatEmbeddingsOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _num_channels = _o->num_channels; auto _num_columns_per_channel = _o->num_columns_per_channel.size() ? _fbb.CreateVector(_o->num_columns_per_channel) : 0; auto _embedding_dim_per_channel = _o->embedding_dim_per_channel.size() ? _fbb.CreateVector(_o->embedding_dim_per_channel) : 0; return tflite::CreateConcatEmbeddingsOptions( _fbb, _num_channels, _num_columns_per_channel, _embedding_dim_per_channel); } inline LSHProjectionOptionsT *LSHProjectionOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LSHProjectionOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LSHProjectionOptions::UnPackTo(LSHProjectionOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = type(); _o->type = _e; } } inline flatbuffers::Offset<LSHProjectionOptions> LSHProjectionOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LSHProjectionOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLSHProjectionOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LSHProjectionOptions> CreateLSHProjectionOptions(flatbuffers::FlatBufferBuilder &_fbb, const LSHProjectionOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LSHProjectionOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _type = _o->type; return tflite::CreateLSHProjectionOptions( _fbb, _type); } inline SVDFOptionsT *SVDFOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SVDFOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SVDFOptions::UnPackTo(SVDFOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = rank(); _o->rank = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<SVDFOptions> SVDFOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SVDFOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSVDFOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SVDFOptions> CreateSVDFOptions(flatbuffers::FlatBufferBuilder &_fbb, const SVDFOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SVDFOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _rank = _o->rank; auto _fused_activation_function = _o->fused_activation_function; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateSVDFOptions( _fbb, _rank, _fused_activation_function, _asymmetric_quantize_inputs); } inline RNNOptionsT *RNNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new RNNOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void RNNOptions::UnPackTo(RNNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<RNNOptions> RNNOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const RNNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateRNNOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<RNNOptions> CreateRNNOptions(flatbuffers::FlatBufferBuilder &_fbb, const RNNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const RNNOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateRNNOptions( _fbb, _fused_activation_function, _asymmetric_quantize_inputs); } inline SequenceRNNOptionsT *SequenceRNNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SequenceRNNOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SequenceRNNOptions::UnPackTo(SequenceRNNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = time_major(); _o->time_major = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<SequenceRNNOptions> SequenceRNNOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SequenceRNNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSequenceRNNOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SequenceRNNOptions> CreateSequenceRNNOptions(flatbuffers::FlatBufferBuilder &_fbb, const SequenceRNNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SequenceRNNOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _time_major = _o->time_major; auto _fused_activation_function = _o->fused_activation_function; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateSequenceRNNOptions( _fbb, _time_major, _fused_activation_function, _asymmetric_quantize_inputs); } inline BidirectionalSequenceRNNOptionsT *BidirectionalSequenceRNNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new BidirectionalSequenceRNNOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void BidirectionalSequenceRNNOptions::UnPackTo(BidirectionalSequenceRNNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = time_major(); _o->time_major = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = merge_outputs(); _o->merge_outputs = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<BidirectionalSequenceRNNOptions> BidirectionalSequenceRNNOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceRNNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateBidirectionalSequenceRNNOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<BidirectionalSequenceRNNOptions> CreateBidirectionalSequenceRNNOptions(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceRNNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const BidirectionalSequenceRNNOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _time_major = _o->time_major; auto _fused_activation_function = _o->fused_activation_function; auto _merge_outputs = _o->merge_outputs; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateBidirectionalSequenceRNNOptions( _fbb, _time_major, _fused_activation_function, _merge_outputs, _asymmetric_quantize_inputs); } inline FullyConnectedOptionsT *FullyConnectedOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new FullyConnectedOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void FullyConnectedOptions::UnPackTo(FullyConnectedOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = weights_format(); _o->weights_format = _e; } { auto _e = keep_num_dims(); _o->keep_num_dims = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<FullyConnectedOptions> FullyConnectedOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FullyConnectedOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateFullyConnectedOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<FullyConnectedOptions> CreateFullyConnectedOptions(flatbuffers::FlatBufferBuilder &_fbb, const FullyConnectedOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const FullyConnectedOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _weights_format = _o->weights_format; auto _keep_num_dims = _o->keep_num_dims; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateFullyConnectedOptions( _fbb, _fused_activation_function, _weights_format, _keep_num_dims, _asymmetric_quantize_inputs); } inline SoftmaxOptionsT *SoftmaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SoftmaxOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SoftmaxOptions::UnPackTo(SoftmaxOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = beta(); _o->beta = _e; } } inline flatbuffers::Offset<SoftmaxOptions> SoftmaxOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SoftmaxOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSoftmaxOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SoftmaxOptions> CreateSoftmaxOptions(flatbuffers::FlatBufferBuilder &_fbb, const SoftmaxOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SoftmaxOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _beta = _o->beta; return tflite::CreateSoftmaxOptions( _fbb, _beta); } inline ConcatenationOptionsT *ConcatenationOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ConcatenationOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ConcatenationOptions::UnPackTo(ConcatenationOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = axis(); _o->axis = _e; } { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } } inline flatbuffers::Offset<ConcatenationOptions> ConcatenationOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ConcatenationOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateConcatenationOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ConcatenationOptions> CreateConcatenationOptions(flatbuffers::FlatBufferBuilder &_fbb, const ConcatenationOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ConcatenationOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _axis = _o->axis; auto _fused_activation_function = _o->fused_activation_function; return tflite::CreateConcatenationOptions( _fbb, _axis, _fused_activation_function); } inline AddOptionsT *AddOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new AddOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void AddOptions::UnPackTo(AddOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = pot_scale_int16(); _o->pot_scale_int16 = _e; } } inline flatbuffers::Offset<AddOptions> AddOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AddOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateAddOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<AddOptions> CreateAddOptions(flatbuffers::FlatBufferBuilder &_fbb, const AddOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const AddOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _pot_scale_int16 = _o->pot_scale_int16; return tflite::CreateAddOptions( _fbb, _fused_activation_function, _pot_scale_int16); } inline MulOptionsT *MulOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new MulOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void MulOptions::UnPackTo(MulOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } } inline flatbuffers::Offset<MulOptions> MulOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MulOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateMulOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<MulOptions> CreateMulOptions(flatbuffers::FlatBufferBuilder &_fbb, const MulOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MulOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; return tflite::CreateMulOptions( _fbb, _fused_activation_function); } inline L2NormOptionsT *L2NormOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new L2NormOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void L2NormOptions::UnPackTo(L2NormOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } } inline flatbuffers::Offset<L2NormOptions> L2NormOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const L2NormOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateL2NormOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<L2NormOptions> CreateL2NormOptions(flatbuffers::FlatBufferBuilder &_fbb, const L2NormOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const L2NormOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; return tflite::CreateL2NormOptions( _fbb, _fused_activation_function); } inline LocalResponseNormalizationOptionsT *LocalResponseNormalizationOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LocalResponseNormalizationOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LocalResponseNormalizationOptions::UnPackTo(LocalResponseNormalizationOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = radius(); _o->radius = _e; } { auto _e = bias(); _o->bias = _e; } { auto _e = alpha(); _o->alpha = _e; } { auto _e = beta(); _o->beta = _e; } } inline flatbuffers::Offset<LocalResponseNormalizationOptions> LocalResponseNormalizationOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LocalResponseNormalizationOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLocalResponseNormalizationOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LocalResponseNormalizationOptions> CreateLocalResponseNormalizationOptions(flatbuffers::FlatBufferBuilder &_fbb, const LocalResponseNormalizationOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LocalResponseNormalizationOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _radius = _o->radius; auto _bias = _o->bias; auto _alpha = _o->alpha; auto _beta = _o->beta; return tflite::CreateLocalResponseNormalizationOptions( _fbb, _radius, _bias, _alpha, _beta); } inline LSTMOptionsT *LSTMOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LSTMOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LSTMOptions::UnPackTo(LSTMOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = cell_clip(); _o->cell_clip = _e; } { auto _e = proj_clip(); _o->proj_clip = _e; } { auto _e = kernel_type(); _o->kernel_type = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<LSTMOptions> LSTMOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LSTMOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLSTMOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LSTMOptions> CreateLSTMOptions(flatbuffers::FlatBufferBuilder &_fbb, const LSTMOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LSTMOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _cell_clip = _o->cell_clip; auto _proj_clip = _o->proj_clip; auto _kernel_type = _o->kernel_type; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateLSTMOptions( _fbb, _fused_activation_function, _cell_clip, _proj_clip, _kernel_type, _asymmetric_quantize_inputs); } inline UnidirectionalSequenceLSTMOptionsT *UnidirectionalSequenceLSTMOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new UnidirectionalSequenceLSTMOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void UnidirectionalSequenceLSTMOptions::UnPackTo(UnidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = cell_clip(); _o->cell_clip = _e; } { auto _e = proj_clip(); _o->proj_clip = _e; } { auto _e = time_major(); _o->time_major = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<UnidirectionalSequenceLSTMOptions> UnidirectionalSequenceLSTMOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const UnidirectionalSequenceLSTMOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateUnidirectionalSequenceLSTMOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<UnidirectionalSequenceLSTMOptions> CreateUnidirectionalSequenceLSTMOptions(flatbuffers::FlatBufferBuilder &_fbb, const UnidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const UnidirectionalSequenceLSTMOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _cell_clip = _o->cell_clip; auto _proj_clip = _o->proj_clip; auto _time_major = _o->time_major; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateUnidirectionalSequenceLSTMOptions( _fbb, _fused_activation_function, _cell_clip, _proj_clip, _time_major, _asymmetric_quantize_inputs); } inline BidirectionalSequenceLSTMOptionsT *BidirectionalSequenceLSTMOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new BidirectionalSequenceLSTMOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void BidirectionalSequenceLSTMOptions::UnPackTo(BidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = cell_clip(); _o->cell_clip = _e; } { auto _e = proj_clip(); _o->proj_clip = _e; } { auto _e = merge_outputs(); _o->merge_outputs = _e; } { auto _e = time_major(); _o->time_major = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<BidirectionalSequenceLSTMOptions> BidirectionalSequenceLSTMOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceLSTMOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateBidirectionalSequenceLSTMOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<BidirectionalSequenceLSTMOptions> CreateBidirectionalSequenceLSTMOptions(flatbuffers::FlatBufferBuilder &_fbb, const BidirectionalSequenceLSTMOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const BidirectionalSequenceLSTMOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _cell_clip = _o->cell_clip; auto _proj_clip = _o->proj_clip; auto _merge_outputs = _o->merge_outputs; auto _time_major = _o->time_major; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateBidirectionalSequenceLSTMOptions( _fbb, _fused_activation_function, _cell_clip, _proj_clip, _merge_outputs, _time_major, _asymmetric_quantize_inputs); } inline ResizeBilinearOptionsT *ResizeBilinearOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ResizeBilinearOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ResizeBilinearOptions::UnPackTo(ResizeBilinearOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = align_corners(); _o->align_corners = _e; } { auto _e = half_pixel_centers(); _o->half_pixel_centers = _e; } } inline flatbuffers::Offset<ResizeBilinearOptions> ResizeBilinearOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ResizeBilinearOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateResizeBilinearOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ResizeBilinearOptions> CreateResizeBilinearOptions(flatbuffers::FlatBufferBuilder &_fbb, const ResizeBilinearOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ResizeBilinearOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _align_corners = _o->align_corners; auto _half_pixel_centers = _o->half_pixel_centers; return tflite::CreateResizeBilinearOptions( _fbb, _align_corners, _half_pixel_centers); } inline ResizeNearestNeighborOptionsT *ResizeNearestNeighborOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ResizeNearestNeighborOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ResizeNearestNeighborOptions::UnPackTo(ResizeNearestNeighborOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = align_corners(); _o->align_corners = _e; } { auto _e = half_pixel_centers(); _o->half_pixel_centers = _e; } } inline flatbuffers::Offset<ResizeNearestNeighborOptions> ResizeNearestNeighborOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ResizeNearestNeighborOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateResizeNearestNeighborOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ResizeNearestNeighborOptions> CreateResizeNearestNeighborOptions(flatbuffers::FlatBufferBuilder &_fbb, const ResizeNearestNeighborOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ResizeNearestNeighborOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _align_corners = _o->align_corners; auto _half_pixel_centers = _o->half_pixel_centers; return tflite::CreateResizeNearestNeighborOptions( _fbb, _align_corners, _half_pixel_centers); } inline CallOptionsT *CallOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new CallOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void CallOptions::UnPackTo(CallOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = subgraph(); _o->subgraph = _e; } } inline flatbuffers::Offset<CallOptions> CallOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CallOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateCallOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<CallOptions> CreateCallOptions(flatbuffers::FlatBufferBuilder &_fbb, const CallOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const CallOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _subgraph = _o->subgraph; return tflite::CreateCallOptions( _fbb, _subgraph); } inline PadOptionsT *PadOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new PadOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void PadOptions::UnPackTo(PadOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<PadOptions> PadOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const PadOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreatePadOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<PadOptions> CreatePadOptions(flatbuffers::FlatBufferBuilder &_fbb, const PadOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const PadOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreatePadOptions( _fbb); } inline PadV2OptionsT *PadV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new PadV2OptionsT(); UnPackTo(_o, _resolver); return _o; } inline void PadV2Options::UnPackTo(PadV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<PadV2Options> PadV2Options::Pack(flatbuffers::FlatBufferBuilder &_fbb, const PadV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreatePadV2Options(_fbb, _o, _rehasher); } inline flatbuffers::Offset<PadV2Options> CreatePadV2Options(flatbuffers::FlatBufferBuilder &_fbb, const PadV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const PadV2OptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreatePadV2Options( _fbb); } inline ReshapeOptionsT *ReshapeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ReshapeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ReshapeOptions::UnPackTo(ReshapeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = new_shape(); if (_e) { _o->new_shape.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->new_shape[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<ReshapeOptions> ReshapeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReshapeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateReshapeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ReshapeOptions> CreateReshapeOptions(flatbuffers::FlatBufferBuilder &_fbb, const ReshapeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReshapeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _new_shape = _o->new_shape.size() ? _fbb.CreateVector(_o->new_shape) : 0; return tflite::CreateReshapeOptions( _fbb, _new_shape); } inline SpaceToBatchNDOptionsT *SpaceToBatchNDOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SpaceToBatchNDOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SpaceToBatchNDOptions::UnPackTo(SpaceToBatchNDOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SpaceToBatchNDOptions> SpaceToBatchNDOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToBatchNDOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSpaceToBatchNDOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SpaceToBatchNDOptions> CreateSpaceToBatchNDOptions(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToBatchNDOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SpaceToBatchNDOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSpaceToBatchNDOptions( _fbb); } inline BatchToSpaceNDOptionsT *BatchToSpaceNDOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new BatchToSpaceNDOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void BatchToSpaceNDOptions::UnPackTo(BatchToSpaceNDOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<BatchToSpaceNDOptions> BatchToSpaceNDOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BatchToSpaceNDOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateBatchToSpaceNDOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<BatchToSpaceNDOptions> CreateBatchToSpaceNDOptions(flatbuffers::FlatBufferBuilder &_fbb, const BatchToSpaceNDOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const BatchToSpaceNDOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateBatchToSpaceNDOptions( _fbb); } inline SkipGramOptionsT *SkipGramOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SkipGramOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SkipGramOptions::UnPackTo(SkipGramOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = ngram_size(); _o->ngram_size = _e; } { auto _e = max_skip_size(); _o->max_skip_size = _e; } { auto _e = include_all_ngrams(); _o->include_all_ngrams = _e; } } inline flatbuffers::Offset<SkipGramOptions> SkipGramOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SkipGramOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSkipGramOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SkipGramOptions> CreateSkipGramOptions(flatbuffers::FlatBufferBuilder &_fbb, const SkipGramOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SkipGramOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _ngram_size = _o->ngram_size; auto _max_skip_size = _o->max_skip_size; auto _include_all_ngrams = _o->include_all_ngrams; return tflite::CreateSkipGramOptions( _fbb, _ngram_size, _max_skip_size, _include_all_ngrams); } inline SpaceToDepthOptionsT *SpaceToDepthOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SpaceToDepthOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SpaceToDepthOptions::UnPackTo(SpaceToDepthOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = block_size(); _o->block_size = _e; } } inline flatbuffers::Offset<SpaceToDepthOptions> SpaceToDepthOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToDepthOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSpaceToDepthOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SpaceToDepthOptions> CreateSpaceToDepthOptions(flatbuffers::FlatBufferBuilder &_fbb, const SpaceToDepthOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SpaceToDepthOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _block_size = _o->block_size; return tflite::CreateSpaceToDepthOptions( _fbb, _block_size); } inline DepthToSpaceOptionsT *DepthToSpaceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new DepthToSpaceOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void DepthToSpaceOptions::UnPackTo(DepthToSpaceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = block_size(); _o->block_size = _e; } } inline flatbuffers::Offset<DepthToSpaceOptions> DepthToSpaceOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DepthToSpaceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateDepthToSpaceOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<DepthToSpaceOptions> CreateDepthToSpaceOptions(flatbuffers::FlatBufferBuilder &_fbb, const DepthToSpaceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DepthToSpaceOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _block_size = _o->block_size; return tflite::CreateDepthToSpaceOptions( _fbb, _block_size); } inline SubOptionsT *SubOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SubOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SubOptions::UnPackTo(SubOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } { auto _e = pot_scale_int16(); _o->pot_scale_int16 = _e; } } inline flatbuffers::Offset<SubOptions> SubOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SubOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSubOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SubOptions> CreateSubOptions(flatbuffers::FlatBufferBuilder &_fbb, const SubOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SubOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; auto _pot_scale_int16 = _o->pot_scale_int16; return tflite::CreateSubOptions( _fbb, _fused_activation_function, _pot_scale_int16); } inline DivOptionsT *DivOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new DivOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void DivOptions::UnPackTo(DivOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = fused_activation_function(); _o->fused_activation_function = _e; } } inline flatbuffers::Offset<DivOptions> DivOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DivOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateDivOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<DivOptions> CreateDivOptions(flatbuffers::FlatBufferBuilder &_fbb, const DivOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DivOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _fused_activation_function = _o->fused_activation_function; return tflite::CreateDivOptions( _fbb, _fused_activation_function); } inline TopKV2OptionsT *TopKV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new TopKV2OptionsT(); UnPackTo(_o, _resolver); return _o; } inline void TopKV2Options::UnPackTo(TopKV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<TopKV2Options> TopKV2Options::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TopKV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateTopKV2Options(_fbb, _o, _rehasher); } inline flatbuffers::Offset<TopKV2Options> CreateTopKV2Options(flatbuffers::FlatBufferBuilder &_fbb, const TopKV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TopKV2OptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateTopKV2Options( _fbb); } inline EmbeddingLookupSparseOptionsT *EmbeddingLookupSparseOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new EmbeddingLookupSparseOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void EmbeddingLookupSparseOptions::UnPackTo(EmbeddingLookupSparseOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = combiner(); _o->combiner = _e; } } inline flatbuffers::Offset<EmbeddingLookupSparseOptions> EmbeddingLookupSparseOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const EmbeddingLookupSparseOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateEmbeddingLookupSparseOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<EmbeddingLookupSparseOptions> CreateEmbeddingLookupSparseOptions(flatbuffers::FlatBufferBuilder &_fbb, const EmbeddingLookupSparseOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const EmbeddingLookupSparseOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _combiner = _o->combiner; return tflite::CreateEmbeddingLookupSparseOptions( _fbb, _combiner); } inline GatherOptionsT *GatherOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new GatherOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void GatherOptions::UnPackTo(GatherOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = axis(); _o->axis = _e; } { auto _e = batch_dims(); _o->batch_dims = _e; } } inline flatbuffers::Offset<GatherOptions> GatherOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const GatherOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateGatherOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<GatherOptions> CreateGatherOptions(flatbuffers::FlatBufferBuilder &_fbb, const GatherOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const GatherOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _axis = _o->axis; auto _batch_dims = _o->batch_dims; return tflite::CreateGatherOptions( _fbb, _axis, _batch_dims); } inline TransposeOptionsT *TransposeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new TransposeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void TransposeOptions::UnPackTo(TransposeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<TransposeOptions> TransposeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TransposeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateTransposeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<TransposeOptions> CreateTransposeOptions(flatbuffers::FlatBufferBuilder &_fbb, const TransposeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TransposeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateTransposeOptions( _fbb); } inline ExpOptionsT *ExpOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ExpOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ExpOptions::UnPackTo(ExpOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<ExpOptions> ExpOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ExpOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateExpOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ExpOptions> CreateExpOptions(flatbuffers::FlatBufferBuilder &_fbb, const ExpOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ExpOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateExpOptions( _fbb); } inline CosOptionsT *CosOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new CosOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void CosOptions::UnPackTo(CosOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<CosOptions> CosOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CosOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateCosOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<CosOptions> CreateCosOptions(flatbuffers::FlatBufferBuilder &_fbb, const CosOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const CosOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateCosOptions( _fbb); } inline ReducerOptionsT *ReducerOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ReducerOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ReducerOptions::UnPackTo(ReducerOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = keep_dims(); _o->keep_dims = _e; } } inline flatbuffers::Offset<ReducerOptions> ReducerOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReducerOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateReducerOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ReducerOptions> CreateReducerOptions(flatbuffers::FlatBufferBuilder &_fbb, const ReducerOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReducerOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _keep_dims = _o->keep_dims; return tflite::CreateReducerOptions( _fbb, _keep_dims); } inline SqueezeOptionsT *SqueezeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SqueezeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SqueezeOptions::UnPackTo(SqueezeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = squeeze_dims(); if (_e) { _o->squeeze_dims.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->squeeze_dims[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<SqueezeOptions> SqueezeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SqueezeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSqueezeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SqueezeOptions> CreateSqueezeOptions(flatbuffers::FlatBufferBuilder &_fbb, const SqueezeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SqueezeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _squeeze_dims = _o->squeeze_dims.size() ? _fbb.CreateVector(_o->squeeze_dims) : 0; return tflite::CreateSqueezeOptions( _fbb, _squeeze_dims); } inline SplitOptionsT *SplitOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SplitOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SplitOptions::UnPackTo(SplitOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = num_splits(); _o->num_splits = _e; } } inline flatbuffers::Offset<SplitOptions> SplitOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SplitOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSplitOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SplitOptions> CreateSplitOptions(flatbuffers::FlatBufferBuilder &_fbb, const SplitOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SplitOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _num_splits = _o->num_splits; return tflite::CreateSplitOptions( _fbb, _num_splits); } inline SplitVOptionsT *SplitVOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SplitVOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SplitVOptions::UnPackTo(SplitVOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = num_splits(); _o->num_splits = _e; } } inline flatbuffers::Offset<SplitVOptions> SplitVOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SplitVOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSplitVOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SplitVOptions> CreateSplitVOptions(flatbuffers::FlatBufferBuilder &_fbb, const SplitVOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SplitVOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _num_splits = _o->num_splits; return tflite::CreateSplitVOptions( _fbb, _num_splits); } inline StridedSliceOptionsT *StridedSliceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new StridedSliceOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void StridedSliceOptions::UnPackTo(StridedSliceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = begin_mask(); _o->begin_mask = _e; } { auto _e = end_mask(); _o->end_mask = _e; } { auto _e = ellipsis_mask(); _o->ellipsis_mask = _e; } { auto _e = new_axis_mask(); _o->new_axis_mask = _e; } { auto _e = shrink_axis_mask(); _o->shrink_axis_mask = _e; } } inline flatbuffers::Offset<StridedSliceOptions> StridedSliceOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const StridedSliceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateStridedSliceOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<StridedSliceOptions> CreateStridedSliceOptions(flatbuffers::FlatBufferBuilder &_fbb, const StridedSliceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StridedSliceOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _begin_mask = _o->begin_mask; auto _end_mask = _o->end_mask; auto _ellipsis_mask = _o->ellipsis_mask; auto _new_axis_mask = _o->new_axis_mask; auto _shrink_axis_mask = _o->shrink_axis_mask; return tflite::CreateStridedSliceOptions( _fbb, _begin_mask, _end_mask, _ellipsis_mask, _new_axis_mask, _shrink_axis_mask); } inline LogSoftmaxOptionsT *LogSoftmaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LogSoftmaxOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LogSoftmaxOptions::UnPackTo(LogSoftmaxOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<LogSoftmaxOptions> LogSoftmaxOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogSoftmaxOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLogSoftmaxOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LogSoftmaxOptions> CreateLogSoftmaxOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogSoftmaxOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LogSoftmaxOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateLogSoftmaxOptions( _fbb); } inline CastOptionsT *CastOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new CastOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void CastOptions::UnPackTo(CastOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = in_data_type(); _o->in_data_type = _e; } { auto _e = out_data_type(); _o->out_data_type = _e; } } inline flatbuffers::Offset<CastOptions> CastOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CastOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateCastOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<CastOptions> CreateCastOptions(flatbuffers::FlatBufferBuilder &_fbb, const CastOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const CastOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _in_data_type = _o->in_data_type; auto _out_data_type = _o->out_data_type; return tflite::CreateCastOptions( _fbb, _in_data_type, _out_data_type); } inline DequantizeOptionsT *DequantizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new DequantizeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void DequantizeOptions::UnPackTo(DequantizeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<DequantizeOptions> DequantizeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DequantizeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateDequantizeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<DequantizeOptions> CreateDequantizeOptions(flatbuffers::FlatBufferBuilder &_fbb, const DequantizeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DequantizeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateDequantizeOptions( _fbb); } inline MaximumMinimumOptionsT *MaximumMinimumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new MaximumMinimumOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void MaximumMinimumOptions::UnPackTo(MaximumMinimumOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<MaximumMinimumOptions> MaximumMinimumOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MaximumMinimumOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateMaximumMinimumOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<MaximumMinimumOptions> CreateMaximumMinimumOptions(flatbuffers::FlatBufferBuilder &_fbb, const MaximumMinimumOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MaximumMinimumOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateMaximumMinimumOptions( _fbb); } inline TileOptionsT *TileOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new TileOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void TileOptions::UnPackTo(TileOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<TileOptions> TileOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TileOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateTileOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<TileOptions> CreateTileOptions(flatbuffers::FlatBufferBuilder &_fbb, const TileOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TileOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateTileOptions( _fbb); } inline ArgMaxOptionsT *ArgMaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ArgMaxOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ArgMaxOptions::UnPackTo(ArgMaxOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = output_type(); _o->output_type = _e; } } inline flatbuffers::Offset<ArgMaxOptions> ArgMaxOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ArgMaxOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateArgMaxOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ArgMaxOptions> CreateArgMaxOptions(flatbuffers::FlatBufferBuilder &_fbb, const ArgMaxOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ArgMaxOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _output_type = _o->output_type; return tflite::CreateArgMaxOptions( _fbb, _output_type); } inline ArgMinOptionsT *ArgMinOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ArgMinOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ArgMinOptions::UnPackTo(ArgMinOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = output_type(); _o->output_type = _e; } } inline flatbuffers::Offset<ArgMinOptions> ArgMinOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ArgMinOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateArgMinOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ArgMinOptions> CreateArgMinOptions(flatbuffers::FlatBufferBuilder &_fbb, const ArgMinOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ArgMinOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _output_type = _o->output_type; return tflite::CreateArgMinOptions( _fbb, _output_type); } inline GreaterOptionsT *GreaterOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new GreaterOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void GreaterOptions::UnPackTo(GreaterOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<GreaterOptions> GreaterOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const GreaterOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateGreaterOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<GreaterOptions> CreateGreaterOptions(flatbuffers::FlatBufferBuilder &_fbb, const GreaterOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const GreaterOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateGreaterOptions( _fbb); } inline GreaterEqualOptionsT *GreaterEqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new GreaterEqualOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void GreaterEqualOptions::UnPackTo(GreaterEqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<GreaterEqualOptions> GreaterEqualOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const GreaterEqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateGreaterEqualOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<GreaterEqualOptions> CreateGreaterEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const GreaterEqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const GreaterEqualOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateGreaterEqualOptions( _fbb); } inline LessOptionsT *LessOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LessOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LessOptions::UnPackTo(LessOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<LessOptions> LessOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LessOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLessOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LessOptions> CreateLessOptions(flatbuffers::FlatBufferBuilder &_fbb, const LessOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LessOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateLessOptions( _fbb); } inline LessEqualOptionsT *LessEqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LessEqualOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LessEqualOptions::UnPackTo(LessEqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<LessEqualOptions> LessEqualOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LessEqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLessEqualOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LessEqualOptions> CreateLessEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const LessEqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LessEqualOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateLessEqualOptions( _fbb); } inline NegOptionsT *NegOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new NegOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void NegOptions::UnPackTo(NegOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<NegOptions> NegOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const NegOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateNegOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<NegOptions> CreateNegOptions(flatbuffers::FlatBufferBuilder &_fbb, const NegOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const NegOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateNegOptions( _fbb); } inline SelectOptionsT *SelectOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SelectOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SelectOptions::UnPackTo(SelectOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SelectOptions> SelectOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SelectOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSelectOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SelectOptions> CreateSelectOptions(flatbuffers::FlatBufferBuilder &_fbb, const SelectOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SelectOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSelectOptions( _fbb); } inline SliceOptionsT *SliceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SliceOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SliceOptions::UnPackTo(SliceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SliceOptions> SliceOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SliceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSliceOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SliceOptions> CreateSliceOptions(flatbuffers::FlatBufferBuilder &_fbb, const SliceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SliceOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSliceOptions( _fbb); } inline TransposeConvOptionsT *TransposeConvOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new TransposeConvOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void TransposeConvOptions::UnPackTo(TransposeConvOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = padding(); _o->padding = _e; } { auto _e = stride_w(); _o->stride_w = _e; } { auto _e = stride_h(); _o->stride_h = _e; } } inline flatbuffers::Offset<TransposeConvOptions> TransposeConvOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TransposeConvOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateTransposeConvOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<TransposeConvOptions> CreateTransposeConvOptions(flatbuffers::FlatBufferBuilder &_fbb, const TransposeConvOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TransposeConvOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _padding = _o->padding; auto _stride_w = _o->stride_w; auto _stride_h = _o->stride_h; return tflite::CreateTransposeConvOptions( _fbb, _padding, _stride_w, _stride_h); } inline ExpandDimsOptionsT *ExpandDimsOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ExpandDimsOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ExpandDimsOptions::UnPackTo(ExpandDimsOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<ExpandDimsOptions> ExpandDimsOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ExpandDimsOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateExpandDimsOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ExpandDimsOptions> CreateExpandDimsOptions(flatbuffers::FlatBufferBuilder &_fbb, const ExpandDimsOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ExpandDimsOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateExpandDimsOptions( _fbb); } inline SparseToDenseOptionsT *SparseToDenseOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SparseToDenseOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SparseToDenseOptions::UnPackTo(SparseToDenseOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = validate_indices(); _o->validate_indices = _e; } } inline flatbuffers::Offset<SparseToDenseOptions> SparseToDenseOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SparseToDenseOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSparseToDenseOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SparseToDenseOptions> CreateSparseToDenseOptions(flatbuffers::FlatBufferBuilder &_fbb, const SparseToDenseOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SparseToDenseOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _validate_indices = _o->validate_indices; return tflite::CreateSparseToDenseOptions( _fbb, _validate_indices); } inline EqualOptionsT *EqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new EqualOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void EqualOptions::UnPackTo(EqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<EqualOptions> EqualOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const EqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateEqualOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<EqualOptions> CreateEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const EqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const EqualOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateEqualOptions( _fbb); } inline NotEqualOptionsT *NotEqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new NotEqualOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void NotEqualOptions::UnPackTo(NotEqualOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<NotEqualOptions> NotEqualOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const NotEqualOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateNotEqualOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<NotEqualOptions> CreateNotEqualOptions(flatbuffers::FlatBufferBuilder &_fbb, const NotEqualOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const NotEqualOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateNotEqualOptions( _fbb); } inline ShapeOptionsT *ShapeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ShapeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ShapeOptions::UnPackTo(ShapeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = out_type(); _o->out_type = _e; } } inline flatbuffers::Offset<ShapeOptions> ShapeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ShapeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateShapeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ShapeOptions> CreateShapeOptions(flatbuffers::FlatBufferBuilder &_fbb, const ShapeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ShapeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _out_type = _o->out_type; return tflite::CreateShapeOptions( _fbb, _out_type); } inline RankOptionsT *RankOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new RankOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void RankOptions::UnPackTo(RankOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<RankOptions> RankOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const RankOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateRankOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<RankOptions> CreateRankOptions(flatbuffers::FlatBufferBuilder &_fbb, const RankOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const RankOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateRankOptions( _fbb); } inline PowOptionsT *PowOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new PowOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void PowOptions::UnPackTo(PowOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<PowOptions> PowOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const PowOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreatePowOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<PowOptions> CreatePowOptions(flatbuffers::FlatBufferBuilder &_fbb, const PowOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const PowOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreatePowOptions( _fbb); } inline FakeQuantOptionsT *FakeQuantOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new FakeQuantOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void FakeQuantOptions::UnPackTo(FakeQuantOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = min(); _o->min = _e; } { auto _e = max(); _o->max = _e; } { auto _e = num_bits(); _o->num_bits = _e; } { auto _e = narrow_range(); _o->narrow_range = _e; } } inline flatbuffers::Offset<FakeQuantOptions> FakeQuantOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FakeQuantOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateFakeQuantOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<FakeQuantOptions> CreateFakeQuantOptions(flatbuffers::FlatBufferBuilder &_fbb, const FakeQuantOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const FakeQuantOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _min = _o->min; auto _max = _o->max; auto _num_bits = _o->num_bits; auto _narrow_range = _o->narrow_range; return tflite::CreateFakeQuantOptions( _fbb, _min, _max, _num_bits, _narrow_range); } inline PackOptionsT *PackOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new PackOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void PackOptions::UnPackTo(PackOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = values_count(); _o->values_count = _e; } { auto _e = axis(); _o->axis = _e; } } inline flatbuffers::Offset<PackOptions> PackOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const PackOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreatePackOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<PackOptions> CreatePackOptions(flatbuffers::FlatBufferBuilder &_fbb, const PackOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const PackOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _values_count = _o->values_count; auto _axis = _o->axis; return tflite::CreatePackOptions( _fbb, _values_count, _axis); } inline LogicalOrOptionsT *LogicalOrOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LogicalOrOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LogicalOrOptions::UnPackTo(LogicalOrOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<LogicalOrOptions> LogicalOrOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogicalOrOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLogicalOrOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LogicalOrOptions> CreateLogicalOrOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogicalOrOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LogicalOrOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateLogicalOrOptions( _fbb); } inline OneHotOptionsT *OneHotOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new OneHotOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void OneHotOptions::UnPackTo(OneHotOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = axis(); _o->axis = _e; } } inline flatbuffers::Offset<OneHotOptions> OneHotOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const OneHotOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateOneHotOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<OneHotOptions> CreateOneHotOptions(flatbuffers::FlatBufferBuilder &_fbb, const OneHotOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const OneHotOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _axis = _o->axis; return tflite::CreateOneHotOptions( _fbb, _axis); } inline AbsOptionsT *AbsOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new AbsOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void AbsOptions::UnPackTo(AbsOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<AbsOptions> AbsOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AbsOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateAbsOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<AbsOptions> CreateAbsOptions(flatbuffers::FlatBufferBuilder &_fbb, const AbsOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const AbsOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateAbsOptions( _fbb); } inline HardSwishOptionsT *HardSwishOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new HardSwishOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void HardSwishOptions::UnPackTo(HardSwishOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<HardSwishOptions> HardSwishOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const HardSwishOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateHardSwishOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<HardSwishOptions> CreateHardSwishOptions(flatbuffers::FlatBufferBuilder &_fbb, const HardSwishOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const HardSwishOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateHardSwishOptions( _fbb); } inline LogicalAndOptionsT *LogicalAndOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LogicalAndOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LogicalAndOptions::UnPackTo(LogicalAndOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<LogicalAndOptions> LogicalAndOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogicalAndOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLogicalAndOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LogicalAndOptions> CreateLogicalAndOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogicalAndOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LogicalAndOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateLogicalAndOptions( _fbb); } inline LogicalNotOptionsT *LogicalNotOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LogicalNotOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LogicalNotOptions::UnPackTo(LogicalNotOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<LogicalNotOptions> LogicalNotOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LogicalNotOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLogicalNotOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LogicalNotOptions> CreateLogicalNotOptions(flatbuffers::FlatBufferBuilder &_fbb, const LogicalNotOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LogicalNotOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateLogicalNotOptions( _fbb); } inline UnpackOptionsT *UnpackOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new UnpackOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void UnpackOptions::UnPackTo(UnpackOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = num(); _o->num = _e; } { auto _e = axis(); _o->axis = _e; } } inline flatbuffers::Offset<UnpackOptions> UnpackOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const UnpackOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateUnpackOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<UnpackOptions> CreateUnpackOptions(flatbuffers::FlatBufferBuilder &_fbb, const UnpackOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const UnpackOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _num = _o->num; auto _axis = _o->axis; return tflite::CreateUnpackOptions( _fbb, _num, _axis); } inline FloorDivOptionsT *FloorDivOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new FloorDivOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void FloorDivOptions::UnPackTo(FloorDivOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<FloorDivOptions> FloorDivOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FloorDivOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateFloorDivOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<FloorDivOptions> CreateFloorDivOptions(flatbuffers::FlatBufferBuilder &_fbb, const FloorDivOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const FloorDivOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateFloorDivOptions( _fbb); } inline SquareOptionsT *SquareOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SquareOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SquareOptions::UnPackTo(SquareOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SquareOptions> SquareOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SquareOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSquareOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SquareOptions> CreateSquareOptions(flatbuffers::FlatBufferBuilder &_fbb, const SquareOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SquareOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSquareOptions( _fbb); } inline ZerosLikeOptionsT *ZerosLikeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ZerosLikeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ZerosLikeOptions::UnPackTo(ZerosLikeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<ZerosLikeOptions> ZerosLikeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ZerosLikeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateZerosLikeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ZerosLikeOptions> CreateZerosLikeOptions(flatbuffers::FlatBufferBuilder &_fbb, const ZerosLikeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ZerosLikeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateZerosLikeOptions( _fbb); } inline FillOptionsT *FillOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new FillOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void FillOptions::UnPackTo(FillOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<FillOptions> FillOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FillOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateFillOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<FillOptions> CreateFillOptions(flatbuffers::FlatBufferBuilder &_fbb, const FillOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const FillOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateFillOptions( _fbb); } inline FloorModOptionsT *FloorModOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new FloorModOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void FloorModOptions::UnPackTo(FloorModOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<FloorModOptions> FloorModOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const FloorModOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateFloorModOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<FloorModOptions> CreateFloorModOptions(flatbuffers::FlatBufferBuilder &_fbb, const FloorModOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const FloorModOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateFloorModOptions( _fbb); } inline RangeOptionsT *RangeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new RangeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void RangeOptions::UnPackTo(RangeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<RangeOptions> RangeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const RangeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateRangeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<RangeOptions> CreateRangeOptions(flatbuffers::FlatBufferBuilder &_fbb, const RangeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const RangeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateRangeOptions( _fbb); } inline LeakyReluOptionsT *LeakyReluOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new LeakyReluOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void LeakyReluOptions::UnPackTo(LeakyReluOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = alpha(); _o->alpha = _e; } } inline flatbuffers::Offset<LeakyReluOptions> LeakyReluOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const LeakyReluOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateLeakyReluOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<LeakyReluOptions> CreateLeakyReluOptions(flatbuffers::FlatBufferBuilder &_fbb, const LeakyReluOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const LeakyReluOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _alpha = _o->alpha; return tflite::CreateLeakyReluOptions( _fbb, _alpha); } inline SquaredDifferenceOptionsT *SquaredDifferenceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SquaredDifferenceOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SquaredDifferenceOptions::UnPackTo(SquaredDifferenceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SquaredDifferenceOptions> SquaredDifferenceOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SquaredDifferenceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSquaredDifferenceOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SquaredDifferenceOptions> CreateSquaredDifferenceOptions(flatbuffers::FlatBufferBuilder &_fbb, const SquaredDifferenceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SquaredDifferenceOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSquaredDifferenceOptions( _fbb); } inline MirrorPadOptionsT *MirrorPadOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new MirrorPadOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void MirrorPadOptions::UnPackTo(MirrorPadOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = mode(); _o->mode = _e; } } inline flatbuffers::Offset<MirrorPadOptions> MirrorPadOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MirrorPadOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateMirrorPadOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<MirrorPadOptions> CreateMirrorPadOptions(flatbuffers::FlatBufferBuilder &_fbb, const MirrorPadOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MirrorPadOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _mode = _o->mode; return tflite::CreateMirrorPadOptions( _fbb, _mode); } inline UniqueOptionsT *UniqueOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new UniqueOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void UniqueOptions::UnPackTo(UniqueOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = idx_out_type(); _o->idx_out_type = _e; } } inline flatbuffers::Offset<UniqueOptions> UniqueOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const UniqueOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateUniqueOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<UniqueOptions> CreateUniqueOptions(flatbuffers::FlatBufferBuilder &_fbb, const UniqueOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const UniqueOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _idx_out_type = _o->idx_out_type; return tflite::CreateUniqueOptions( _fbb, _idx_out_type); } inline ReverseV2OptionsT *ReverseV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ReverseV2OptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ReverseV2Options::UnPackTo(ReverseV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<ReverseV2Options> ReverseV2Options::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReverseV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateReverseV2Options(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ReverseV2Options> CreateReverseV2Options(flatbuffers::FlatBufferBuilder &_fbb, const ReverseV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReverseV2OptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateReverseV2Options( _fbb); } inline AddNOptionsT *AddNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new AddNOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void AddNOptions::UnPackTo(AddNOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<AddNOptions> AddNOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const AddNOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateAddNOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<AddNOptions> CreateAddNOptions(flatbuffers::FlatBufferBuilder &_fbb, const AddNOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const AddNOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateAddNOptions( _fbb); } inline GatherNdOptionsT *GatherNdOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new GatherNdOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void GatherNdOptions::UnPackTo(GatherNdOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<GatherNdOptions> GatherNdOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const GatherNdOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateGatherNdOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<GatherNdOptions> CreateGatherNdOptions(flatbuffers::FlatBufferBuilder &_fbb, const GatherNdOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const GatherNdOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateGatherNdOptions( _fbb); } inline WhereOptionsT *WhereOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new WhereOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void WhereOptions::UnPackTo(WhereOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<WhereOptions> WhereOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const WhereOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateWhereOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<WhereOptions> CreateWhereOptions(flatbuffers::FlatBufferBuilder &_fbb, const WhereOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const WhereOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateWhereOptions( _fbb); } inline ReverseSequenceOptionsT *ReverseSequenceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ReverseSequenceOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ReverseSequenceOptions::UnPackTo(ReverseSequenceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = seq_dim(); _o->seq_dim = _e; } { auto _e = batch_dim(); _o->batch_dim = _e; } } inline flatbuffers::Offset<ReverseSequenceOptions> ReverseSequenceOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ReverseSequenceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateReverseSequenceOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ReverseSequenceOptions> CreateReverseSequenceOptions(flatbuffers::FlatBufferBuilder &_fbb, const ReverseSequenceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ReverseSequenceOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _seq_dim = _o->seq_dim; auto _batch_dim = _o->batch_dim; return tflite::CreateReverseSequenceOptions( _fbb, _seq_dim, _batch_dim); } inline MatrixDiagOptionsT *MatrixDiagOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new MatrixDiagOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void MatrixDiagOptions::UnPackTo(MatrixDiagOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<MatrixDiagOptions> MatrixDiagOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MatrixDiagOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateMatrixDiagOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<MatrixDiagOptions> CreateMatrixDiagOptions(flatbuffers::FlatBufferBuilder &_fbb, const MatrixDiagOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MatrixDiagOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateMatrixDiagOptions( _fbb); } inline QuantizeOptionsT *QuantizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new QuantizeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void QuantizeOptions::UnPackTo(QuantizeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<QuantizeOptions> QuantizeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const QuantizeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateQuantizeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<QuantizeOptions> CreateQuantizeOptions(flatbuffers::FlatBufferBuilder &_fbb, const QuantizeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const QuantizeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateQuantizeOptions( _fbb); } inline MatrixSetDiagOptionsT *MatrixSetDiagOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new MatrixSetDiagOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void MatrixSetDiagOptions::UnPackTo(MatrixSetDiagOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<MatrixSetDiagOptions> MatrixSetDiagOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MatrixSetDiagOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateMatrixSetDiagOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<MatrixSetDiagOptions> CreateMatrixSetDiagOptions(flatbuffers::FlatBufferBuilder &_fbb, const MatrixSetDiagOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MatrixSetDiagOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateMatrixSetDiagOptions( _fbb); } inline IfOptionsT *IfOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new IfOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void IfOptions::UnPackTo(IfOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = then_subgraph_index(); _o->then_subgraph_index = _e; } { auto _e = else_subgraph_index(); _o->else_subgraph_index = _e; } } inline flatbuffers::Offset<IfOptions> IfOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const IfOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateIfOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<IfOptions> CreateIfOptions(flatbuffers::FlatBufferBuilder &_fbb, const IfOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const IfOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _then_subgraph_index = _o->then_subgraph_index; auto _else_subgraph_index = _o->else_subgraph_index; return tflite::CreateIfOptions( _fbb, _then_subgraph_index, _else_subgraph_index); } inline CallOnceOptionsT *CallOnceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new CallOnceOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void CallOnceOptions::UnPackTo(CallOnceOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = init_subgraph_index(); _o->init_subgraph_index = _e; } } inline flatbuffers::Offset<CallOnceOptions> CallOnceOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CallOnceOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateCallOnceOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<CallOnceOptions> CreateCallOnceOptions(flatbuffers::FlatBufferBuilder &_fbb, const CallOnceOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const CallOnceOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _init_subgraph_index = _o->init_subgraph_index; return tflite::CreateCallOnceOptions( _fbb, _init_subgraph_index); } inline WhileOptionsT *WhileOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new WhileOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void WhileOptions::UnPackTo(WhileOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = cond_subgraph_index(); _o->cond_subgraph_index = _e; } { auto _e = body_subgraph_index(); _o->body_subgraph_index = _e; } } inline flatbuffers::Offset<WhileOptions> WhileOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const WhileOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateWhileOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<WhileOptions> CreateWhileOptions(flatbuffers::FlatBufferBuilder &_fbb, const WhileOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const WhileOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _cond_subgraph_index = _o->cond_subgraph_index; auto _body_subgraph_index = _o->body_subgraph_index; return tflite::CreateWhileOptions( _fbb, _cond_subgraph_index, _body_subgraph_index); } inline NonMaxSuppressionV4OptionsT *NonMaxSuppressionV4Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new NonMaxSuppressionV4OptionsT(); UnPackTo(_o, _resolver); return _o; } inline void NonMaxSuppressionV4Options::UnPackTo(NonMaxSuppressionV4OptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<NonMaxSuppressionV4Options> NonMaxSuppressionV4Options::Pack(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV4OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateNonMaxSuppressionV4Options(_fbb, _o, _rehasher); } inline flatbuffers::Offset<NonMaxSuppressionV4Options> CreateNonMaxSuppressionV4Options(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV4OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const NonMaxSuppressionV4OptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateNonMaxSuppressionV4Options( _fbb); } inline NonMaxSuppressionV5OptionsT *NonMaxSuppressionV5Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new NonMaxSuppressionV5OptionsT(); UnPackTo(_o, _resolver); return _o; } inline void NonMaxSuppressionV5Options::UnPackTo(NonMaxSuppressionV5OptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<NonMaxSuppressionV5Options> NonMaxSuppressionV5Options::Pack(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV5OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateNonMaxSuppressionV5Options(_fbb, _o, _rehasher); } inline flatbuffers::Offset<NonMaxSuppressionV5Options> CreateNonMaxSuppressionV5Options(flatbuffers::FlatBufferBuilder &_fbb, const NonMaxSuppressionV5OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const NonMaxSuppressionV5OptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateNonMaxSuppressionV5Options( _fbb); } inline ScatterNdOptionsT *ScatterNdOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ScatterNdOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void ScatterNdOptions::UnPackTo(ScatterNdOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<ScatterNdOptions> ScatterNdOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ScatterNdOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateScatterNdOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<ScatterNdOptions> CreateScatterNdOptions(flatbuffers::FlatBufferBuilder &_fbb, const ScatterNdOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ScatterNdOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateScatterNdOptions( _fbb); } inline SelectV2OptionsT *SelectV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SelectV2OptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SelectV2Options::UnPackTo(SelectV2OptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SelectV2Options> SelectV2Options::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SelectV2OptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSelectV2Options(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SelectV2Options> CreateSelectV2Options(flatbuffers::FlatBufferBuilder &_fbb, const SelectV2OptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SelectV2OptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSelectV2Options( _fbb); } inline DensifyOptionsT *DensifyOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new DensifyOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void DensifyOptions::UnPackTo(DensifyOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<DensifyOptions> DensifyOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const DensifyOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateDensifyOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<DensifyOptions> CreateDensifyOptions(flatbuffers::FlatBufferBuilder &_fbb, const DensifyOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const DensifyOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateDensifyOptions( _fbb); } inline SegmentSumOptionsT *SegmentSumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SegmentSumOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void SegmentSumOptions::UnPackTo(SegmentSumOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<SegmentSumOptions> SegmentSumOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SegmentSumOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSegmentSumOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SegmentSumOptions> CreateSegmentSumOptions(flatbuffers::FlatBufferBuilder &_fbb, const SegmentSumOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SegmentSumOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateSegmentSumOptions( _fbb); } inline BatchMatMulOptionsT *BatchMatMulOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new BatchMatMulOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void BatchMatMulOptions::UnPackTo(BatchMatMulOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = adj_x(); _o->adj_x = _e; } { auto _e = adj_y(); _o->adj_y = _e; } { auto _e = asymmetric_quantize_inputs(); _o->asymmetric_quantize_inputs = _e; } } inline flatbuffers::Offset<BatchMatMulOptions> BatchMatMulOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BatchMatMulOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateBatchMatMulOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<BatchMatMulOptions> CreateBatchMatMulOptions(flatbuffers::FlatBufferBuilder &_fbb, const BatchMatMulOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const BatchMatMulOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _adj_x = _o->adj_x; auto _adj_y = _o->adj_y; auto _asymmetric_quantize_inputs = _o->asymmetric_quantize_inputs; return tflite::CreateBatchMatMulOptions( _fbb, _adj_x, _adj_y, _asymmetric_quantize_inputs); } inline CumsumOptionsT *CumsumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new CumsumOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void CumsumOptions::UnPackTo(CumsumOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = exclusive(); _o->exclusive = _e; } { auto _e = reverse(); _o->reverse = _e; } } inline flatbuffers::Offset<CumsumOptions> CumsumOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CumsumOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateCumsumOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<CumsumOptions> CreateCumsumOptions(flatbuffers::FlatBufferBuilder &_fbb, const CumsumOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const CumsumOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _exclusive = _o->exclusive; auto _reverse = _o->reverse; return tflite::CreateCumsumOptions( _fbb, _exclusive, _reverse); } inline BroadcastToOptionsT *BroadcastToOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new BroadcastToOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void BroadcastToOptions::UnPackTo(BroadcastToOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<BroadcastToOptions> BroadcastToOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BroadcastToOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateBroadcastToOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<BroadcastToOptions> CreateBroadcastToOptions(flatbuffers::FlatBufferBuilder &_fbb, const BroadcastToOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const BroadcastToOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateBroadcastToOptions( _fbb); } inline Rfft2dOptionsT *Rfft2dOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new Rfft2dOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void Rfft2dOptions::UnPackTo(Rfft2dOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<Rfft2dOptions> Rfft2dOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Rfft2dOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateRfft2dOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Rfft2dOptions> CreateRfft2dOptions(flatbuffers::FlatBufferBuilder &_fbb, const Rfft2dOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const Rfft2dOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateRfft2dOptions( _fbb); } inline HashtableOptionsT *HashtableOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new HashtableOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void HashtableOptions::UnPackTo(HashtableOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = table_id(); _o->table_id = _e; } { auto _e = key_dtype(); _o->key_dtype = _e; } { auto _e = value_dtype(); _o->value_dtype = _e; } } inline flatbuffers::Offset<HashtableOptions> HashtableOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateHashtableOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<HashtableOptions> CreateHashtableOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const HashtableOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _table_id = _o->table_id; auto _key_dtype = _o->key_dtype; auto _value_dtype = _o->value_dtype; return tflite::CreateHashtableOptions( _fbb, _table_id, _key_dtype, _value_dtype); } inline HashtableFindOptionsT *HashtableFindOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new HashtableFindOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void HashtableFindOptions::UnPackTo(HashtableFindOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<HashtableFindOptions> HashtableFindOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableFindOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateHashtableFindOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<HashtableFindOptions> CreateHashtableFindOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableFindOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const HashtableFindOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateHashtableFindOptions( _fbb); } inline HashtableImportOptionsT *HashtableImportOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new HashtableImportOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void HashtableImportOptions::UnPackTo(HashtableImportOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<HashtableImportOptions> HashtableImportOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableImportOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateHashtableImportOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<HashtableImportOptions> CreateHashtableImportOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableImportOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const HashtableImportOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateHashtableImportOptions( _fbb); } inline HashtableSizeOptionsT *HashtableSizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new HashtableSizeOptionsT(); UnPackTo(_o, _resolver); return _o; } inline void HashtableSizeOptions::UnPackTo(HashtableSizeOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; } inline flatbuffers::Offset<HashtableSizeOptions> HashtableSizeOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const HashtableSizeOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateHashtableSizeOptions(_fbb, _o, _rehasher); } inline flatbuffers::Offset<HashtableSizeOptions> CreateHashtableSizeOptions(flatbuffers::FlatBufferBuilder &_fbb, const HashtableSizeOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const HashtableSizeOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; return tflite::CreateHashtableSizeOptions( _fbb); } inline OperatorCodeT *OperatorCode::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new OperatorCodeT(); UnPackTo(_o, _resolver); return _o; } inline void OperatorCode::UnPackTo(OperatorCodeT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = deprecated_builtin_code(); _o->deprecated_builtin_code = _e; } { auto _e = custom_code(); if (_e) _o->custom_code = _e->str(); } { auto _e = version(); _o->version = _e; } { auto _e = builtin_code(); _o->builtin_code = _e; } } inline flatbuffers::Offset<OperatorCode> OperatorCode::Pack(flatbuffers::FlatBufferBuilder &_fbb, const OperatorCodeT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateOperatorCode(_fbb, _o, _rehasher); } inline flatbuffers::Offset<OperatorCode> CreateOperatorCode(flatbuffers::FlatBufferBuilder &_fbb, const OperatorCodeT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const OperatorCodeT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _deprecated_builtin_code = _o->deprecated_builtin_code; auto _custom_code = _o->custom_code.empty() ? 0 : _fbb.CreateString(_o->custom_code); auto _version = _o->version; auto _builtin_code = _o->builtin_code; return tflite::CreateOperatorCode( _fbb, _deprecated_builtin_code, _custom_code, _version, _builtin_code); } inline OperatorT *Operator::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new OperatorT(); UnPackTo(_o, _resolver); return _o; } inline void Operator::UnPackTo(OperatorT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = opcode_index(); _o->opcode_index = _e; } { auto _e = inputs(); if (_e) { _o->inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inputs[_i] = _e->Get(_i); } } } { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->outputs[_i] = _e->Get(_i); } } } { auto _e = builtin_options_type(); _o->builtin_options.type = _e; } { auto _e = builtin_options(); if (_e) _o->builtin_options.value = tflite::BuiltinOptionsUnion::UnPack(_e, builtin_options_type(), _resolver); } { auto _e = custom_options(); if (_e) { _o->custom_options.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->custom_options.begin()); } } { auto _e = custom_options_format(); _o->custom_options_format = _e; } { auto _e = mutating_variable_inputs(); if (_e) { _o->mutating_variable_inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->mutating_variable_inputs[_i] = _e->Get(_i) != 0; } } } { auto _e = intermediates(); if (_e) { _o->intermediates.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->intermediates[_i] = _e->Get(_i); } } } } inline flatbuffers::Offset<Operator> Operator::Pack(flatbuffers::FlatBufferBuilder &_fbb, const OperatorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateOperator(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Operator> CreateOperator(flatbuffers::FlatBufferBuilder &_fbb, const OperatorT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const OperatorT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _opcode_index = _o->opcode_index; auto _inputs = _o->inputs.size() ? _fbb.CreateVector(_o->inputs) : 0; auto _outputs = _o->outputs.size() ? _fbb.CreateVector(_o->outputs) : 0; auto _builtin_options_type = _o->builtin_options.type; auto _builtin_options = _o->builtin_options.Pack(_fbb); auto _custom_options = _o->custom_options.size() ? _fbb.CreateVector(_o->custom_options) : 0; auto _custom_options_format = _o->custom_options_format; auto _mutating_variable_inputs = _o->mutating_variable_inputs.size() ? _fbb.CreateVector(_o->mutating_variable_inputs) : 0; auto _intermediates = _o->intermediates.size() ? _fbb.CreateVector(_o->intermediates) : 0; return tflite::CreateOperator( _fbb, _opcode_index, _inputs, _outputs, _builtin_options_type, _builtin_options, _custom_options, _custom_options_format, _mutating_variable_inputs, _intermediates); } inline SubGraphT *SubGraph::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SubGraphT(); UnPackTo(_o, _resolver); return _o; } inline void SubGraph::UnPackTo(SubGraphT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = tensors(); if (_e) { _o->tensors.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->tensors[_i] = std::unique_ptr<tflite::TensorT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = inputs(); if (_e) { _o->inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inputs[_i] = _e->Get(_i); } } } { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->outputs[_i] = _e->Get(_i); } } } { auto _e = operators(); if (_e) { _o->operators.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->operators[_i] = std::unique_ptr<tflite::OperatorT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = name(); if (_e) _o->name = _e->str(); } } inline flatbuffers::Offset<SubGraph> SubGraph::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SubGraphT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSubGraph(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SubGraph> CreateSubGraph(flatbuffers::FlatBufferBuilder &_fbb, const SubGraphT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SubGraphT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _tensors = _o->tensors.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::Tensor>> (_o->tensors.size(), [](size_t i, _VectorArgs *__va) { return CreateTensor(*__va->__fbb, __va->__o->tensors[i].get(), __va->__rehasher); }, &_va ) : 0; auto _inputs = _o->inputs.size() ? _fbb.CreateVector(_o->inputs) : 0; auto _outputs = _o->outputs.size() ? _fbb.CreateVector(_o->outputs) : 0; auto _operators = _o->operators.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::Operator>> (_o->operators.size(), [](size_t i, _VectorArgs *__va) { return CreateOperator(*__va->__fbb, __va->__o->operators[i].get(), __va->__rehasher); }, &_va ) : 0; auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name); return tflite::CreateSubGraph( _fbb, _tensors, _inputs, _outputs, _operators, _name); } inline BufferT *Buffer::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new BufferT(); UnPackTo(_o, _resolver); return _o; } inline void Buffer::UnPackTo(BufferT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = data(); if (_e) { _o->data.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->data.begin()); } } } inline flatbuffers::Offset<Buffer> Buffer::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BufferT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateBuffer(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Buffer> CreateBuffer(flatbuffers::FlatBufferBuilder &_fbb, const BufferT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const BufferT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; _fbb.ForceVectorAlignment(_o->data.size(), sizeof(uint8_t), 16); auto _data = _o->data.size() ? _fbb.CreateVector(_o->data) : 0; return tflite::CreateBuffer( _fbb, _data); } inline MetadataT *Metadata::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new MetadataT(); UnPackTo(_o, _resolver); return _o; } inline void Metadata::UnPackTo(MetadataT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = name(); if (_e) _o->name = _e->str(); } { auto _e = buffer(); _o->buffer = _e; } } inline flatbuffers::Offset<Metadata> Metadata::Pack(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateMetadata(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Metadata> CreateMetadata(flatbuffers::FlatBufferBuilder &_fbb, const MetadataT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const MetadataT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name); auto _buffer = _o->buffer; return tflite::CreateMetadata( _fbb, _name, _buffer); } inline TensorMapT *TensorMap::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new TensorMapT(); UnPackTo(_o, _resolver); return _o; } inline void TensorMap::UnPackTo(TensorMapT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = name(); if (_e) _o->name = _e->str(); } { auto _e = tensor_index(); _o->tensor_index = _e; } } inline flatbuffers::Offset<TensorMap> TensorMap::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TensorMapT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateTensorMap(_fbb, _o, _rehasher); } inline flatbuffers::Offset<TensorMap> CreateTensorMap(flatbuffers::FlatBufferBuilder &_fbb, const TensorMapT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TensorMapT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _name = _o->name.empty() ? 0 : _fbb.CreateString(_o->name); auto _tensor_index = _o->tensor_index; return tflite::CreateTensorMap( _fbb, _name, _tensor_index); } inline SignatureDefT *SignatureDef::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new SignatureDefT(); UnPackTo(_o, _resolver); return _o; } inline void SignatureDef::UnPackTo(SignatureDefT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = inputs(); if (_e) { _o->inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inputs[_i] = std::unique_ptr<tflite::TensorMapT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->outputs[_i] = std::unique_ptr<tflite::TensorMapT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = method_name(); if (_e) _o->method_name = _e->str(); } { auto _e = key(); if (_e) _o->key = _e->str(); } } inline flatbuffers::Offset<SignatureDef> SignatureDef::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SignatureDefT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateSignatureDef(_fbb, _o, _rehasher); } inline flatbuffers::Offset<SignatureDef> CreateSignatureDef(flatbuffers::FlatBufferBuilder &_fbb, const SignatureDefT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SignatureDefT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _inputs = _o->inputs.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::TensorMap>> (_o->inputs.size(), [](size_t i, _VectorArgs *__va) { return CreateTensorMap(*__va->__fbb, __va->__o->inputs[i].get(), __va->__rehasher); }, &_va ) : 0; auto _outputs = _o->outputs.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::TensorMap>> (_o->outputs.size(), [](size_t i, _VectorArgs *__va) { return CreateTensorMap(*__va->__fbb, __va->__o->outputs[i].get(), __va->__rehasher); }, &_va ) : 0; auto _method_name = _o->method_name.empty() ? 0 : _fbb.CreateString(_o->method_name); auto _key = _o->key.empty() ? 0 : _fbb.CreateString(_o->key); return tflite::CreateSignatureDef( _fbb, _inputs, _outputs, _method_name, _key); } inline ModelT *Model::UnPack(const flatbuffers::resolver_function_t *_resolver) const { auto _o = new ModelT(); UnPackTo(_o, _resolver); return _o; } inline void Model::UnPackTo(ModelT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; { auto _e = version(); _o->version = _e; } { auto _e = operator_codes(); if (_e) { _o->operator_codes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->operator_codes[_i] = std::unique_ptr<tflite::OperatorCodeT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = subgraphs(); if (_e) { _o->subgraphs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->subgraphs[_i] = std::unique_ptr<tflite::SubGraphT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = description(); if (_e) _o->description = _e->str(); } { auto _e = buffers(); if (_e) { _o->buffers.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->buffers[_i] = std::unique_ptr<tflite::BufferT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = metadata_buffer(); if (_e) { _o->metadata_buffer.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->metadata_buffer[_i] = _e->Get(_i); } } } { auto _e = metadata(); if (_e) { _o->metadata.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->metadata[_i] = std::unique_ptr<tflite::MetadataT>(_e->Get(_i)->UnPack(_resolver)); } } } { auto _e = signature_defs(); if (_e) { _o->signature_defs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->signature_defs[_i] = std::unique_ptr<tflite::SignatureDefT>(_e->Get(_i)->UnPack(_resolver)); } } } } inline flatbuffers::Offset<Model> Model::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ModelT* _o, const flatbuffers::rehasher_function_t *_rehasher) { return CreateModel(_fbb, _o, _rehasher); } inline flatbuffers::Offset<Model> CreateModel(flatbuffers::FlatBufferBuilder &_fbb, const ModelT *_o, const flatbuffers::rehasher_function_t *_rehasher) { (void)_rehasher; (void)_o; struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const ModelT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; auto _version = _o->version; auto _operator_codes = _o->operator_codes.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::OperatorCode>> (_o->operator_codes.size(), [](size_t i, _VectorArgs *__va) { return CreateOperatorCode(*__va->__fbb, __va->__o->operator_codes[i].get(), __va->__rehasher); }, &_va ) : 0; auto _subgraphs = _o->subgraphs.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::SubGraph>> (_o->subgraphs.size(), [](size_t i, _VectorArgs *__va) { return CreateSubGraph(*__va->__fbb, __va->__o->subgraphs[i].get(), __va->__rehasher); }, &_va ) : 0; auto _description = _o->description.empty() ? 0 : _fbb.CreateString(_o->description); auto _buffers = _o->buffers.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::Buffer>> (_o->buffers.size(), [](size_t i, _VectorArgs *__va) { return CreateBuffer(*__va->__fbb, __va->__o->buffers[i].get(), __va->__rehasher); }, &_va ) : 0; auto _metadata_buffer = _o->metadata_buffer.size() ? _fbb.CreateVector(_o->metadata_buffer) : 0; auto _metadata = _o->metadata.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::Metadata>> (_o->metadata.size(), [](size_t i, _VectorArgs *__va) { return CreateMetadata(*__va->__fbb, __va->__o->metadata[i].get(), __va->__rehasher); }, &_va ) : 0; auto _signature_defs = _o->signature_defs.size() ? _fbb.CreateVector<flatbuffers::Offset<tflite::SignatureDef>> (_o->signature_defs.size(), [](size_t i, _VectorArgs *__va) { return CreateSignatureDef(*__va->__fbb, __va->__o->signature_defs[i].get(), __va->__rehasher); }, &_va ) : 0; return tflite::CreateModel( _fbb, _version, _operator_codes, _subgraphs, _description, _buffers, _metadata_buffer, _metadata, _signature_defs); } inline bool VerifyQuantizationDetails(flatbuffers::Verifier &verifier, const void *obj, QuantizationDetails type) { switch (type) { case QuantizationDetails_NONE: { return true; } case QuantizationDetails_CustomQuantization: { auto ptr = reinterpret_cast<const tflite::CustomQuantization *>(obj); return verifier.VerifyTable(ptr); } default: return true; } } inline bool VerifyQuantizationDetailsVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) { if (!values || !types) return !values && !types; if (values->size() != types->size()) return false; for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { if (!VerifyQuantizationDetails( verifier, values->Get(i), types->GetEnum<QuantizationDetails>(i))) { return false; } } return true; } inline void *QuantizationDetailsUnion::UnPack(const void *obj, QuantizationDetails type, const flatbuffers::resolver_function_t *resolver) { switch (type) { case QuantizationDetails_CustomQuantization: { auto ptr = reinterpret_cast<const tflite::CustomQuantization *>(obj); return ptr->UnPack(resolver); } default: return nullptr; } } inline flatbuffers::Offset<void> QuantizationDetailsUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { switch (type) { case QuantizationDetails_CustomQuantization: { auto ptr = reinterpret_cast<const tflite::CustomQuantizationT *>(value); return CreateCustomQuantization(_fbb, ptr, _rehasher).Union(); } default: return 0; } } inline QuantizationDetailsUnion::QuantizationDetailsUnion(const QuantizationDetailsUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) { switch (type) { case QuantizationDetails_CustomQuantization: { value = new tflite::CustomQuantizationT(*reinterpret_cast<tflite::CustomQuantizationT *>(u.value)); break; } default: break; } } inline void QuantizationDetailsUnion::Reset() { switch (type) { case QuantizationDetails_CustomQuantization: { auto ptr = reinterpret_cast<tflite::CustomQuantizationT *>(value); delete ptr; break; } default: break; } value = nullptr; type = QuantizationDetails_NONE; } inline bool VerifySparseIndexVector(flatbuffers::Verifier &verifier, const void *obj, SparseIndexVector type) { switch (type) { case SparseIndexVector_NONE: { return true; } case SparseIndexVector_Int32Vector: { auto ptr = reinterpret_cast<const tflite::Int32Vector *>(obj); return verifier.VerifyTable(ptr); } case SparseIndexVector_Uint16Vector: { auto ptr = reinterpret_cast<const tflite::Uint16Vector *>(obj); return verifier.VerifyTable(ptr); } case SparseIndexVector_Uint8Vector: { auto ptr = reinterpret_cast<const tflite::Uint8Vector *>(obj); return verifier.VerifyTable(ptr); } default: return true; } } inline bool VerifySparseIndexVectorVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) { if (!values || !types) return !values && !types; if (values->size() != types->size()) return false; for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { if (!VerifySparseIndexVector( verifier, values->Get(i), types->GetEnum<SparseIndexVector>(i))) { return false; } } return true; } inline void *SparseIndexVectorUnion::UnPack(const void *obj, SparseIndexVector type, const flatbuffers::resolver_function_t *resolver) { switch (type) { case SparseIndexVector_Int32Vector: { auto ptr = reinterpret_cast<const tflite::Int32Vector *>(obj); return ptr->UnPack(resolver); } case SparseIndexVector_Uint16Vector: { auto ptr = reinterpret_cast<const tflite::Uint16Vector *>(obj); return ptr->UnPack(resolver); } case SparseIndexVector_Uint8Vector: { auto ptr = reinterpret_cast<const tflite::Uint8Vector *>(obj); return ptr->UnPack(resolver); } default: return nullptr; } } inline flatbuffers::Offset<void> SparseIndexVectorUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { switch (type) { case SparseIndexVector_Int32Vector: { auto ptr = reinterpret_cast<const tflite::Int32VectorT *>(value); return CreateInt32Vector(_fbb, ptr, _rehasher).Union(); } case SparseIndexVector_Uint16Vector: { auto ptr = reinterpret_cast<const tflite::Uint16VectorT *>(value); return CreateUint16Vector(_fbb, ptr, _rehasher).Union(); } case SparseIndexVector_Uint8Vector: { auto ptr = reinterpret_cast<const tflite::Uint8VectorT *>(value); return CreateUint8Vector(_fbb, ptr, _rehasher).Union(); } default: return 0; } } inline SparseIndexVectorUnion::SparseIndexVectorUnion(const SparseIndexVectorUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) { switch (type) { case SparseIndexVector_Int32Vector: { value = new tflite::Int32VectorT(*reinterpret_cast<tflite::Int32VectorT *>(u.value)); break; } case SparseIndexVector_Uint16Vector: { value = new tflite::Uint16VectorT(*reinterpret_cast<tflite::Uint16VectorT *>(u.value)); break; } case SparseIndexVector_Uint8Vector: { value = new tflite::Uint8VectorT(*reinterpret_cast<tflite::Uint8VectorT *>(u.value)); break; } default: break; } } inline void SparseIndexVectorUnion::Reset() { switch (type) { case SparseIndexVector_Int32Vector: { auto ptr = reinterpret_cast<tflite::Int32VectorT *>(value); delete ptr; break; } case SparseIndexVector_Uint16Vector: { auto ptr = reinterpret_cast<tflite::Uint16VectorT *>(value); delete ptr; break; } case SparseIndexVector_Uint8Vector: { auto ptr = reinterpret_cast<tflite::Uint8VectorT *>(value); delete ptr; break; } default: break; } value = nullptr; type = SparseIndexVector_NONE; } inline bool VerifyBuiltinOptions(flatbuffers::Verifier &verifier, const void *obj, BuiltinOptions type) { switch (type) { case BuiltinOptions_NONE: { return true; } case BuiltinOptions_Conv2DOptions: { auto ptr = reinterpret_cast<const tflite::Conv2DOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_DepthwiseConv2DOptions: { auto ptr = reinterpret_cast<const tflite::DepthwiseConv2DOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ConcatEmbeddingsOptions: { auto ptr = reinterpret_cast<const tflite::ConcatEmbeddingsOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LSHProjectionOptions: { auto ptr = reinterpret_cast<const tflite::LSHProjectionOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_Pool2DOptions: { auto ptr = reinterpret_cast<const tflite::Pool2DOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SVDFOptions: { auto ptr = reinterpret_cast<const tflite::SVDFOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_RNNOptions: { auto ptr = reinterpret_cast<const tflite::RNNOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_FullyConnectedOptions: { auto ptr = reinterpret_cast<const tflite::FullyConnectedOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SoftmaxOptions: { auto ptr = reinterpret_cast<const tflite::SoftmaxOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ConcatenationOptions: { auto ptr = reinterpret_cast<const tflite::ConcatenationOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_AddOptions: { auto ptr = reinterpret_cast<const tflite::AddOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_L2NormOptions: { auto ptr = reinterpret_cast<const tflite::L2NormOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LocalResponseNormalizationOptions: { auto ptr = reinterpret_cast<const tflite::LocalResponseNormalizationOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LSTMOptions: { auto ptr = reinterpret_cast<const tflite::LSTMOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ResizeBilinearOptions: { auto ptr = reinterpret_cast<const tflite::ResizeBilinearOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_CallOptions: { auto ptr = reinterpret_cast<const tflite::CallOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ReshapeOptions: { auto ptr = reinterpret_cast<const tflite::ReshapeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SkipGramOptions: { auto ptr = reinterpret_cast<const tflite::SkipGramOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SpaceToDepthOptions: { auto ptr = reinterpret_cast<const tflite::SpaceToDepthOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_EmbeddingLookupSparseOptions: { auto ptr = reinterpret_cast<const tflite::EmbeddingLookupSparseOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_MulOptions: { auto ptr = reinterpret_cast<const tflite::MulOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_PadOptions: { auto ptr = reinterpret_cast<const tflite::PadOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_GatherOptions: { auto ptr = reinterpret_cast<const tflite::GatherOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_BatchToSpaceNDOptions: { auto ptr = reinterpret_cast<const tflite::BatchToSpaceNDOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SpaceToBatchNDOptions: { auto ptr = reinterpret_cast<const tflite::SpaceToBatchNDOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_TransposeOptions: { auto ptr = reinterpret_cast<const tflite::TransposeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ReducerOptions: { auto ptr = reinterpret_cast<const tflite::ReducerOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SubOptions: { auto ptr = reinterpret_cast<const tflite::SubOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_DivOptions: { auto ptr = reinterpret_cast<const tflite::DivOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SqueezeOptions: { auto ptr = reinterpret_cast<const tflite::SqueezeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SequenceRNNOptions: { auto ptr = reinterpret_cast<const tflite::SequenceRNNOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_StridedSliceOptions: { auto ptr = reinterpret_cast<const tflite::StridedSliceOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ExpOptions: { auto ptr = reinterpret_cast<const tflite::ExpOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_TopKV2Options: { auto ptr = reinterpret_cast<const tflite::TopKV2Options *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SplitOptions: { auto ptr = reinterpret_cast<const tflite::SplitOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LogSoftmaxOptions: { auto ptr = reinterpret_cast<const tflite::LogSoftmaxOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_CastOptions: { auto ptr = reinterpret_cast<const tflite::CastOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_DequantizeOptions: { auto ptr = reinterpret_cast<const tflite::DequantizeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_MaximumMinimumOptions: { auto ptr = reinterpret_cast<const tflite::MaximumMinimumOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ArgMaxOptions: { auto ptr = reinterpret_cast<const tflite::ArgMaxOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LessOptions: { auto ptr = reinterpret_cast<const tflite::LessOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_NegOptions: { auto ptr = reinterpret_cast<const tflite::NegOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_PadV2Options: { auto ptr = reinterpret_cast<const tflite::PadV2Options *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_GreaterOptions: { auto ptr = reinterpret_cast<const tflite::GreaterOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_GreaterEqualOptions: { auto ptr = reinterpret_cast<const tflite::GreaterEqualOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LessEqualOptions: { auto ptr = reinterpret_cast<const tflite::LessEqualOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SelectOptions: { auto ptr = reinterpret_cast<const tflite::SelectOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SliceOptions: { auto ptr = reinterpret_cast<const tflite::SliceOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_TransposeConvOptions: { auto ptr = reinterpret_cast<const tflite::TransposeConvOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SparseToDenseOptions: { auto ptr = reinterpret_cast<const tflite::SparseToDenseOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_TileOptions: { auto ptr = reinterpret_cast<const tflite::TileOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ExpandDimsOptions: { auto ptr = reinterpret_cast<const tflite::ExpandDimsOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_EqualOptions: { auto ptr = reinterpret_cast<const tflite::EqualOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_NotEqualOptions: { auto ptr = reinterpret_cast<const tflite::NotEqualOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ShapeOptions: { auto ptr = reinterpret_cast<const tflite::ShapeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_PowOptions: { auto ptr = reinterpret_cast<const tflite::PowOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ArgMinOptions: { auto ptr = reinterpret_cast<const tflite::ArgMinOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_FakeQuantOptions: { auto ptr = reinterpret_cast<const tflite::FakeQuantOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_PackOptions: { auto ptr = reinterpret_cast<const tflite::PackOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LogicalOrOptions: { auto ptr = reinterpret_cast<const tflite::LogicalOrOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_OneHotOptions: { auto ptr = reinterpret_cast<const tflite::OneHotOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LogicalAndOptions: { auto ptr = reinterpret_cast<const tflite::LogicalAndOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LogicalNotOptions: { auto ptr = reinterpret_cast<const tflite::LogicalNotOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_UnpackOptions: { auto ptr = reinterpret_cast<const tflite::UnpackOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_FloorDivOptions: { auto ptr = reinterpret_cast<const tflite::FloorDivOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SquareOptions: { auto ptr = reinterpret_cast<const tflite::SquareOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ZerosLikeOptions: { auto ptr = reinterpret_cast<const tflite::ZerosLikeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_FillOptions: { auto ptr = reinterpret_cast<const tflite::FillOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_BidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<const tflite::BidirectionalSequenceLSTMOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_BidirectionalSequenceRNNOptions: { auto ptr = reinterpret_cast<const tflite::BidirectionalSequenceRNNOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_UnidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<const tflite::UnidirectionalSequenceLSTMOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_FloorModOptions: { auto ptr = reinterpret_cast<const tflite::FloorModOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_RangeOptions: { auto ptr = reinterpret_cast<const tflite::RangeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ResizeNearestNeighborOptions: { auto ptr = reinterpret_cast<const tflite::ResizeNearestNeighborOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_LeakyReluOptions: { auto ptr = reinterpret_cast<const tflite::LeakyReluOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SquaredDifferenceOptions: { auto ptr = reinterpret_cast<const tflite::SquaredDifferenceOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_MirrorPadOptions: { auto ptr = reinterpret_cast<const tflite::MirrorPadOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_AbsOptions: { auto ptr = reinterpret_cast<const tflite::AbsOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SplitVOptions: { auto ptr = reinterpret_cast<const tflite::SplitVOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_UniqueOptions: { auto ptr = reinterpret_cast<const tflite::UniqueOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ReverseV2Options: { auto ptr = reinterpret_cast<const tflite::ReverseV2Options *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_AddNOptions: { auto ptr = reinterpret_cast<const tflite::AddNOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_GatherNdOptions: { auto ptr = reinterpret_cast<const tflite::GatherNdOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_CosOptions: { auto ptr = reinterpret_cast<const tflite::CosOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_WhereOptions: { auto ptr = reinterpret_cast<const tflite::WhereOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_RankOptions: { auto ptr = reinterpret_cast<const tflite::RankOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ReverseSequenceOptions: { auto ptr = reinterpret_cast<const tflite::ReverseSequenceOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_MatrixDiagOptions: { auto ptr = reinterpret_cast<const tflite::MatrixDiagOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_QuantizeOptions: { auto ptr = reinterpret_cast<const tflite::QuantizeOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_MatrixSetDiagOptions: { auto ptr = reinterpret_cast<const tflite::MatrixSetDiagOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_HardSwishOptions: { auto ptr = reinterpret_cast<const tflite::HardSwishOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_IfOptions: { auto ptr = reinterpret_cast<const tflite::IfOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_WhileOptions: { auto ptr = reinterpret_cast<const tflite::WhileOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_DepthToSpaceOptions: { auto ptr = reinterpret_cast<const tflite::DepthToSpaceOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_NonMaxSuppressionV4Options: { auto ptr = reinterpret_cast<const tflite::NonMaxSuppressionV4Options *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_NonMaxSuppressionV5Options: { auto ptr = reinterpret_cast<const tflite::NonMaxSuppressionV5Options *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_ScatterNdOptions: { auto ptr = reinterpret_cast<const tflite::ScatterNdOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SelectV2Options: { auto ptr = reinterpret_cast<const tflite::SelectV2Options *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_DensifyOptions: { auto ptr = reinterpret_cast<const tflite::DensifyOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_SegmentSumOptions: { auto ptr = reinterpret_cast<const tflite::SegmentSumOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_BatchMatMulOptions: { auto ptr = reinterpret_cast<const tflite::BatchMatMulOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_CumsumOptions: { auto ptr = reinterpret_cast<const tflite::CumsumOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_CallOnceOptions: { auto ptr = reinterpret_cast<const tflite::CallOnceOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_BroadcastToOptions: { auto ptr = reinterpret_cast<const tflite::BroadcastToOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_Rfft2dOptions: { auto ptr = reinterpret_cast<const tflite::Rfft2dOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_Conv3DOptions: { auto ptr = reinterpret_cast<const tflite::Conv3DOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_HashtableOptions: { auto ptr = reinterpret_cast<const tflite::HashtableOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_HashtableFindOptions: { auto ptr = reinterpret_cast<const tflite::HashtableFindOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_HashtableImportOptions: { auto ptr = reinterpret_cast<const tflite::HashtableImportOptions *>(obj); return verifier.VerifyTable(ptr); } case BuiltinOptions_HashtableSizeOptions: { auto ptr = reinterpret_cast<const tflite::HashtableSizeOptions *>(obj); return verifier.VerifyTable(ptr); } default: return true; } } inline bool VerifyBuiltinOptionsVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) { if (!values || !types) return !values && !types; if (values->size() != types->size()) return false; for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) { if (!VerifyBuiltinOptions( verifier, values->Get(i), types->GetEnum<BuiltinOptions>(i))) { return false; } } return true; } inline void *BuiltinOptionsUnion::UnPack(const void *obj, BuiltinOptions type, const flatbuffers::resolver_function_t *resolver) { switch (type) { case BuiltinOptions_Conv2DOptions: { auto ptr = reinterpret_cast<const tflite::Conv2DOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_DepthwiseConv2DOptions: { auto ptr = reinterpret_cast<const tflite::DepthwiseConv2DOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ConcatEmbeddingsOptions: { auto ptr = reinterpret_cast<const tflite::ConcatEmbeddingsOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LSHProjectionOptions: { auto ptr = reinterpret_cast<const tflite::LSHProjectionOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_Pool2DOptions: { auto ptr = reinterpret_cast<const tflite::Pool2DOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SVDFOptions: { auto ptr = reinterpret_cast<const tflite::SVDFOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_RNNOptions: { auto ptr = reinterpret_cast<const tflite::RNNOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_FullyConnectedOptions: { auto ptr = reinterpret_cast<const tflite::FullyConnectedOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SoftmaxOptions: { auto ptr = reinterpret_cast<const tflite::SoftmaxOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ConcatenationOptions: { auto ptr = reinterpret_cast<const tflite::ConcatenationOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_AddOptions: { auto ptr = reinterpret_cast<const tflite::AddOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_L2NormOptions: { auto ptr = reinterpret_cast<const tflite::L2NormOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LocalResponseNormalizationOptions: { auto ptr = reinterpret_cast<const tflite::LocalResponseNormalizationOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LSTMOptions: { auto ptr = reinterpret_cast<const tflite::LSTMOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ResizeBilinearOptions: { auto ptr = reinterpret_cast<const tflite::ResizeBilinearOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_CallOptions: { auto ptr = reinterpret_cast<const tflite::CallOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ReshapeOptions: { auto ptr = reinterpret_cast<const tflite::ReshapeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SkipGramOptions: { auto ptr = reinterpret_cast<const tflite::SkipGramOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SpaceToDepthOptions: { auto ptr = reinterpret_cast<const tflite::SpaceToDepthOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_EmbeddingLookupSparseOptions: { auto ptr = reinterpret_cast<const tflite::EmbeddingLookupSparseOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_MulOptions: { auto ptr = reinterpret_cast<const tflite::MulOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_PadOptions: { auto ptr = reinterpret_cast<const tflite::PadOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_GatherOptions: { auto ptr = reinterpret_cast<const tflite::GatherOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_BatchToSpaceNDOptions: { auto ptr = reinterpret_cast<const tflite::BatchToSpaceNDOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SpaceToBatchNDOptions: { auto ptr = reinterpret_cast<const tflite::SpaceToBatchNDOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_TransposeOptions: { auto ptr = reinterpret_cast<const tflite::TransposeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ReducerOptions: { auto ptr = reinterpret_cast<const tflite::ReducerOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SubOptions: { auto ptr = reinterpret_cast<const tflite::SubOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_DivOptions: { auto ptr = reinterpret_cast<const tflite::DivOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SqueezeOptions: { auto ptr = reinterpret_cast<const tflite::SqueezeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SequenceRNNOptions: { auto ptr = reinterpret_cast<const tflite::SequenceRNNOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_StridedSliceOptions: { auto ptr = reinterpret_cast<const tflite::StridedSliceOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ExpOptions: { auto ptr = reinterpret_cast<const tflite::ExpOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_TopKV2Options: { auto ptr = reinterpret_cast<const tflite::TopKV2Options *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SplitOptions: { auto ptr = reinterpret_cast<const tflite::SplitOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LogSoftmaxOptions: { auto ptr = reinterpret_cast<const tflite::LogSoftmaxOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_CastOptions: { auto ptr = reinterpret_cast<const tflite::CastOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_DequantizeOptions: { auto ptr = reinterpret_cast<const tflite::DequantizeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_MaximumMinimumOptions: { auto ptr = reinterpret_cast<const tflite::MaximumMinimumOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ArgMaxOptions: { auto ptr = reinterpret_cast<const tflite::ArgMaxOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LessOptions: { auto ptr = reinterpret_cast<const tflite::LessOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_NegOptions: { auto ptr = reinterpret_cast<const tflite::NegOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_PadV2Options: { auto ptr = reinterpret_cast<const tflite::PadV2Options *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_GreaterOptions: { auto ptr = reinterpret_cast<const tflite::GreaterOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_GreaterEqualOptions: { auto ptr = reinterpret_cast<const tflite::GreaterEqualOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LessEqualOptions: { auto ptr = reinterpret_cast<const tflite::LessEqualOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SelectOptions: { auto ptr = reinterpret_cast<const tflite::SelectOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SliceOptions: { auto ptr = reinterpret_cast<const tflite::SliceOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_TransposeConvOptions: { auto ptr = reinterpret_cast<const tflite::TransposeConvOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SparseToDenseOptions: { auto ptr = reinterpret_cast<const tflite::SparseToDenseOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_TileOptions: { auto ptr = reinterpret_cast<const tflite::TileOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ExpandDimsOptions: { auto ptr = reinterpret_cast<const tflite::ExpandDimsOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_EqualOptions: { auto ptr = reinterpret_cast<const tflite::EqualOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_NotEqualOptions: { auto ptr = reinterpret_cast<const tflite::NotEqualOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ShapeOptions: { auto ptr = reinterpret_cast<const tflite::ShapeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_PowOptions: { auto ptr = reinterpret_cast<const tflite::PowOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ArgMinOptions: { auto ptr = reinterpret_cast<const tflite::ArgMinOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_FakeQuantOptions: { auto ptr = reinterpret_cast<const tflite::FakeQuantOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_PackOptions: { auto ptr = reinterpret_cast<const tflite::PackOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LogicalOrOptions: { auto ptr = reinterpret_cast<const tflite::LogicalOrOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_OneHotOptions: { auto ptr = reinterpret_cast<const tflite::OneHotOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LogicalAndOptions: { auto ptr = reinterpret_cast<const tflite::LogicalAndOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LogicalNotOptions: { auto ptr = reinterpret_cast<const tflite::LogicalNotOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_UnpackOptions: { auto ptr = reinterpret_cast<const tflite::UnpackOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_FloorDivOptions: { auto ptr = reinterpret_cast<const tflite::FloorDivOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SquareOptions: { auto ptr = reinterpret_cast<const tflite::SquareOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ZerosLikeOptions: { auto ptr = reinterpret_cast<const tflite::ZerosLikeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_FillOptions: { auto ptr = reinterpret_cast<const tflite::FillOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_BidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<const tflite::BidirectionalSequenceLSTMOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_BidirectionalSequenceRNNOptions: { auto ptr = reinterpret_cast<const tflite::BidirectionalSequenceRNNOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_UnidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<const tflite::UnidirectionalSequenceLSTMOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_FloorModOptions: { auto ptr = reinterpret_cast<const tflite::FloorModOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_RangeOptions: { auto ptr = reinterpret_cast<const tflite::RangeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ResizeNearestNeighborOptions: { auto ptr = reinterpret_cast<const tflite::ResizeNearestNeighborOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_LeakyReluOptions: { auto ptr = reinterpret_cast<const tflite::LeakyReluOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SquaredDifferenceOptions: { auto ptr = reinterpret_cast<const tflite::SquaredDifferenceOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_MirrorPadOptions: { auto ptr = reinterpret_cast<const tflite::MirrorPadOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_AbsOptions: { auto ptr = reinterpret_cast<const tflite::AbsOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SplitVOptions: { auto ptr = reinterpret_cast<const tflite::SplitVOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_UniqueOptions: { auto ptr = reinterpret_cast<const tflite::UniqueOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ReverseV2Options: { auto ptr = reinterpret_cast<const tflite::ReverseV2Options *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_AddNOptions: { auto ptr = reinterpret_cast<const tflite::AddNOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_GatherNdOptions: { auto ptr = reinterpret_cast<const tflite::GatherNdOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_CosOptions: { auto ptr = reinterpret_cast<const tflite::CosOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_WhereOptions: { auto ptr = reinterpret_cast<const tflite::WhereOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_RankOptions: { auto ptr = reinterpret_cast<const tflite::RankOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ReverseSequenceOptions: { auto ptr = reinterpret_cast<const tflite::ReverseSequenceOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_MatrixDiagOptions: { auto ptr = reinterpret_cast<const tflite::MatrixDiagOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_QuantizeOptions: { auto ptr = reinterpret_cast<const tflite::QuantizeOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_MatrixSetDiagOptions: { auto ptr = reinterpret_cast<const tflite::MatrixSetDiagOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_HardSwishOptions: { auto ptr = reinterpret_cast<const tflite::HardSwishOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_IfOptions: { auto ptr = reinterpret_cast<const tflite::IfOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_WhileOptions: { auto ptr = reinterpret_cast<const tflite::WhileOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_DepthToSpaceOptions: { auto ptr = reinterpret_cast<const tflite::DepthToSpaceOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_NonMaxSuppressionV4Options: { auto ptr = reinterpret_cast<const tflite::NonMaxSuppressionV4Options *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_NonMaxSuppressionV5Options: { auto ptr = reinterpret_cast<const tflite::NonMaxSuppressionV5Options *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_ScatterNdOptions: { auto ptr = reinterpret_cast<const tflite::ScatterNdOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SelectV2Options: { auto ptr = reinterpret_cast<const tflite::SelectV2Options *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_DensifyOptions: { auto ptr = reinterpret_cast<const tflite::DensifyOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_SegmentSumOptions: { auto ptr = reinterpret_cast<const tflite::SegmentSumOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_BatchMatMulOptions: { auto ptr = reinterpret_cast<const tflite::BatchMatMulOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_CumsumOptions: { auto ptr = reinterpret_cast<const tflite::CumsumOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_CallOnceOptions: { auto ptr = reinterpret_cast<const tflite::CallOnceOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_BroadcastToOptions: { auto ptr = reinterpret_cast<const tflite::BroadcastToOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_Rfft2dOptions: { auto ptr = reinterpret_cast<const tflite::Rfft2dOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_Conv3DOptions: { auto ptr = reinterpret_cast<const tflite::Conv3DOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_HashtableOptions: { auto ptr = reinterpret_cast<const tflite::HashtableOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_HashtableFindOptions: { auto ptr = reinterpret_cast<const tflite::HashtableFindOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_HashtableImportOptions: { auto ptr = reinterpret_cast<const tflite::HashtableImportOptions *>(obj); return ptr->UnPack(resolver); } case BuiltinOptions_HashtableSizeOptions: { auto ptr = reinterpret_cast<const tflite::HashtableSizeOptions *>(obj); return ptr->UnPack(resolver); } default: return nullptr; } } inline flatbuffers::Offset<void> BuiltinOptionsUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { switch (type) { case BuiltinOptions_Conv2DOptions: { auto ptr = reinterpret_cast<const tflite::Conv2DOptionsT *>(value); return CreateConv2DOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_DepthwiseConv2DOptions: { auto ptr = reinterpret_cast<const tflite::DepthwiseConv2DOptionsT *>(value); return CreateDepthwiseConv2DOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ConcatEmbeddingsOptions: { auto ptr = reinterpret_cast<const tflite::ConcatEmbeddingsOptionsT *>(value); return CreateConcatEmbeddingsOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LSHProjectionOptions: { auto ptr = reinterpret_cast<const tflite::LSHProjectionOptionsT *>(value); return CreateLSHProjectionOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_Pool2DOptions: { auto ptr = reinterpret_cast<const tflite::Pool2DOptionsT *>(value); return CreatePool2DOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SVDFOptions: { auto ptr = reinterpret_cast<const tflite::SVDFOptionsT *>(value); return CreateSVDFOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_RNNOptions: { auto ptr = reinterpret_cast<const tflite::RNNOptionsT *>(value); return CreateRNNOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_FullyConnectedOptions: { auto ptr = reinterpret_cast<const tflite::FullyConnectedOptionsT *>(value); return CreateFullyConnectedOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SoftmaxOptions: { auto ptr = reinterpret_cast<const tflite::SoftmaxOptionsT *>(value); return CreateSoftmaxOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ConcatenationOptions: { auto ptr = reinterpret_cast<const tflite::ConcatenationOptionsT *>(value); return CreateConcatenationOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_AddOptions: { auto ptr = reinterpret_cast<const tflite::AddOptionsT *>(value); return CreateAddOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_L2NormOptions: { auto ptr = reinterpret_cast<const tflite::L2NormOptionsT *>(value); return CreateL2NormOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LocalResponseNormalizationOptions: { auto ptr = reinterpret_cast<const tflite::LocalResponseNormalizationOptionsT *>(value); return CreateLocalResponseNormalizationOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LSTMOptions: { auto ptr = reinterpret_cast<const tflite::LSTMOptionsT *>(value); return CreateLSTMOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ResizeBilinearOptions: { auto ptr = reinterpret_cast<const tflite::ResizeBilinearOptionsT *>(value); return CreateResizeBilinearOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_CallOptions: { auto ptr = reinterpret_cast<const tflite::CallOptionsT *>(value); return CreateCallOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ReshapeOptions: { auto ptr = reinterpret_cast<const tflite::ReshapeOptionsT *>(value); return CreateReshapeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SkipGramOptions: { auto ptr = reinterpret_cast<const tflite::SkipGramOptionsT *>(value); return CreateSkipGramOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SpaceToDepthOptions: { auto ptr = reinterpret_cast<const tflite::SpaceToDepthOptionsT *>(value); return CreateSpaceToDepthOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_EmbeddingLookupSparseOptions: { auto ptr = reinterpret_cast<const tflite::EmbeddingLookupSparseOptionsT *>(value); return CreateEmbeddingLookupSparseOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_MulOptions: { auto ptr = reinterpret_cast<const tflite::MulOptionsT *>(value); return CreateMulOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_PadOptions: { auto ptr = reinterpret_cast<const tflite::PadOptionsT *>(value); return CreatePadOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_GatherOptions: { auto ptr = reinterpret_cast<const tflite::GatherOptionsT *>(value); return CreateGatherOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_BatchToSpaceNDOptions: { auto ptr = reinterpret_cast<const tflite::BatchToSpaceNDOptionsT *>(value); return CreateBatchToSpaceNDOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SpaceToBatchNDOptions: { auto ptr = reinterpret_cast<const tflite::SpaceToBatchNDOptionsT *>(value); return CreateSpaceToBatchNDOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_TransposeOptions: { auto ptr = reinterpret_cast<const tflite::TransposeOptionsT *>(value); return CreateTransposeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ReducerOptions: { auto ptr = reinterpret_cast<const tflite::ReducerOptionsT *>(value); return CreateReducerOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SubOptions: { auto ptr = reinterpret_cast<const tflite::SubOptionsT *>(value); return CreateSubOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_DivOptions: { auto ptr = reinterpret_cast<const tflite::DivOptionsT *>(value); return CreateDivOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SqueezeOptions: { auto ptr = reinterpret_cast<const tflite::SqueezeOptionsT *>(value); return CreateSqueezeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SequenceRNNOptions: { auto ptr = reinterpret_cast<const tflite::SequenceRNNOptionsT *>(value); return CreateSequenceRNNOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_StridedSliceOptions: { auto ptr = reinterpret_cast<const tflite::StridedSliceOptionsT *>(value); return CreateStridedSliceOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ExpOptions: { auto ptr = reinterpret_cast<const tflite::ExpOptionsT *>(value); return CreateExpOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_TopKV2Options: { auto ptr = reinterpret_cast<const tflite::TopKV2OptionsT *>(value); return CreateTopKV2Options(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SplitOptions: { auto ptr = reinterpret_cast<const tflite::SplitOptionsT *>(value); return CreateSplitOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LogSoftmaxOptions: { auto ptr = reinterpret_cast<const tflite::LogSoftmaxOptionsT *>(value); return CreateLogSoftmaxOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_CastOptions: { auto ptr = reinterpret_cast<const tflite::CastOptionsT *>(value); return CreateCastOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_DequantizeOptions: { auto ptr = reinterpret_cast<const tflite::DequantizeOptionsT *>(value); return CreateDequantizeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_MaximumMinimumOptions: { auto ptr = reinterpret_cast<const tflite::MaximumMinimumOptionsT *>(value); return CreateMaximumMinimumOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ArgMaxOptions: { auto ptr = reinterpret_cast<const tflite::ArgMaxOptionsT *>(value); return CreateArgMaxOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LessOptions: { auto ptr = reinterpret_cast<const tflite::LessOptionsT *>(value); return CreateLessOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_NegOptions: { auto ptr = reinterpret_cast<const tflite::NegOptionsT *>(value); return CreateNegOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_PadV2Options: { auto ptr = reinterpret_cast<const tflite::PadV2OptionsT *>(value); return CreatePadV2Options(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_GreaterOptions: { auto ptr = reinterpret_cast<const tflite::GreaterOptionsT *>(value); return CreateGreaterOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_GreaterEqualOptions: { auto ptr = reinterpret_cast<const tflite::GreaterEqualOptionsT *>(value); return CreateGreaterEqualOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LessEqualOptions: { auto ptr = reinterpret_cast<const tflite::LessEqualOptionsT *>(value); return CreateLessEqualOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SelectOptions: { auto ptr = reinterpret_cast<const tflite::SelectOptionsT *>(value); return CreateSelectOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SliceOptions: { auto ptr = reinterpret_cast<const tflite::SliceOptionsT *>(value); return CreateSliceOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_TransposeConvOptions: { auto ptr = reinterpret_cast<const tflite::TransposeConvOptionsT *>(value); return CreateTransposeConvOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SparseToDenseOptions: { auto ptr = reinterpret_cast<const tflite::SparseToDenseOptionsT *>(value); return CreateSparseToDenseOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_TileOptions: { auto ptr = reinterpret_cast<const tflite::TileOptionsT *>(value); return CreateTileOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ExpandDimsOptions: { auto ptr = reinterpret_cast<const tflite::ExpandDimsOptionsT *>(value); return CreateExpandDimsOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_EqualOptions: { auto ptr = reinterpret_cast<const tflite::EqualOptionsT *>(value); return CreateEqualOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_NotEqualOptions: { auto ptr = reinterpret_cast<const tflite::NotEqualOptionsT *>(value); return CreateNotEqualOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ShapeOptions: { auto ptr = reinterpret_cast<const tflite::ShapeOptionsT *>(value); return CreateShapeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_PowOptions: { auto ptr = reinterpret_cast<const tflite::PowOptionsT *>(value); return CreatePowOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ArgMinOptions: { auto ptr = reinterpret_cast<const tflite::ArgMinOptionsT *>(value); return CreateArgMinOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_FakeQuantOptions: { auto ptr = reinterpret_cast<const tflite::FakeQuantOptionsT *>(value); return CreateFakeQuantOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_PackOptions: { auto ptr = reinterpret_cast<const tflite::PackOptionsT *>(value); return CreatePackOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LogicalOrOptions: { auto ptr = reinterpret_cast<const tflite::LogicalOrOptionsT *>(value); return CreateLogicalOrOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_OneHotOptions: { auto ptr = reinterpret_cast<const tflite::OneHotOptionsT *>(value); return CreateOneHotOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LogicalAndOptions: { auto ptr = reinterpret_cast<const tflite::LogicalAndOptionsT *>(value); return CreateLogicalAndOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LogicalNotOptions: { auto ptr = reinterpret_cast<const tflite::LogicalNotOptionsT *>(value); return CreateLogicalNotOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_UnpackOptions: { auto ptr = reinterpret_cast<const tflite::UnpackOptionsT *>(value); return CreateUnpackOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_FloorDivOptions: { auto ptr = reinterpret_cast<const tflite::FloorDivOptionsT *>(value); return CreateFloorDivOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SquareOptions: { auto ptr = reinterpret_cast<const tflite::SquareOptionsT *>(value); return CreateSquareOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ZerosLikeOptions: { auto ptr = reinterpret_cast<const tflite::ZerosLikeOptionsT *>(value); return CreateZerosLikeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_FillOptions: { auto ptr = reinterpret_cast<const tflite::FillOptionsT *>(value); return CreateFillOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_BidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<const tflite::BidirectionalSequenceLSTMOptionsT *>(value); return CreateBidirectionalSequenceLSTMOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_BidirectionalSequenceRNNOptions: { auto ptr = reinterpret_cast<const tflite::BidirectionalSequenceRNNOptionsT *>(value); return CreateBidirectionalSequenceRNNOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_UnidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<const tflite::UnidirectionalSequenceLSTMOptionsT *>(value); return CreateUnidirectionalSequenceLSTMOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_FloorModOptions: { auto ptr = reinterpret_cast<const tflite::FloorModOptionsT *>(value); return CreateFloorModOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_RangeOptions: { auto ptr = reinterpret_cast<const tflite::RangeOptionsT *>(value); return CreateRangeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ResizeNearestNeighborOptions: { auto ptr = reinterpret_cast<const tflite::ResizeNearestNeighborOptionsT *>(value); return CreateResizeNearestNeighborOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_LeakyReluOptions: { auto ptr = reinterpret_cast<const tflite::LeakyReluOptionsT *>(value); return CreateLeakyReluOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SquaredDifferenceOptions: { auto ptr = reinterpret_cast<const tflite::SquaredDifferenceOptionsT *>(value); return CreateSquaredDifferenceOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_MirrorPadOptions: { auto ptr = reinterpret_cast<const tflite::MirrorPadOptionsT *>(value); return CreateMirrorPadOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_AbsOptions: { auto ptr = reinterpret_cast<const tflite::AbsOptionsT *>(value); return CreateAbsOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SplitVOptions: { auto ptr = reinterpret_cast<const tflite::SplitVOptionsT *>(value); return CreateSplitVOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_UniqueOptions: { auto ptr = reinterpret_cast<const tflite::UniqueOptionsT *>(value); return CreateUniqueOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ReverseV2Options: { auto ptr = reinterpret_cast<const tflite::ReverseV2OptionsT *>(value); return CreateReverseV2Options(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_AddNOptions: { auto ptr = reinterpret_cast<const tflite::AddNOptionsT *>(value); return CreateAddNOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_GatherNdOptions: { auto ptr = reinterpret_cast<const tflite::GatherNdOptionsT *>(value); return CreateGatherNdOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_CosOptions: { auto ptr = reinterpret_cast<const tflite::CosOptionsT *>(value); return CreateCosOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_WhereOptions: { auto ptr = reinterpret_cast<const tflite::WhereOptionsT *>(value); return CreateWhereOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_RankOptions: { auto ptr = reinterpret_cast<const tflite::RankOptionsT *>(value); return CreateRankOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ReverseSequenceOptions: { auto ptr = reinterpret_cast<const tflite::ReverseSequenceOptionsT *>(value); return CreateReverseSequenceOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_MatrixDiagOptions: { auto ptr = reinterpret_cast<const tflite::MatrixDiagOptionsT *>(value); return CreateMatrixDiagOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_QuantizeOptions: { auto ptr = reinterpret_cast<const tflite::QuantizeOptionsT *>(value); return CreateQuantizeOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_MatrixSetDiagOptions: { auto ptr = reinterpret_cast<const tflite::MatrixSetDiagOptionsT *>(value); return CreateMatrixSetDiagOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_HardSwishOptions: { auto ptr = reinterpret_cast<const tflite::HardSwishOptionsT *>(value); return CreateHardSwishOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_IfOptions: { auto ptr = reinterpret_cast<const tflite::IfOptionsT *>(value); return CreateIfOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_WhileOptions: { auto ptr = reinterpret_cast<const tflite::WhileOptionsT *>(value); return CreateWhileOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_DepthToSpaceOptions: { auto ptr = reinterpret_cast<const tflite::DepthToSpaceOptionsT *>(value); return CreateDepthToSpaceOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_NonMaxSuppressionV4Options: { auto ptr = reinterpret_cast<const tflite::NonMaxSuppressionV4OptionsT *>(value); return CreateNonMaxSuppressionV4Options(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_NonMaxSuppressionV5Options: { auto ptr = reinterpret_cast<const tflite::NonMaxSuppressionV5OptionsT *>(value); return CreateNonMaxSuppressionV5Options(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_ScatterNdOptions: { auto ptr = reinterpret_cast<const tflite::ScatterNdOptionsT *>(value); return CreateScatterNdOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SelectV2Options: { auto ptr = reinterpret_cast<const tflite::SelectV2OptionsT *>(value); return CreateSelectV2Options(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_DensifyOptions: { auto ptr = reinterpret_cast<const tflite::DensifyOptionsT *>(value); return CreateDensifyOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_SegmentSumOptions: { auto ptr = reinterpret_cast<const tflite::SegmentSumOptionsT *>(value); return CreateSegmentSumOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_BatchMatMulOptions: { auto ptr = reinterpret_cast<const tflite::BatchMatMulOptionsT *>(value); return CreateBatchMatMulOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_CumsumOptions: { auto ptr = reinterpret_cast<const tflite::CumsumOptionsT *>(value); return CreateCumsumOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_CallOnceOptions: { auto ptr = reinterpret_cast<const tflite::CallOnceOptionsT *>(value); return CreateCallOnceOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_BroadcastToOptions: { auto ptr = reinterpret_cast<const tflite::BroadcastToOptionsT *>(value); return CreateBroadcastToOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_Rfft2dOptions: { auto ptr = reinterpret_cast<const tflite::Rfft2dOptionsT *>(value); return CreateRfft2dOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_Conv3DOptions: { auto ptr = reinterpret_cast<const tflite::Conv3DOptionsT *>(value); return CreateConv3DOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_HashtableOptions: { auto ptr = reinterpret_cast<const tflite::HashtableOptionsT *>(value); return CreateHashtableOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_HashtableFindOptions: { auto ptr = reinterpret_cast<const tflite::HashtableFindOptionsT *>(value); return CreateHashtableFindOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_HashtableImportOptions: { auto ptr = reinterpret_cast<const tflite::HashtableImportOptionsT *>(value); return CreateHashtableImportOptions(_fbb, ptr, _rehasher).Union(); } case BuiltinOptions_HashtableSizeOptions: { auto ptr = reinterpret_cast<const tflite::HashtableSizeOptionsT *>(value); return CreateHashtableSizeOptions(_fbb, ptr, _rehasher).Union(); } default: return 0; } } inline BuiltinOptionsUnion::BuiltinOptionsUnion(const BuiltinOptionsUnion &u) FLATBUFFERS_NOEXCEPT : type(u.type), value(nullptr) { switch (type) { case BuiltinOptions_Conv2DOptions: { value = new tflite::Conv2DOptionsT(*reinterpret_cast<tflite::Conv2DOptionsT *>(u.value)); break; } case BuiltinOptions_DepthwiseConv2DOptions: { value = new tflite::DepthwiseConv2DOptionsT(*reinterpret_cast<tflite::DepthwiseConv2DOptionsT *>(u.value)); break; } case BuiltinOptions_ConcatEmbeddingsOptions: { value = new tflite::ConcatEmbeddingsOptionsT(*reinterpret_cast<tflite::ConcatEmbeddingsOptionsT *>(u.value)); break; } case BuiltinOptions_LSHProjectionOptions: { value = new tflite::LSHProjectionOptionsT(*reinterpret_cast<tflite::LSHProjectionOptionsT *>(u.value)); break; } case BuiltinOptions_Pool2DOptions: { value = new tflite::Pool2DOptionsT(*reinterpret_cast<tflite::Pool2DOptionsT *>(u.value)); break; } case BuiltinOptions_SVDFOptions: { value = new tflite::SVDFOptionsT(*reinterpret_cast<tflite::SVDFOptionsT *>(u.value)); break; } case BuiltinOptions_RNNOptions: { value = new tflite::RNNOptionsT(*reinterpret_cast<tflite::RNNOptionsT *>(u.value)); break; } case BuiltinOptions_FullyConnectedOptions: { value = new tflite::FullyConnectedOptionsT(*reinterpret_cast<tflite::FullyConnectedOptionsT *>(u.value)); break; } case BuiltinOptions_SoftmaxOptions: { value = new tflite::SoftmaxOptionsT(*reinterpret_cast<tflite::SoftmaxOptionsT *>(u.value)); break; } case BuiltinOptions_ConcatenationOptions: { value = new tflite::ConcatenationOptionsT(*reinterpret_cast<tflite::ConcatenationOptionsT *>(u.value)); break; } case BuiltinOptions_AddOptions: { value = new tflite::AddOptionsT(*reinterpret_cast<tflite::AddOptionsT *>(u.value)); break; } case BuiltinOptions_L2NormOptions: { value = new tflite::L2NormOptionsT(*reinterpret_cast<tflite::L2NormOptionsT *>(u.value)); break; } case BuiltinOptions_LocalResponseNormalizationOptions: { value = new tflite::LocalResponseNormalizationOptionsT(*reinterpret_cast<tflite::LocalResponseNormalizationOptionsT *>(u.value)); break; } case BuiltinOptions_LSTMOptions: { value = new tflite::LSTMOptionsT(*reinterpret_cast<tflite::LSTMOptionsT *>(u.value)); break; } case BuiltinOptions_ResizeBilinearOptions: { value = new tflite::ResizeBilinearOptionsT(*reinterpret_cast<tflite::ResizeBilinearOptionsT *>(u.value)); break; } case BuiltinOptions_CallOptions: { value = new tflite::CallOptionsT(*reinterpret_cast<tflite::CallOptionsT *>(u.value)); break; } case BuiltinOptions_ReshapeOptions: { value = new tflite::ReshapeOptionsT(*reinterpret_cast<tflite::ReshapeOptionsT *>(u.value)); break; } case BuiltinOptions_SkipGramOptions: { value = new tflite::SkipGramOptionsT(*reinterpret_cast<tflite::SkipGramOptionsT *>(u.value)); break; } case BuiltinOptions_SpaceToDepthOptions: { value = new tflite::SpaceToDepthOptionsT(*reinterpret_cast<tflite::SpaceToDepthOptionsT *>(u.value)); break; } case BuiltinOptions_EmbeddingLookupSparseOptions: { value = new tflite::EmbeddingLookupSparseOptionsT(*reinterpret_cast<tflite::EmbeddingLookupSparseOptionsT *>(u.value)); break; } case BuiltinOptions_MulOptions: { value = new tflite::MulOptionsT(*reinterpret_cast<tflite::MulOptionsT *>(u.value)); break; } case BuiltinOptions_PadOptions: { value = new tflite::PadOptionsT(*reinterpret_cast<tflite::PadOptionsT *>(u.value)); break; } case BuiltinOptions_GatherOptions: { value = new tflite::GatherOptionsT(*reinterpret_cast<tflite::GatherOptionsT *>(u.value)); break; } case BuiltinOptions_BatchToSpaceNDOptions: { value = new tflite::BatchToSpaceNDOptionsT(*reinterpret_cast<tflite::BatchToSpaceNDOptionsT *>(u.value)); break; } case BuiltinOptions_SpaceToBatchNDOptions: { value = new tflite::SpaceToBatchNDOptionsT(*reinterpret_cast<tflite::SpaceToBatchNDOptionsT *>(u.value)); break; } case BuiltinOptions_TransposeOptions: { value = new tflite::TransposeOptionsT(*reinterpret_cast<tflite::TransposeOptionsT *>(u.value)); break; } case BuiltinOptions_ReducerOptions: { value = new tflite::ReducerOptionsT(*reinterpret_cast<tflite::ReducerOptionsT *>(u.value)); break; } case BuiltinOptions_SubOptions: { value = new tflite::SubOptionsT(*reinterpret_cast<tflite::SubOptionsT *>(u.value)); break; } case BuiltinOptions_DivOptions: { value = new tflite::DivOptionsT(*reinterpret_cast<tflite::DivOptionsT *>(u.value)); break; } case BuiltinOptions_SqueezeOptions: { value = new tflite::SqueezeOptionsT(*reinterpret_cast<tflite::SqueezeOptionsT *>(u.value)); break; } case BuiltinOptions_SequenceRNNOptions: { value = new tflite::SequenceRNNOptionsT(*reinterpret_cast<tflite::SequenceRNNOptionsT *>(u.value)); break; } case BuiltinOptions_StridedSliceOptions: { value = new tflite::StridedSliceOptionsT(*reinterpret_cast<tflite::StridedSliceOptionsT *>(u.value)); break; } case BuiltinOptions_ExpOptions: { value = new tflite::ExpOptionsT(*reinterpret_cast<tflite::ExpOptionsT *>(u.value)); break; } case BuiltinOptions_TopKV2Options: { value = new tflite::TopKV2OptionsT(*reinterpret_cast<tflite::TopKV2OptionsT *>(u.value)); break; } case BuiltinOptions_SplitOptions: { value = new tflite::SplitOptionsT(*reinterpret_cast<tflite::SplitOptionsT *>(u.value)); break; } case BuiltinOptions_LogSoftmaxOptions: { value = new tflite::LogSoftmaxOptionsT(*reinterpret_cast<tflite::LogSoftmaxOptionsT *>(u.value)); break; } case BuiltinOptions_CastOptions: { value = new tflite::CastOptionsT(*reinterpret_cast<tflite::CastOptionsT *>(u.value)); break; } case BuiltinOptions_DequantizeOptions: { value = new tflite::DequantizeOptionsT(*reinterpret_cast<tflite::DequantizeOptionsT *>(u.value)); break; } case BuiltinOptions_MaximumMinimumOptions: { value = new tflite::MaximumMinimumOptionsT(*reinterpret_cast<tflite::MaximumMinimumOptionsT *>(u.value)); break; } case BuiltinOptions_ArgMaxOptions: { value = new tflite::ArgMaxOptionsT(*reinterpret_cast<tflite::ArgMaxOptionsT *>(u.value)); break; } case BuiltinOptions_LessOptions: { value = new tflite::LessOptionsT(*reinterpret_cast<tflite::LessOptionsT *>(u.value)); break; } case BuiltinOptions_NegOptions: { value = new tflite::NegOptionsT(*reinterpret_cast<tflite::NegOptionsT *>(u.value)); break; } case BuiltinOptions_PadV2Options: { value = new tflite::PadV2OptionsT(*reinterpret_cast<tflite::PadV2OptionsT *>(u.value)); break; } case BuiltinOptions_GreaterOptions: { value = new tflite::GreaterOptionsT(*reinterpret_cast<tflite::GreaterOptionsT *>(u.value)); break; } case BuiltinOptions_GreaterEqualOptions: { value = new tflite::GreaterEqualOptionsT(*reinterpret_cast<tflite::GreaterEqualOptionsT *>(u.value)); break; } case BuiltinOptions_LessEqualOptions: { value = new tflite::LessEqualOptionsT(*reinterpret_cast<tflite::LessEqualOptionsT *>(u.value)); break; } case BuiltinOptions_SelectOptions: { value = new tflite::SelectOptionsT(*reinterpret_cast<tflite::SelectOptionsT *>(u.value)); break; } case BuiltinOptions_SliceOptions: { value = new tflite::SliceOptionsT(*reinterpret_cast<tflite::SliceOptionsT *>(u.value)); break; } case BuiltinOptions_TransposeConvOptions: { value = new tflite::TransposeConvOptionsT(*reinterpret_cast<tflite::TransposeConvOptionsT *>(u.value)); break; } case BuiltinOptions_SparseToDenseOptions: { value = new tflite::SparseToDenseOptionsT(*reinterpret_cast<tflite::SparseToDenseOptionsT *>(u.value)); break; } case BuiltinOptions_TileOptions: { value = new tflite::TileOptionsT(*reinterpret_cast<tflite::TileOptionsT *>(u.value)); break; } case BuiltinOptions_ExpandDimsOptions: { value = new tflite::ExpandDimsOptionsT(*reinterpret_cast<tflite::ExpandDimsOptionsT *>(u.value)); break; } case BuiltinOptions_EqualOptions: { value = new tflite::EqualOptionsT(*reinterpret_cast<tflite::EqualOptionsT *>(u.value)); break; } case BuiltinOptions_NotEqualOptions: { value = new tflite::NotEqualOptionsT(*reinterpret_cast<tflite::NotEqualOptionsT *>(u.value)); break; } case BuiltinOptions_ShapeOptions: { value = new tflite::ShapeOptionsT(*reinterpret_cast<tflite::ShapeOptionsT *>(u.value)); break; } case BuiltinOptions_PowOptions: { value = new tflite::PowOptionsT(*reinterpret_cast<tflite::PowOptionsT *>(u.value)); break; } case BuiltinOptions_ArgMinOptions: { value = new tflite::ArgMinOptionsT(*reinterpret_cast<tflite::ArgMinOptionsT *>(u.value)); break; } case BuiltinOptions_FakeQuantOptions: { value = new tflite::FakeQuantOptionsT(*reinterpret_cast<tflite::FakeQuantOptionsT *>(u.value)); break; } case BuiltinOptions_PackOptions: { value = new tflite::PackOptionsT(*reinterpret_cast<tflite::PackOptionsT *>(u.value)); break; } case BuiltinOptions_LogicalOrOptions: { value = new tflite::LogicalOrOptionsT(*reinterpret_cast<tflite::LogicalOrOptionsT *>(u.value)); break; } case BuiltinOptions_OneHotOptions: { value = new tflite::OneHotOptionsT(*reinterpret_cast<tflite::OneHotOptionsT *>(u.value)); break; } case BuiltinOptions_LogicalAndOptions: { value = new tflite::LogicalAndOptionsT(*reinterpret_cast<tflite::LogicalAndOptionsT *>(u.value)); break; } case BuiltinOptions_LogicalNotOptions: { value = new tflite::LogicalNotOptionsT(*reinterpret_cast<tflite::LogicalNotOptionsT *>(u.value)); break; } case BuiltinOptions_UnpackOptions: { value = new tflite::UnpackOptionsT(*reinterpret_cast<tflite::UnpackOptionsT *>(u.value)); break; } case BuiltinOptions_FloorDivOptions: { value = new tflite::FloorDivOptionsT(*reinterpret_cast<tflite::FloorDivOptionsT *>(u.value)); break; } case BuiltinOptions_SquareOptions: { value = new tflite::SquareOptionsT(*reinterpret_cast<tflite::SquareOptionsT *>(u.value)); break; } case BuiltinOptions_ZerosLikeOptions: { value = new tflite::ZerosLikeOptionsT(*reinterpret_cast<tflite::ZerosLikeOptionsT *>(u.value)); break; } case BuiltinOptions_FillOptions: { value = new tflite::FillOptionsT(*reinterpret_cast<tflite::FillOptionsT *>(u.value)); break; } case BuiltinOptions_BidirectionalSequenceLSTMOptions: { value = new tflite::BidirectionalSequenceLSTMOptionsT(*reinterpret_cast<tflite::BidirectionalSequenceLSTMOptionsT *>(u.value)); break; } case BuiltinOptions_BidirectionalSequenceRNNOptions: { value = new tflite::BidirectionalSequenceRNNOptionsT(*reinterpret_cast<tflite::BidirectionalSequenceRNNOptionsT *>(u.value)); break; } case BuiltinOptions_UnidirectionalSequenceLSTMOptions: { value = new tflite::UnidirectionalSequenceLSTMOptionsT(*reinterpret_cast<tflite::UnidirectionalSequenceLSTMOptionsT *>(u.value)); break; } case BuiltinOptions_FloorModOptions: { value = new tflite::FloorModOptionsT(*reinterpret_cast<tflite::FloorModOptionsT *>(u.value)); break; } case BuiltinOptions_RangeOptions: { value = new tflite::RangeOptionsT(*reinterpret_cast<tflite::RangeOptionsT *>(u.value)); break; } case BuiltinOptions_ResizeNearestNeighborOptions: { value = new tflite::ResizeNearestNeighborOptionsT(*reinterpret_cast<tflite::ResizeNearestNeighborOptionsT *>(u.value)); break; } case BuiltinOptions_LeakyReluOptions: { value = new tflite::LeakyReluOptionsT(*reinterpret_cast<tflite::LeakyReluOptionsT *>(u.value)); break; } case BuiltinOptions_SquaredDifferenceOptions: { value = new tflite::SquaredDifferenceOptionsT(*reinterpret_cast<tflite::SquaredDifferenceOptionsT *>(u.value)); break; } case BuiltinOptions_MirrorPadOptions: { value = new tflite::MirrorPadOptionsT(*reinterpret_cast<tflite::MirrorPadOptionsT *>(u.value)); break; } case BuiltinOptions_AbsOptions: { value = new tflite::AbsOptionsT(*reinterpret_cast<tflite::AbsOptionsT *>(u.value)); break; } case BuiltinOptions_SplitVOptions: { value = new tflite::SplitVOptionsT(*reinterpret_cast<tflite::SplitVOptionsT *>(u.value)); break; } case BuiltinOptions_UniqueOptions: { value = new tflite::UniqueOptionsT(*reinterpret_cast<tflite::UniqueOptionsT *>(u.value)); break; } case BuiltinOptions_ReverseV2Options: { value = new tflite::ReverseV2OptionsT(*reinterpret_cast<tflite::ReverseV2OptionsT *>(u.value)); break; } case BuiltinOptions_AddNOptions: { value = new tflite::AddNOptionsT(*reinterpret_cast<tflite::AddNOptionsT *>(u.value)); break; } case BuiltinOptions_GatherNdOptions: { value = new tflite::GatherNdOptionsT(*reinterpret_cast<tflite::GatherNdOptionsT *>(u.value)); break; } case BuiltinOptions_CosOptions: { value = new tflite::CosOptionsT(*reinterpret_cast<tflite::CosOptionsT *>(u.value)); break; } case BuiltinOptions_WhereOptions: { value = new tflite::WhereOptionsT(*reinterpret_cast<tflite::WhereOptionsT *>(u.value)); break; } case BuiltinOptions_RankOptions: { value = new tflite::RankOptionsT(*reinterpret_cast<tflite::RankOptionsT *>(u.value)); break; } case BuiltinOptions_ReverseSequenceOptions: { value = new tflite::ReverseSequenceOptionsT(*reinterpret_cast<tflite::ReverseSequenceOptionsT *>(u.value)); break; } case BuiltinOptions_MatrixDiagOptions: { value = new tflite::MatrixDiagOptionsT(*reinterpret_cast<tflite::MatrixDiagOptionsT *>(u.value)); break; } case BuiltinOptions_QuantizeOptions: { value = new tflite::QuantizeOptionsT(*reinterpret_cast<tflite::QuantizeOptionsT *>(u.value)); break; } case BuiltinOptions_MatrixSetDiagOptions: { value = new tflite::MatrixSetDiagOptionsT(*reinterpret_cast<tflite::MatrixSetDiagOptionsT *>(u.value)); break; } case BuiltinOptions_HardSwishOptions: { value = new tflite::HardSwishOptionsT(*reinterpret_cast<tflite::HardSwishOptionsT *>(u.value)); break; } case BuiltinOptions_IfOptions: { value = new tflite::IfOptionsT(*reinterpret_cast<tflite::IfOptionsT *>(u.value)); break; } case BuiltinOptions_WhileOptions: { value = new tflite::WhileOptionsT(*reinterpret_cast<tflite::WhileOptionsT *>(u.value)); break; } case BuiltinOptions_DepthToSpaceOptions: { value = new tflite::DepthToSpaceOptionsT(*reinterpret_cast<tflite::DepthToSpaceOptionsT *>(u.value)); break; } case BuiltinOptions_NonMaxSuppressionV4Options: { value = new tflite::NonMaxSuppressionV4OptionsT(*reinterpret_cast<tflite::NonMaxSuppressionV4OptionsT *>(u.value)); break; } case BuiltinOptions_NonMaxSuppressionV5Options: { value = new tflite::NonMaxSuppressionV5OptionsT(*reinterpret_cast<tflite::NonMaxSuppressionV5OptionsT *>(u.value)); break; } case BuiltinOptions_ScatterNdOptions: { value = new tflite::ScatterNdOptionsT(*reinterpret_cast<tflite::ScatterNdOptionsT *>(u.value)); break; } case BuiltinOptions_SelectV2Options: { value = new tflite::SelectV2OptionsT(*reinterpret_cast<tflite::SelectV2OptionsT *>(u.value)); break; } case BuiltinOptions_DensifyOptions: { value = new tflite::DensifyOptionsT(*reinterpret_cast<tflite::DensifyOptionsT *>(u.value)); break; } case BuiltinOptions_SegmentSumOptions: { value = new tflite::SegmentSumOptionsT(*reinterpret_cast<tflite::SegmentSumOptionsT *>(u.value)); break; } case BuiltinOptions_BatchMatMulOptions: { value = new tflite::BatchMatMulOptionsT(*reinterpret_cast<tflite::BatchMatMulOptionsT *>(u.value)); break; } case BuiltinOptions_CumsumOptions: { value = new tflite::CumsumOptionsT(*reinterpret_cast<tflite::CumsumOptionsT *>(u.value)); break; } case BuiltinOptions_CallOnceOptions: { value = new tflite::CallOnceOptionsT(*reinterpret_cast<tflite::CallOnceOptionsT *>(u.value)); break; } case BuiltinOptions_BroadcastToOptions: { value = new tflite::BroadcastToOptionsT(*reinterpret_cast<tflite::BroadcastToOptionsT *>(u.value)); break; } case BuiltinOptions_Rfft2dOptions: { value = new tflite::Rfft2dOptionsT(*reinterpret_cast<tflite::Rfft2dOptionsT *>(u.value)); break; } case BuiltinOptions_Conv3DOptions: { value = new tflite::Conv3DOptionsT(*reinterpret_cast<tflite::Conv3DOptionsT *>(u.value)); break; } case BuiltinOptions_HashtableOptions: { value = new tflite::HashtableOptionsT(*reinterpret_cast<tflite::HashtableOptionsT *>(u.value)); break; } case BuiltinOptions_HashtableFindOptions: { value = new tflite::HashtableFindOptionsT(*reinterpret_cast<tflite::HashtableFindOptionsT *>(u.value)); break; } case BuiltinOptions_HashtableImportOptions: { value = new tflite::HashtableImportOptionsT(*reinterpret_cast<tflite::HashtableImportOptionsT *>(u.value)); break; } case BuiltinOptions_HashtableSizeOptions: { value = new tflite::HashtableSizeOptionsT(*reinterpret_cast<tflite::HashtableSizeOptionsT *>(u.value)); break; } default: break; } } inline void BuiltinOptionsUnion::Reset() { switch (type) { case BuiltinOptions_Conv2DOptions: { auto ptr = reinterpret_cast<tflite::Conv2DOptionsT *>(value); delete ptr; break; } case BuiltinOptions_DepthwiseConv2DOptions: { auto ptr = reinterpret_cast<tflite::DepthwiseConv2DOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ConcatEmbeddingsOptions: { auto ptr = reinterpret_cast<tflite::ConcatEmbeddingsOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LSHProjectionOptions: { auto ptr = reinterpret_cast<tflite::LSHProjectionOptionsT *>(value); delete ptr; break; } case BuiltinOptions_Pool2DOptions: { auto ptr = reinterpret_cast<tflite::Pool2DOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SVDFOptions: { auto ptr = reinterpret_cast<tflite::SVDFOptionsT *>(value); delete ptr; break; } case BuiltinOptions_RNNOptions: { auto ptr = reinterpret_cast<tflite::RNNOptionsT *>(value); delete ptr; break; } case BuiltinOptions_FullyConnectedOptions: { auto ptr = reinterpret_cast<tflite::FullyConnectedOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SoftmaxOptions: { auto ptr = reinterpret_cast<tflite::SoftmaxOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ConcatenationOptions: { auto ptr = reinterpret_cast<tflite::ConcatenationOptionsT *>(value); delete ptr; break; } case BuiltinOptions_AddOptions: { auto ptr = reinterpret_cast<tflite::AddOptionsT *>(value); delete ptr; break; } case BuiltinOptions_L2NormOptions: { auto ptr = reinterpret_cast<tflite::L2NormOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LocalResponseNormalizationOptions: { auto ptr = reinterpret_cast<tflite::LocalResponseNormalizationOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LSTMOptions: { auto ptr = reinterpret_cast<tflite::LSTMOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ResizeBilinearOptions: { auto ptr = reinterpret_cast<tflite::ResizeBilinearOptionsT *>(value); delete ptr; break; } case BuiltinOptions_CallOptions: { auto ptr = reinterpret_cast<tflite::CallOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ReshapeOptions: { auto ptr = reinterpret_cast<tflite::ReshapeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SkipGramOptions: { auto ptr = reinterpret_cast<tflite::SkipGramOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SpaceToDepthOptions: { auto ptr = reinterpret_cast<tflite::SpaceToDepthOptionsT *>(value); delete ptr; break; } case BuiltinOptions_EmbeddingLookupSparseOptions: { auto ptr = reinterpret_cast<tflite::EmbeddingLookupSparseOptionsT *>(value); delete ptr; break; } case BuiltinOptions_MulOptions: { auto ptr = reinterpret_cast<tflite::MulOptionsT *>(value); delete ptr; break; } case BuiltinOptions_PadOptions: { auto ptr = reinterpret_cast<tflite::PadOptionsT *>(value); delete ptr; break; } case BuiltinOptions_GatherOptions: { auto ptr = reinterpret_cast<tflite::GatherOptionsT *>(value); delete ptr; break; } case BuiltinOptions_BatchToSpaceNDOptions: { auto ptr = reinterpret_cast<tflite::BatchToSpaceNDOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SpaceToBatchNDOptions: { auto ptr = reinterpret_cast<tflite::SpaceToBatchNDOptionsT *>(value); delete ptr; break; } case BuiltinOptions_TransposeOptions: { auto ptr = reinterpret_cast<tflite::TransposeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ReducerOptions: { auto ptr = reinterpret_cast<tflite::ReducerOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SubOptions: { auto ptr = reinterpret_cast<tflite::SubOptionsT *>(value); delete ptr; break; } case BuiltinOptions_DivOptions: { auto ptr = reinterpret_cast<tflite::DivOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SqueezeOptions: { auto ptr = reinterpret_cast<tflite::SqueezeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SequenceRNNOptions: { auto ptr = reinterpret_cast<tflite::SequenceRNNOptionsT *>(value); delete ptr; break; } case BuiltinOptions_StridedSliceOptions: { auto ptr = reinterpret_cast<tflite::StridedSliceOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ExpOptions: { auto ptr = reinterpret_cast<tflite::ExpOptionsT *>(value); delete ptr; break; } case BuiltinOptions_TopKV2Options: { auto ptr = reinterpret_cast<tflite::TopKV2OptionsT *>(value); delete ptr; break; } case BuiltinOptions_SplitOptions: { auto ptr = reinterpret_cast<tflite::SplitOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LogSoftmaxOptions: { auto ptr = reinterpret_cast<tflite::LogSoftmaxOptionsT *>(value); delete ptr; break; } case BuiltinOptions_CastOptions: { auto ptr = reinterpret_cast<tflite::CastOptionsT *>(value); delete ptr; break; } case BuiltinOptions_DequantizeOptions: { auto ptr = reinterpret_cast<tflite::DequantizeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_MaximumMinimumOptions: { auto ptr = reinterpret_cast<tflite::MaximumMinimumOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ArgMaxOptions: { auto ptr = reinterpret_cast<tflite::ArgMaxOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LessOptions: { auto ptr = reinterpret_cast<tflite::LessOptionsT *>(value); delete ptr; break; } case BuiltinOptions_NegOptions: { auto ptr = reinterpret_cast<tflite::NegOptionsT *>(value); delete ptr; break; } case BuiltinOptions_PadV2Options: { auto ptr = reinterpret_cast<tflite::PadV2OptionsT *>(value); delete ptr; break; } case BuiltinOptions_GreaterOptions: { auto ptr = reinterpret_cast<tflite::GreaterOptionsT *>(value); delete ptr; break; } case BuiltinOptions_GreaterEqualOptions: { auto ptr = reinterpret_cast<tflite::GreaterEqualOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LessEqualOptions: { auto ptr = reinterpret_cast<tflite::LessEqualOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SelectOptions: { auto ptr = reinterpret_cast<tflite::SelectOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SliceOptions: { auto ptr = reinterpret_cast<tflite::SliceOptionsT *>(value); delete ptr; break; } case BuiltinOptions_TransposeConvOptions: { auto ptr = reinterpret_cast<tflite::TransposeConvOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SparseToDenseOptions: { auto ptr = reinterpret_cast<tflite::SparseToDenseOptionsT *>(value); delete ptr; break; } case BuiltinOptions_TileOptions: { auto ptr = reinterpret_cast<tflite::TileOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ExpandDimsOptions: { auto ptr = reinterpret_cast<tflite::ExpandDimsOptionsT *>(value); delete ptr; break; } case BuiltinOptions_EqualOptions: { auto ptr = reinterpret_cast<tflite::EqualOptionsT *>(value); delete ptr; break; } case BuiltinOptions_NotEqualOptions: { auto ptr = reinterpret_cast<tflite::NotEqualOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ShapeOptions: { auto ptr = reinterpret_cast<tflite::ShapeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_PowOptions: { auto ptr = reinterpret_cast<tflite::PowOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ArgMinOptions: { auto ptr = reinterpret_cast<tflite::ArgMinOptionsT *>(value); delete ptr; break; } case BuiltinOptions_FakeQuantOptions: { auto ptr = reinterpret_cast<tflite::FakeQuantOptionsT *>(value); delete ptr; break; } case BuiltinOptions_PackOptions: { auto ptr = reinterpret_cast<tflite::PackOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LogicalOrOptions: { auto ptr = reinterpret_cast<tflite::LogicalOrOptionsT *>(value); delete ptr; break; } case BuiltinOptions_OneHotOptions: { auto ptr = reinterpret_cast<tflite::OneHotOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LogicalAndOptions: { auto ptr = reinterpret_cast<tflite::LogicalAndOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LogicalNotOptions: { auto ptr = reinterpret_cast<tflite::LogicalNotOptionsT *>(value); delete ptr; break; } case BuiltinOptions_UnpackOptions: { auto ptr = reinterpret_cast<tflite::UnpackOptionsT *>(value); delete ptr; break; } case BuiltinOptions_FloorDivOptions: { auto ptr = reinterpret_cast<tflite::FloorDivOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SquareOptions: { auto ptr = reinterpret_cast<tflite::SquareOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ZerosLikeOptions: { auto ptr = reinterpret_cast<tflite::ZerosLikeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_FillOptions: { auto ptr = reinterpret_cast<tflite::FillOptionsT *>(value); delete ptr; break; } case BuiltinOptions_BidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<tflite::BidirectionalSequenceLSTMOptionsT *>(value); delete ptr; break; } case BuiltinOptions_BidirectionalSequenceRNNOptions: { auto ptr = reinterpret_cast<tflite::BidirectionalSequenceRNNOptionsT *>(value); delete ptr; break; } case BuiltinOptions_UnidirectionalSequenceLSTMOptions: { auto ptr = reinterpret_cast<tflite::UnidirectionalSequenceLSTMOptionsT *>(value); delete ptr; break; } case BuiltinOptions_FloorModOptions: { auto ptr = reinterpret_cast<tflite::FloorModOptionsT *>(value); delete ptr; break; } case BuiltinOptions_RangeOptions: { auto ptr = reinterpret_cast<tflite::RangeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ResizeNearestNeighborOptions: { auto ptr = reinterpret_cast<tflite::ResizeNearestNeighborOptionsT *>(value); delete ptr; break; } case BuiltinOptions_LeakyReluOptions: { auto ptr = reinterpret_cast<tflite::LeakyReluOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SquaredDifferenceOptions: { auto ptr = reinterpret_cast<tflite::SquaredDifferenceOptionsT *>(value); delete ptr; break; } case BuiltinOptions_MirrorPadOptions: { auto ptr = reinterpret_cast<tflite::MirrorPadOptionsT *>(value); delete ptr; break; } case BuiltinOptions_AbsOptions: { auto ptr = reinterpret_cast<tflite::AbsOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SplitVOptions: { auto ptr = reinterpret_cast<tflite::SplitVOptionsT *>(value); delete ptr; break; } case BuiltinOptions_UniqueOptions: { auto ptr = reinterpret_cast<tflite::UniqueOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ReverseV2Options: { auto ptr = reinterpret_cast<tflite::ReverseV2OptionsT *>(value); delete ptr; break; } case BuiltinOptions_AddNOptions: { auto ptr = reinterpret_cast<tflite::AddNOptionsT *>(value); delete ptr; break; } case BuiltinOptions_GatherNdOptions: { auto ptr = reinterpret_cast<tflite::GatherNdOptionsT *>(value); delete ptr; break; } case BuiltinOptions_CosOptions: { auto ptr = reinterpret_cast<tflite::CosOptionsT *>(value); delete ptr; break; } case BuiltinOptions_WhereOptions: { auto ptr = reinterpret_cast<tflite::WhereOptionsT *>(value); delete ptr; break; } case BuiltinOptions_RankOptions: { auto ptr = reinterpret_cast<tflite::RankOptionsT *>(value); delete ptr; break; } case BuiltinOptions_ReverseSequenceOptions: { auto ptr = reinterpret_cast<tflite::ReverseSequenceOptionsT *>(value); delete ptr; break; } case BuiltinOptions_MatrixDiagOptions: { auto ptr = reinterpret_cast<tflite::MatrixDiagOptionsT *>(value); delete ptr; break; } case BuiltinOptions_QuantizeOptions: { auto ptr = reinterpret_cast<tflite::QuantizeOptionsT *>(value); delete ptr; break; } case BuiltinOptions_MatrixSetDiagOptions: { auto ptr = reinterpret_cast<tflite::MatrixSetDiagOptionsT *>(value); delete ptr; break; } case BuiltinOptions_HardSwishOptions: { auto ptr = reinterpret_cast<tflite::HardSwishOptionsT *>(value); delete ptr; break; } case BuiltinOptions_IfOptions: { auto ptr = reinterpret_cast<tflite::IfOptionsT *>(value); delete ptr; break; } case BuiltinOptions_WhileOptions: { auto ptr = reinterpret_cast<tflite::WhileOptionsT *>(value); delete ptr; break; } case BuiltinOptions_DepthToSpaceOptions: { auto ptr = reinterpret_cast<tflite::DepthToSpaceOptionsT *>(value); delete ptr; break; } case BuiltinOptions_NonMaxSuppressionV4Options: { auto ptr = reinterpret_cast<tflite::NonMaxSuppressionV4OptionsT *>(value); delete ptr; break; } case BuiltinOptions_NonMaxSuppressionV5Options: { auto ptr = reinterpret_cast<tflite::NonMaxSuppressionV5OptionsT *>(value); delete ptr; break; } case BuiltinOptions_ScatterNdOptions: { auto ptr = reinterpret_cast<tflite::ScatterNdOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SelectV2Options: { auto ptr = reinterpret_cast<tflite::SelectV2OptionsT *>(value); delete ptr; break; } case BuiltinOptions_DensifyOptions: { auto ptr = reinterpret_cast<tflite::DensifyOptionsT *>(value); delete ptr; break; } case BuiltinOptions_SegmentSumOptions: { auto ptr = reinterpret_cast<tflite::SegmentSumOptionsT *>(value); delete ptr; break; } case BuiltinOptions_BatchMatMulOptions: { auto ptr = reinterpret_cast<tflite::BatchMatMulOptionsT *>(value); delete ptr; break; } case BuiltinOptions_CumsumOptions: { auto ptr = reinterpret_cast<tflite::CumsumOptionsT *>(value); delete ptr; break; } case BuiltinOptions_CallOnceOptions: { auto ptr = reinterpret_cast<tflite::CallOnceOptionsT *>(value); delete ptr; break; } case BuiltinOptions_BroadcastToOptions: { auto ptr = reinterpret_cast<tflite::BroadcastToOptionsT *>(value); delete ptr; break; } case BuiltinOptions_Rfft2dOptions: { auto ptr = reinterpret_cast<tflite::Rfft2dOptionsT *>(value); delete ptr; break; } case BuiltinOptions_Conv3DOptions: { auto ptr = reinterpret_cast<tflite::Conv3DOptionsT *>(value); delete ptr; break; } case BuiltinOptions_HashtableOptions: { auto ptr = reinterpret_cast<tflite::HashtableOptionsT *>(value); delete ptr; break; } case BuiltinOptions_HashtableFindOptions: { auto ptr = reinterpret_cast<tflite::HashtableFindOptionsT *>(value); delete ptr; break; } case BuiltinOptions_HashtableImportOptions: { auto ptr = reinterpret_cast<tflite::HashtableImportOptionsT *>(value); delete ptr; break; } case BuiltinOptions_HashtableSizeOptions: { auto ptr = reinterpret_cast<tflite::HashtableSizeOptionsT *>(value); delete ptr; break; } default: break; } value = nullptr; type = BuiltinOptions_NONE; } inline const tflite::Model *GetModel(const void *buf) { return flatbuffers::GetRoot<tflite::Model>(buf); } inline const tflite::Model *GetSizePrefixedModel(const void *buf) { return flatbuffers::GetSizePrefixedRoot<tflite::Model>(buf); } inline const char *ModelIdentifier() { return "TFL3"; } inline bool ModelBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier( buf, ModelIdentifier()); } inline bool VerifyModelBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<tflite::Model>(ModelIdentifier()); } inline bool VerifySizePrefixedModelBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifySizePrefixedBuffer<tflite::Model>(ModelIdentifier()); } inline const char *ModelExtension() { return "tflite"; } inline void FinishModelBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<tflite::Model> root) { fbb.Finish(root, ModelIdentifier()); } inline void FinishSizePrefixedModelBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<tflite::Model> root) { fbb.FinishSizePrefixed(root, ModelIdentifier()); } inline std::unique_ptr<tflite::ModelT> UnPackModel( const void *buf, const flatbuffers::resolver_function_t *res = nullptr) { return std::unique_ptr<tflite::ModelT>(GetModel(buf)->UnPack(res)); } inline std::unique_ptr<tflite::ModelT> UnPackSizePrefixedModel( const void *buf, const flatbuffers::resolver_function_t *res = nullptr) { return std::unique_ptr<tflite::ModelT>(GetSizePrefixedModel(buf)->UnPack(res)); } } // namespace tflite #endif // FLATBUFFERS_GENERATED_SCHEMA_TFLITE_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/schema/schema_generated.h
C++
apache-2.0
746,558
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 "tensorflow/lite/schema/schema_utils.h" #include <algorithm> #include "tensorflow/lite/kernels/internal/compatibility.h" namespace tflite { // The following GetBuiltinCode methods are the utility methods for reading // builtin operatore code, ensuring compatibility issues between v3 and v3a // schema. Always the maximum value of the two fields always will be the correct // value as follows: // // - Supporting schema version v3 models // // The `builtin_code` field is not available in the v3 models. Flatbuffer // library will feed zero value, which is the default value in the v3a schema. // The actual builtin operatore code value will exist in the // `deprecated_builtin_code` field. At the same time, it implies that // `deprecated_builtin_code` >= `builtin_code` and the maximum value of the two // fields will be same with `deprecated_builtin_code'. // // - Supporting builtin operator codes beyonds 127 // // New builtin operators, whose operator code is larger than 127, can not be // assigned to the `deprecated_builtin_code` field. In such cases, the // value of the `builtin_code` field should be used for the builtin operator // code. In the case, the maximum value of the two fields will be the value of // the `builtin_code` as the right value. BuiltinOperator GetBuiltinCode(const OperatorCode* op_code) { // Caller should guarantee that the given argument value is not a nullptr. TFLITE_DCHECK(op_code != nullptr); return std::max( op_code->builtin_code(), static_cast<BuiltinOperator>(op_code->deprecated_builtin_code())); } BuiltinOperator GetBuiltinCode(const OperatorCodeT* op_code) { // Caller should guarantee that the given argument value is not a nullptr. TFLITE_DCHECK(op_code != nullptr); return std::max(op_code->builtin_code, static_cast<BuiltinOperator>( op_code->deprecated_builtin_code)); } } // namespace tflite
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/schema/schema_utils.cc
C++
apache-2.0
2,605
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_ #define TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_ #include "flatbuffers/flatbuffers.h" #include "tensorflow/lite/schema/schema_generated.h" namespace tflite { // The following methods are introduced to resolve op builtin code shortage // problem. The new builtin operator will be assigned to the extended builtin // code field in the flatbuffer schema. Those methods helps to hide builtin code // details. BuiltinOperator GetBuiltinCode(const OperatorCode *op_code); BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code); } // namespace tflite #endif // TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/schema/schema_utils.h
C++
apache-2.0
1,321
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_SHARED_LIBRARY_H_ #define TENSORFLOW_LITE_SHARED_LIBRARY_H_ #if defined(_WIN32) // Windows does not have dlfcn.h/dlsym, use GetProcAddress() instead. #include <windows.h> #else #include <dlfcn.h> #endif // defined(_WIN32) namespace tflite { // SharedLibrary provides a uniform set of APIs across different platforms to // handle dynamic library operations class SharedLibrary { public: #if defined(_WIN32) static inline void* LoadLibrary(const char* lib) { return ::LoadLibrary(lib); } static inline void* GetLibrarySymbol(void* handle, const char* symbol) { return reinterpret_cast<void*>( GetProcAddress(static_cast<HMODULE>(handle), symbol)); } // Warning: Unlike dlsym(RTLD_DEFAULT), it doesn't search the symbol from // dependent DLLs. static inline void* GetSymbol(const char* symbol) { return reinterpret_cast<void*>(GetProcAddress(nullptr, symbol)); } static inline int UnLoadLibrary(void* handle) { return FreeLibrary(static_cast<HMODULE>(handle)); } static inline const char* GetError() { return "Unknown"; } #else static inline void* LoadLibrary(const char* lib) { return dlopen(lib, RTLD_LAZY | RTLD_LOCAL); } static inline void* GetLibrarySymbol(void* handle, const char* symbol) { return dlsym(handle, symbol); } static inline void* GetSymbol(const char* symbol) { return dlsym(RTLD_DEFAULT, symbol); } static inline int UnLoadLibrary(void* handle) { return dlclose(handle); } static inline const char* GetError() { return dlerror(); } #endif // defined(_WIN32) }; } // namespace tflite #endif // TENSORFLOW_LITE_SHARED_LIBRARY_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/shared_library.h
C++
apache-2.0
2,322
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_SIMPLE_MEMORY_ARENA_H_ #define TENSORFLOW_LITE_SIMPLE_MEMORY_ARENA_H_ #include <stddef.h> #include <cstdint> #include <memory> #include <vector> #include "tensorflow/lite/c/common.h" namespace tflite { // This little structure holds the offset and the size for a dynamic memory // allocation in the memory arena as well as first_node and last_node that use // corresponding tensor. It means that continuous part of memory with this size // needs to be allocated before execution of operation in the first node and can // be deallocated after execution of the operation in the last_node. When the // arena is committed and the underlying buffer is set, the alloc can be // resolved into an actual memory pointer. struct ArenaAllocWithUsageInterval { ArenaAllocWithUsageInterval() { reset(); } size_t offset; size_t size; int32_t tensor; int32_t first_node; int32_t last_node; inline void reset() { offset = 0; size = 0; tensor = -1; first_node = -1; last_node = -1; } inline bool operator<(const ArenaAllocWithUsageInterval& other) const { return offset < other.offset; } }; // This small class is responsible for allocating, deallocating and reusing // dynamic memory from a common underlying buffer. The arena can be used in // scenarios when the pattern of memory allocations and deallocations is // repetitive, e.g. running NN inference in multiple iterations. Note that // zero-sized allocations are explicitly allowed, and will resolve to null. class SimpleMemoryArena { public: explicit SimpleMemoryArena(size_t arena_alignment) : committed_(false), arena_alignment_(arena_alignment), high_water_mark_(0), underlying_buffer_size_(0), ordered_allocs_() {} // Schedule memory allocation for a tensor with a given size, assuming that it // needs to be allocated before the execution of first_node, and deallocated // after the execution of last_node. TfLiteStatus Allocate(TfLiteContext* context, size_t alignment, size_t size, int32_t tensor, int32_t first_node, int32_t last_node, ArenaAllocWithUsageInterval* new_alloc); TfLiteStatus Deallocate(TfLiteContext* context, const ArenaAllocWithUsageInterval& alloc); inline size_t RequiredBufferSize() { // Add in a small amount of padding to reduce the chance of resize events // for small allocations. size_t padding = arena_alignment_; return arena_alignment_ + high_water_mark_ + padding; } TfLiteStatus Commit(TfLiteContext* context); TfLiteStatus ResolveAlloc(TfLiteContext* context, const ArenaAllocWithUsageInterval& alloc, char** output_ptr); // This clears allocation details but does not release the underlying buffer. // New allocations should be committed & resolved before using this arena // again. TfLiteStatus ClearPlan(); // This releases the underlying buffer but does not clear the allocation plan. // Since all associated pointers are invalidated, the arena cannot be used // again until Commit() is called & tensor allocations are resolved. TfLiteStatus ReleaseBuffer(); size_t GetBufferSize() { return underlying_buffer_size_; } std::intptr_t BasePointer() const { return reinterpret_cast<std::intptr_t>(underlying_buffer_aligned_ptr_); } private: bool committed_; size_t arena_alignment_; size_t high_water_mark_; std::unique_ptr<char[]> underlying_buffer_; size_t underlying_buffer_size_; char* underlying_buffer_aligned_ptr_; std::vector<ArenaAllocWithUsageInterval> ordered_allocs_; }; } // namespace tflite #endif // TENSORFLOW_LITE_SIMPLE_MEMORY_ARENA_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/simple_memory_arena.h
C++
apache-2.0
4,441
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_STATEFUL_ERROR_REPORTER_H_ #define TENSORFLOW_LITE_STATEFUL_ERROR_REPORTER_H_ #include <string> #include "tensorflow/lite/core/api/error_reporter.h" namespace tflite { // Similar to tflite::ErrorReporter, except that it allows callers to get the // last error message. class StatefulErrorReporter : public ErrorReporter { public: // Returns last error message. Returns empty string if no error is reported. virtual std::string message() = 0; }; } // namespace tflite #endif // TENSORFLOW_LITE_STATEFUL_ERROR_REPORTER_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/stateful_error_reporter.h
C++
apache-2.0
1,226
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_STDERR_REPORTER_H_ #define TENSORFLOW_LITE_STDERR_REPORTER_H_ #include <cstdarg> #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/core/api/error_reporter.h" namespace tflite { // An error reporter that simply writes the message to stderr. struct StderrReporter : public ErrorReporter { int Report(const char* format, va_list args) override; }; // Return the default error reporter (output to stderr). ErrorReporter* DefaultErrorReporter(); } // namespace tflite #endif // TENSORFLOW_LITE_STDERR_REPORTER_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/stderr_reporter.h
C++
apache-2.0
1,226
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ // Abstract string. We don't want even absl at this level. #ifndef TENSORFLOW_LITE_STRING_TYPE_H_ #define TENSORFLOW_LITE_STRING_TYPE_H_ #include <string> namespace tflite { using std::string; } // namespace tflite #endif // TENSORFLOW_LITE_STRING_TYPE_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/string_type.h
C++
apache-2.0
932
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ // Util methods to read and write String tensors. // String tensors are considered to be char tensor with protocol. // [0, 3] 4 bytes: N, num of strings in the tensor in little endian. // [(i+1)*4, (i+1)*4+3] 4 bytes: offset of i-th string in little endian, // for i from 0 to N-1. // [(N+1)*4, (N+1)*4+3] 4 bytes: length of the whole char buffer. // [offset(i), offset(i+1) - 1] : content of i-th string. // Example of a string tensor: // [ // 2, 0, 0, 0, # 2 strings. // 16, 0, 0, 0, # 0-th string starts from index 16. // 18, 0, 0, 0, # 1-st string starts from index 18. // 18, 0, 0, 0, # total length of array. // 'A', 'B', # 0-th string [16..17]: "AB" // ] # 1-th string, empty // // A typical usage: // In op.Eval(context, node): // DynamicBuffer buf; // # Add string "AB" to tensor, string is stored in dynamic buffer. // buf.AddString("AB", 2); // # Write content of DynamicBuffer to tensor in format of string tensor // # described above. // buf.WriteToTensor(tensor, nullptr) #ifndef TENSORFLOW_LITE_STRING_UTIL_H_ #define TENSORFLOW_LITE_STRING_UTIL_H_ #include <stddef.h> #include <stdint.h> #include <vector> #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/string_type.h" namespace tflite { // Convenient structure to store string pointer and length. typedef struct { const char* str; int len; } StringRef; // DynamicBuffer holds temporary buffer that will be used to create a dynamic // tensor. A typical usage is to initialize a DynamicBuffer object, fill in // content and call CreateStringTensor in op.Eval(). class DynamicBuffer { public: DynamicBuffer() : offset_({0}) {} // Add string to dynamic buffer by resizing the buffer and copying the data. void AddString(const StringRef& string); // Add string to dynamic buffer by resizing the buffer and copying the data. void AddString(const char* str, size_t len); // Join a list of string with separator, and add as a single string to the // buffer. void AddJoinedString(const std::vector<StringRef>& strings, char separator); void AddJoinedString(const std::vector<StringRef>& strings, StringRef separator); // Fill content into a buffer and returns the number of bytes stored. // The function allocates space for the buffer but does NOT take ownership. int WriteToBuffer(char** buffer); // Fill content into a string tensor, with the given new_shape. The new shape // must match the number of strings in this object. Caller relinquishes // ownership of new_shape. If 'new_shape' is nullptr, keep the tensor's // existing shape. void WriteToTensor(TfLiteTensor* tensor, TfLiteIntArray* new_shape); // Fill content into a string tensor. Set shape to {num_strings}. void WriteToTensorAsVector(TfLiteTensor* tensor); private: // Data buffer to store contents of strings, not including headers. std::vector<char> data_; // Offset of the starting index of each string in data buffer. std::vector<int32_t> offset_; }; // Return num of strings in a String tensor. int GetStringCount(const void* raw_buffer); int GetStringCount(const TfLiteTensor* tensor); // Get String pointer and length of index-th string in tensor. // NOTE: This will not create a copy of string data. StringRef GetString(const void* raw_buffer, int string_index); StringRef GetString(const TfLiteTensor* tensor, int string_index); } // namespace tflite #endif // TENSORFLOW_LITE_STRING_UTIL_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/string_util.h
C++
apache-2.0
4,203
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_TFLITE_WITH_XNNPACK_OPTIONAL_H_ #define TENSORFLOW_LITE_TFLITE_WITH_XNNPACK_OPTIONAL_H_ #include <memory> #include "tensorflow/lite/c/common.h" namespace tflite { std::unique_ptr<TfLiteDelegate, void (*)(TfLiteDelegate*)> MaybeCreateXNNPACKDelegate(int num_threads); } // namespace tflite #endif // TENSORFLOW_LITE_TFLITE_WITH_XNNPACK_OPTIONAL_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/tflite_with_xnnpack_optional.h
C++
apache-2.0
1,045
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_TYPE_TO_TFLITETYPE_H_ #define TENSORFLOW_LITE_TYPE_TO_TFLITETYPE_H_ #include <complex> #include <string> #include "tensorflow/lite/c/common.h" // Most of the definitions have been moved to this subheader so that Micro // can include it without relying on <string> and <complex>, which isn't // available on all platforms. #include "tensorflow/lite/portable_type_to_tflitetype.h" namespace tflite { // TODO(b/163167649): This string conversion means that only the first entry // in a string tensor will be returned as a std::string, so it's deprecated. MATCH_TYPE_AND_TFLITE_TYPE(std::string, kTfLiteString); MATCH_TYPE_AND_TFLITE_TYPE(std::complex<float>, kTfLiteComplex64); MATCH_TYPE_AND_TFLITE_TYPE(std::complex<double>, kTfLiteComplex128); } // namespace tflite #endif // TENSORFLOW_LITE_TYPE_TO_TFLITETYPE_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/type_to_tflitetype.h
C++
apache-2.0
1,516
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ // This file provides general C++ utility functions in TFLite. // For example: Converting between `TfLiteIntArray`, `std::vector` and // Flatbuffer vectors. These functions can't live in `context.h` since it's pure // C. #ifndef TENSORFLOW_LITE_UTIL_H_ #define TENSORFLOW_LITE_UTIL_H_ #include <stddef.h> #include <initializer_list> #include <memory> #include <string> #include <vector> #include "tensorflow/lite/c/common.h" namespace tflite { // Memory allocation parameter used by ArenaPlanner. // Clients (such as delegates) might look at this to ensure interop between // TFLite memory & hardware buffers. // NOTE: This only holds for tensors allocated on the arena. constexpr int kDefaultTensorAlignment = 64; // The prefix of Flex op custom code. // This will be matched agains the `custom_code` field in `OperatorCode` // Flatbuffer Table. // WARNING: This is an experimental API and subject to change. constexpr char kFlexCustomCodePrefix[] = "Flex"; // Checks whether the prefix of the custom name indicates the operation is an // Flex operation. bool IsFlexOp(const char* custom_name); // Converts a `std::vector` to a `TfLiteIntArray`. The caller takes ownership // of the returned pointer. TfLiteIntArray* ConvertVectorToTfLiteIntArray(const std::vector<int>& input); // Converts an array (of the given size) to a `TfLiteIntArray`. The caller // takes ownership of the returned pointer, and must make sure 'dims' has at // least 'rank' elements. TfLiteIntArray* ConvertArrayToTfLiteIntArray(const int rank, const int* dims); // Checks whether a `TfLiteIntArray` and an int array have matching elements. // The caller must guarantee that 'b' has at least 'b_size' elements. bool EqualArrayAndTfLiteIntArray(const TfLiteIntArray* a, const int b_size, const int* b); size_t CombineHashes(std::initializer_list<size_t> hashes); struct TfLiteIntArrayDeleter { void operator()(TfLiteIntArray* a) { if (a) TfLiteIntArrayFree(a); } }; // Helper for Building TfLiteIntArray that is wrapped in a unique_ptr, // So that it is automatically freed when it goes out of the scope. std::unique_ptr<TfLiteIntArray, TfLiteIntArrayDeleter> BuildTfLiteIntArray( const std::vector<int>& data); // Populates the size in bytes of a type into `bytes`. Returns kTfLiteOk for // valid types, and kTfLiteError otherwise. TfLiteStatus GetSizeOfType(TfLiteContext* context, const TfLiteType type, size_t* bytes); // Creates a stub TfLiteRegistration instance with the provided // `custom_op_name`. The op will fail if invoked, and is useful as a // placeholder to defer op resolution. // Note that `custom_op_name` must remain valid for the returned op's lifetime.. TfLiteRegistration CreateUnresolvedCustomOp(const char* custom_op_name); // Checks whether the provided op is an unresolved custom op. bool IsUnresolvedCustomOp(const TfLiteRegistration& registration); // Returns a descriptive name with the given op TfLiteRegistration. std::string GetOpNameByRegistration(const TfLiteRegistration& registration); // The prefix of a validation subgraph name. // WARNING: This is an experimental API and subject to change. constexpr char kValidationSubgraphNamePrefix[] = "VALIDATION:"; // Checks whether the prefix of the subgraph name indicates the subgraph is a // validation subgraph. bool IsValidationSubgraph(const char* name); } // namespace tflite #endif // TENSORFLOW_LITE_UTIL_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/util.h
C++
apache-2.0
4,136
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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 TENSORFLOW_LITE_VERSION_H_ #define TENSORFLOW_LITE_VERSION_H_ #include "tensorflow/core/public/version.h" // The version number of the Schema. Ideally all changes will be backward // compatible. If that ever changes, we must ensure that version is the first // entry in the new tflite root so that we can see that version is not 1. #define TFLITE_SCHEMA_VERSION (3) // TensorFlow Lite Runtime version. // This value is currently shared with that of TensorFlow. #define TFLITE_VERSION_STRING TF_VERSION_STRING #endif // TENSORFLOW_LITE_VERSION_H_
YifuLiu/AliOS-Things
components/ai_agent/src/engine/tflite-micro/tensorflow/lite/version.h
C
apache-2.0
1,228
/* * Copyright (C) 2021-2023 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "ulog/ulog.h" #include "aos/kernel.h" #include "aiagent_engine.h" #include "engine/ucloud_ai_engine.h" #include "aiagent_service.h" #include "ucloud_ai_common.h" #include "aiconfig.h" #define TAG "UCLOUD_AI_ENGINE" static void ucloud_ai_engine_delete(aiagent_engine_t *eng) { if (!eng) return -1; free(eng); } static bool ucloud_ai_engine_available(void) { return true; } int32_t ucloud_ai_engine_init(aiagent_engine_t *eng) { int32_t ret; if (!eng) return -1; ret = ucloud_ai_init(); if (ret < 0) { LOGE(TAG, "ucloud_ai_init failed, ret: %d\n", ret); return -1; } ucloud_ai_set_key_secret(OSS_ACCESS_KEY, OSS_ACCESS_SECRET); ucloud_ai_set_oss_endpoint(OSS_ENDPOINT); ucloud_ai_set_oss_bucket(OSS_BUCKET); } int32_t ucloud_ai_engine_uninit(aiagent_engine_t *eng) { if (!eng) return -1; return ucloud_ai_uninit(); } int ucloud_ai_engine_model_infer(aiagent_engine_t *eng) { if (!eng) return -1; ucloud_ai_cb_t cb = (ucloud_ai_cb_t)eng->callback; switch (eng->model) { #ifdef CONFIG_ALICLOUD_FACEBODY_ENABLE case UCLOUD_AI_MODEL_COMPARING_FACEBODY: ucloud_ai_facebody_comparing_face(eng->src1, eng->src2, cb); break; case UCLOUD_AI_MODEL_GENERATE_HUMAN_ANIME_STYLE: ucloud_ai_facebody_generate_human_anime_style(eng->src1, cb); break; case UCLOUD_AI_MODEL_RECOGNIZE_EXPRESSION: ucloud_ai_facebody_recognize_expression(eng->src1, cb); break; #endif #ifdef CONFIG_ALICLOUD_OBJECTDET_ENABLE case UCLOUD_AI_MODEL_DETECT_OBJECT: ucloud_ai_objectdet_detect_object(eng->src1, cb); break; case UCLOUD_AI_MODEL_DETECT_MAIN_BODY: ucloud_ai_objectdet_detect_main_body(eng->src1, cb); break; #endif #ifdef CONFIG_ALICLOUD_IMAGESEG_ENABLE case UCLOUD_AI_MODEL_SEGMENT_COMMON_IMAGE: ucloud_ai_imageseg_segment_common_image(eng->src1, cb); break; case UCLOUD_AI_MODEL_SEGMENT_FACE: ucloud_ai_imageseg_segment_face(eng->src1, cb); break; #endif #ifdef CONFIG_ALICLOUD_OCR_ENABLE case UCLOUD_AI_MODEL_RECOGNIZE_IDENTITY_CARD_FACE_SIDE: ucloud_ai_ocr_recognize_identity_card_face_side(eng->src1, cb); break; case UCLOUD_AI_MODEL_RECOGNIZE_IDENTITY_CARD_BACK_SIDE: ucloud_ai_ocr_recognize_identity_card_back_side(eng->src1, cb); break; case UCLOUD_AI_MODEL_RECOGNIZE_BANK_CARD: ucloud_ai_ocr_recognize_bank_card(eng->src1, cb); break; case UCLOUD_AI_MODEL_RECOGNIZE_CHARACTER: ucloud_ai_ocr_recognize_character(eng->src1, cb); break; #endif #ifdef CONFIG_ALICLOUD_IMAGERECOG_ENABLE case UCLOUD_AI_MODEL_CLASSIFYING_RUBBISH: ucloud_ai_imagerecog_classifying_rubbish(eng->src1, cb); break; case UCLOUD_AI_MODEL_DETECT_FRUITS: ucloud_ai_imagerecog_detect_fruits(eng->src1, cb); break; #endif #ifdef CONFIG_ALICLOUD_IMAGEENHAN_ENABLE case UCLOUD_AI_MODEL_ERASE_PERSON: ucloud_ai_imageenhan_erase_person(eng->src1, IMAGEENHAN_ERASE_PERSON_USERMASK_URL, cb); break; case UCLOUD_AI_MODEL_EXTEND_IMAGE_STYLE: ucloud_ai_imageenhan_extend_image_style(eng->src1, IMAGEENHAN_EXTEND_IMAGE_STYLE_URL, cb); break; #endif default: break; } return 0; } static aiagent_engine_t *ucloud_ai_engine_create(int engineid) { aiagent_engine_t *eng; /* Malloc ai agent eng*/ eng = (aiagent_engine_t *) malloc(sizeof(aiagent_engine_t)); if (!eng) { LOGE(TAG, "malloc camera device fail\n"); return NULL; } eng->is_dummy = false; /* Set the function pointers */ eng->ai_engine_init = ucloud_ai_engine_init; eng->ai_engine_uninit = ucloud_ai_engine_uninit; eng->ai_engine_model_infer = ucloud_ai_engine_model_infer; // eng->callback = ucloud_callback; eng->ai_engine_free = ucloud_ai_engine_delete; return eng; } aiagent_context_t ucloud_ai_engine = { UCLOUD_AI_NAME, "ucloud ai inference engine", ucloud_ai_engine_available, ucloud_ai_engine_create };
YifuLiu/AliOS-Things
components/ai_agent/src/engine/ucloud_ai_engine.c
C
apache-2.0
4,429
cmake_minimum_required(VERSION 3.5) project(ampsim C ASM CXX) set(library amp) set(EXE ampsim) add_compile_options(-m32) add_compile_options(-g) aux_source_directory(../engine/quickjs_engine/addons/hardware/gpio DIR_ADDON_GPIO_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/ir DIR_ADDON_IR_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/pwm DIR_ADDON_PWM_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/onewire DIR_ADDON_ONEWIRE_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/rtc DIR_ADDON_RTC_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/uart DIR_ADDON_UART_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/wdg DIR_ADDON_WDG_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/adc DIR_ADDON_ADC_SRCS) aux_source_directory(../engine/quickjs_engine/addons/network/http DIR_ADDON_HTTP_SRCS) aux_source_directory(../engine/quickjs_engine/addons/network/netmgr DIR_ADDON_NETMGR_SRCS) aux_source_directory(../engine/quickjs_engine/addons/network/mqtt DIR_ADDON_MQTT_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/timer DIR_ADDON_TIMER_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/dac DIR_ADDON_DAC_SRCS) aux_source_directory(../engine/quickjs_engine/addons/hardware/i2c DIR_ADDON_I2C_SRCS) aux_source_directory(../engine/quickjs_engine/addons/utils/systimer DIR_ADDON_SYSTIMER_SRCS) aux_source_directory(../engine/quickjs_engine/addons/utils/system DIR_ADDON_SYSTEM_SRCS) aux_source_directory(../engine/quickjs_engine/addons/utils/fs DIR_ADDON_FS_SRCS) aux_source_directory(../engine/quickjs_engine/addons/utils/kv DIR_ADDON_KV_SRCS) aux_source_directory(../engine/quickjs_engine/addons/utils/builtin DIR_ADDON_BUILTIN_SRCS) aux_source_directory(../engine/quickjs_engine/addons/advanced/ota DIR_ADDON_OTA_SRCS) aux_source_directory(../engine/quickjs_engine/addons/advanced/audio DIR_ADDON_AUDIO_SRCS) aux_source_directory(../engine/quickjs_engine/addons/advanced/aiot DIR_ADDON_AIOT_SRCS) aux_source_directory(../engine/quickjs_engine/addons/libc DIR_ADDON_LIBC_SRCS) aux_source_directory(../engine/quickjs_engine/addons/repl DIR_ADDON_REPL_SRCS) aux_source_directory(../engine/quickjs_engine/addons DIR_ADDON_SRCS) aux_source_directory(../engine/quickjs_engine/startup DIR_QJS_STARTUP_SRCS) aux_source_directory(../main DIR_MAIN_SRCS) aux_source_directory(../services/amp_boot DIR_AMP_BOOT) aux_source_directory(../services/amp_utils DIR_AMP_UTILS) aux_source_directory(../services/amp_mgr DIR_AMP_MGR) aux_source_directory(../services/app_mgr DIR_AMP_APP_MGR) aux_source_directory(../services/board_mgr DIR_BOARD_MGR) aux_source_directory(../services/amp_memmgt DIR_AMP_MEMMGT) aux_source_directory(../jslib/bytecode DIR_JSLIB) aux_source_directory(../../amp_adapter/platform/linux DIR_PLATFORM_LINUX) aux_source_directory(../../amp_adapter/platform/linux/peripheral DIR_PLATFORM_LINUX_PERIPHERAL) aux_source_directory(../../uvoice/media DIR_UVOICE_MEDIA) aux_source_directory(../../uvoice/audio DIR_UVOICE_AUDIO) aux_source_directory(../../uvoice/stream DIR_UVOICE_STREAM) aux_source_directory(../../cjson/src DIR_CJSON) set(ulog_sources ../../ulog/src/ulog_init.c ../../ulog/src/ulog_ring_fifo.c ../../ulog/src/ulog_utility.c ../../ulog/src/ulog.c ) set(DIR_UVOICE_COMMON ../../uvoice/common/event.c ../../uvoice/common/ringbuffer.c ) aux_source_directory(../../linksdk/core/ DIR_LINKSDK_CORE) aux_source_directory(../../linksdk/core/sysdep/ DIR_LINKSDK_SYSDEP) aux_source_directory(../../linksdk/core/utils/ DIR_LINKSDK_UTILS) aux_source_directory(../../linksdk/components/bootstrap/ DIR_LINKSDK_BOOTSTRAP) aux_source_directory(../../linksdk/components/data-model/ DIR_LINKSDK_DATAMODEL) aux_source_directory(../../linksdk/components/subdev/ DIR_LINKSDK_SUBDEV) aux_source_directory(../../linksdk/external/ DIR_LINKSDK_EXTERNAL) aux_source_directory(../../linksdk/components/devinfo/ DIR_LINKSDK_DEVINFO) aux_source_directory(../../linksdk/components/dynreg/ DIR_LINKSDK_DYNREG) aux_source_directory(../../linksdk/components/ntp/ DIR_LINKSDK_NRP) aux_source_directory(../../http/src/ DIR_HTTP) set(linksdk_source ${DIR_LINKSDK_CORE} ${DIR_LINKSDK_SYSDEP} ${DIR_LINKSDK_UTILS} ${DIR_LINKSDK_BOOTSTRAP} ${DIR_LINKSDK_DATAMODEL} ${DIR_LINKSDK_SUBDEV} ${DIR_LINKSDK_EXTERNAL} ${DIR_LINKSDK_DEVINFO} ${DIR_LINKSDK_DYNREG} ${DIR_LINKSDK_NRP}) set(mbedtls_source ../../mbedtls/library/aes.c ../../mbedtls/library/aesni.c ../../mbedtls/library/arc4.c ../../mbedtls/library/asn1parse.c ../../mbedtls/library/asn1write.c ../../mbedtls/library/base64.c ../../mbedtls/library/bignum.c ../../mbedtls/library/blowfish.c ../../mbedtls/library/camellia.c ../../mbedtls/library/ccm.c ../../mbedtls/library/cipher.c ../../mbedtls/library/cipher_wrap.c ../../mbedtls/library/cmac.c ../../mbedtls/library/ctr_drbg.c ../../mbedtls/library/des.c ../../mbedtls/library/dhm.c ../../mbedtls/library/ecdh.c ../../mbedtls/library/ecdsa.c ../../mbedtls/library/ecjpake.c ../../mbedtls/library/ecp.c ../../mbedtls/library/ecp_curves.c ../../mbedtls/library/entropy.c ../../mbedtls/library/entropy_poll.c ../../mbedtls/library/error.c ../../mbedtls/library/gcm.c ../../mbedtls/library/havege.c ../../mbedtls/library/hmac_drbg.c ../../mbedtls/library/md.c ../../mbedtls/library/md2.c ../../mbedtls/library/md4.c ../../mbedtls/library/md5.c ../../mbedtls/library/md_wrap.c ../../mbedtls/library/memory_buffer_alloc.c ../../mbedtls/library/oid.c ../../mbedtls/library/padlock.c ../../mbedtls/library/pem.c ../../mbedtls/library/pk.c ../../mbedtls/library/pk_wrap.c ../../mbedtls/library/pkcs12.c ../../mbedtls/library/pkcs5.c ../../mbedtls/library/pkparse.c ../../mbedtls/library/pkwrite.c ../../mbedtls/library/platform.c ../../mbedtls/library/ripemd160.c ../../mbedtls/library/rsa.c ../../mbedtls/library/sha1.c ../../mbedtls/library/sha256.c ../../mbedtls/library/sha512.c ../../mbedtls/library/threading.c ../../mbedtls/library/timing.c ../../mbedtls/library/version.c ../../mbedtls/library/version_features.c ../../mbedtls/library/xtea.c ../../mbedtls/library/certs.c ../../mbedtls/library/pkcs11.c ../../mbedtls/library/x509.c ../../mbedtls/library/x509_create.c ../../mbedtls/library/x509_crl.c ../../mbedtls/library/x509_crt.c ../../mbedtls/library/x509_csr.c ../../mbedtls/library/x509write_crt.c ../../mbedtls/library/x509write_csr.c ../../mbedtls/library/debug.c ../../mbedtls/library/net_sockets.c ../../mbedtls/library/ssl_cache.c ../../mbedtls/library/ssl_ciphersuites.c ../../mbedtls/library/ssl_cli.c ../../mbedtls/library/ssl_cookie.c ../../mbedtls/library/ssl_srv.c ../../mbedtls/library/ssl_ticket.c ../../mbedtls/library/ssl_tls.c ../../mbedtls/library/platform_util.c ../../mbedtls/library/rsa_internal.c ) aux_source_directory(../../mbedtls/platform/aos/library/ DIR_MBEDTLS_LIB) add_library(${library} STATIC ../entry/amp_entry.c ../engine/quickjs_engine/quickjs/quickjs.c ../engine/quickjs_engine/quickjs/libregexp.c ../engine/quickjs_engine/quickjs/libunicode.c ../engine/quickjs_engine/quickjs/cutils.c ../engine/quickjs_engine/quickjs/libbf.c ../engine/quickjs_engine/quickjs/linux_jquick_mutex.c ../../linksdk/portfiles/aiot_port/aos_port.c ${DIR_JSLIB} ${DIR_ADDON_GPIO_SRCS} ${DIR_ADDON_IR_SRCS} ${DIR_ADDON_PWM_SRCS} ${DIR_ADDON_ONEWIRE_SRCS} ${DIR_ADDON_RTC_SRCS} ${DIR_ADDON_UART_SRCS} ${DIR_ADDON_WDG_SRCS} ${DIR_ADDON_ADC_SRCS} ${DIR_ADDON_HTTP_SRCS} ${DIR_ADDON_AUDIO_SRCS} ${DIR_ADDON_NETMGR_SRCS} ${DIR_ADDON_TIMER_SRCS} ${DIR_ADDON_DAC_SRCS} ${DIR_ADDON_I2C_SRCS} ${DIR_ADDON_SYSTIMER_SRCS} ${DIR_ADDON_SYSTEM_SRCS} ${DIR_ADDON_FS_SRCS} ${DIR_ADDON_KV_SRCS} ${DIR_ADDON_BUILTIN_SRCS} ${DIR_ADDON_LIBC_SRCS} ${DIR_QJS_STARTUP_SRCS} ${DIR_ADDON_SRCS} ${DIR_MAIN_SRCS} ${DIR_AMP_MGR} ${DIR_ADDON_REPL_SRCS} ${DIR_AMP_MEMMGT} ${DIR_BOARD_MGR} ${DIR_PLATFORM_LINUX} ${DIR_PLATFORM_LINUX_PERIPHERAL} ${DIR_ADDON_AIOT_SRCS} ${DIR_CJSON} ${ulog_sources} ${DIR_UVOICE_COMMON} ../../uvoice/application/comb/comb.c ../../uvoice/uvoice.c ../../uvoice/audio/hal/linux/uvoice_pcm.c ${DIR_UVOICE_MEDIA} ${DIR_UVOICE_AUDIO} ${DIR_UVOICE_STREAM} ${linksdk_source} ${mbedtls_source} ${DIR_MBEDTLS_LIB} ${DIR_HTTP} ${DIR_ADDON_MQTT_SRCS} ) add_definitions( -D UVOICE_PROJECT -D UVOICE_PLAYER_ENABLE -D UVOICE_EVENT_ENABLE -D UVOICE_FILE_ENABLE -D UVOICE_HTTP_ENABLE -D UVOICE_MLIST_ENABLE -D AUDIO_CACHE_ENABLE -D ALICLOUD_TTS_SUPPORT -D UVOICE_TTS_ENABLE -D UVOICE_DOWNLOAD_ENABLE -D UVOICE_RELEASE_VERSION_MAIN=1 -D UVOICE_RELEASE_VERSION_SUB=0 -D DEBUG -D __os_linux__ -D CONFIG_HTTP_SECURE=1 -D UVOICE_PCM_NO_ALSA -D MBEDTLS_CONFIG_TLS_MAX_CONTENT_LEN=16384) target_compile_definitions(${library} PRIVATE __AOS_AMP__) target_compile_definitions(${library} PRIVATE CONFIG_VERSION=\"1.0\") target_compile_definitions(${library} PRIVATE CONFIG_KERNEL_LINUX) target_compile_definitions(${library} PRIVATE IPADDR_STRLEN_MAX=46) target_compile_definitions(${library} PRIVATE __os_linux__) target_include_directories(${library} PRIVATE ../engine/quickjs_engine/aos_port) target_include_directories(${library} PRIVATE ../engine/quickjs_engine/quickjs) target_include_directories(${library} PRIVATE ../engine/quickjs_engine/addons) target_include_directories(${library} PRIVATE ../engine/quickjs_engine/addons/common) target_include_directories(${library} PRIVATE ../engine/quickjs_engine) target_include_directories(${library} PRIVATE ../main/) target_include_directories(${library} PRIVATE ../services/amp_utils/) target_include_directories(${library} PRIVATE ../services/app_mgr/) target_include_directories(${library} PRIVATE ../services/board_mgr/) target_include_directories(${library} PRIVATE ../services/amp_boot/) target_include_directories(${library} PRIVATE ../services/amp_memmgt/) #target_include_directories(${library} PRIVATE ../utils/cJSON/) target_include_directories(${library} PRIVATE ../utils/list/) target_include_directories(${library} PRIVATE ../../amp_adapter/include) target_include_directories(${library} PRIVATE ../../amp_adapter/include/peripheral) target_include_directories(${library} PRIVATE ../../amp_adapter/platform/linux) target_include_directories(${library} PRIVATE ../../amp_adapter/portfiles) target_include_directories(${library} PRIVATE ../../mbedtls/include) target_include_directories(${library} PRIVATE ../../mbedtls/platform/include) target_include_directories(${library} PRIVATE ../../ulog/include) target_include_directories(${library} PRIVATE ../../ulog/internal) target_include_directories(${library} PRIVATE ../../osal_aos/include) target_include_directories(${library} PRIVATE ../../cjson/include) target_include_directories(${library} PRIVATE ../../ota/include) target_include_directories(${library} PRIVATE ../../linksdk/core) target_include_directories(${library} PRIVATE ../../linksdk/core/utils) target_include_directories(${library} PRIVATE ../../linksdk/core/sysdep) target_include_directories(${library} PRIVATE ../../linksdk/components/data-model) target_include_directories(${library} PRIVATE ../../linksdk/components/subdev) target_include_directories(${library} PRIVATE ../../linksdk/components/ntp) target_include_directories(${library} PRIVATE ../../linksdk/components/devinfo) target_include_directories(${library} PRIVATE ../../linksdk/components/dynreg) target_include_directories(${library} PRIVATE ../../netmgr/include) target_include_directories(${library} PRIVATE ../../uservice/include) target_include_directories(${library} PRIVATE ../../kv/include) target_include_directories(${library} PRIVATE ../../uvoice/include) target_include_directories(${library} PRIVATE ../../uvoice/internal) target_include_directories(${library} PRIVATE ../../uvoice/application/comb/include) target_include_directories(${library} PRIVATE ../../uvoice/audio) target_include_directories(${library} PRIVATE ../../http/include) target_include_directories(${library} PRIVATE ../../http/internal) target_include_directories(${library} PRIVATE ../../mbedtls/platform/aos/include) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") add_executable(${EXE} ampsim.c amp_stub.c) target_link_libraries(${EXE} ${library}) target_link_libraries(${EXE} "-lpthread") target_link_libraries(${EXE} "-lm") target_link_libraries(${EXE} "-lrt")
YifuLiu/AliOS-Things
components/amp/ampsim/CMakeLists.txt
CMake
apache-2.0
12,514
#include <stdio.h> #include <stdint.h> unsigned int g_ntp_time = 0; unsigned int g_up_time = 0; int app_management_center_init() { return 0; } int amp_boot_main() { return 0; } int amp_recovery_init() { return 0; } void amp_recovery_entry() { } void amp_app_version_set() { }
YifuLiu/AliOS-Things
components/amp/ampsim/amp_stub.c
C
apache-2.0
294
#include <stdio.h> #include <stdlib.h> extern int amp_main(void); int main(int argc, char **argv) { amp_main(); return 0; }
YifuLiu/AliOS-Things
components/amp/ampsim/ampsim.c
C
apache-2.0
132
/* * Copyright (C) 2015-2020 Alibaba Group Holding Limited */ #include "amp_board_config.h" #define AMP_FS_ROOT_DIR "/data/jsamp" #define JSE_CORE_ADDON_INITJS /* enable high-level jsapi */ #define JSE_HIGHLEVEL_JSAPI /* js engine low memory enabled */ // #define AMP_LOWMEMORY_ENABLE /* manager channel */ #define AMP_NETWORK_ENABLE /* das(device security) service */ // #define AMP_DAS_ENABLED /* ntp service */ // #define AMP_NTP_ENABLED /* location service */ // #define AMP_LOCATION_SERVICE_ENABLED /* debug mode, use test pk and ps*/ #define AMP_DEBUG_MODE /* ota service */ #if AMP_ADVANCED_ADDON_OTA #define JSE_ADVANCED_ADDON_OTA #endif /* os */ #if AMP_CORE_ADDON_BUILDIN #define JSE_CORE_ADDON_BUILDIN #endif #if AMP_CORE_ADDON_SYSTEM #define JSE_CORE_ADDON_SYSTEM #endif #if AMP_CORE_ADDON_FS #define JSE_CORE_ADDON_FS #endif #if AMP_CORE_ADDON_KV #define JSE_CORE_ADDON_KV #endif #if AMP_CORE_ADDON_LOG #define JSE_CORE_ADDON_LOG #endif #if AMP_CORE_ADDON_PM #define JSE_CORE_ADDON_PM #endif #if AMP_CORE_ADDON_BATTERY #define JSE_CORE_ADDON_BATTERY #endif #if AMP_CORE_ADDON_CHARGER #define JSE_CORE_ADDON_CHARGER #endif #if AMP_CORE_ADDON_SYSTIMER #define JSE_CORE_ADDON_SYSTIMER #endif #if AMP_CORE_ADDON_CRYPTO #define JSE_CORE_ADDON_CRYPTO #endif /* periperal */ #if AMP_HW_ADDON_ADC #define JSE_HW_ADDON_ADC #endif #if AMP_HW_ADDON_CAN #define JSE_HW_ADDON_CAN #endif #if AMP_HW_ADDON_DAC #define JSE_HW_ADDON_DAC #endif #if AMP_HW_ADDON_GPIO #define JSE_HW_ADDON_GPIO #endif #if AMP_HW_ADDON_I2C #define JSE_HW_ADDON_I2C #endif #if AMP_HW_ADDON_SPI #define JSE_HW_ADDON_SPI #endif #if AMP_HW_ADDON_TIMER #define JSE_HW_ADDON_TIMER #endif #if AMP_HW_ADDON_PWM #define JSE_HW_ADDON_PWM #endif #if AMP_HW_ADDON_RTC #define JSE_HW_ADDON_RTC #endif #if AMP_HW_ADDON_UART #define JSE_HW_ADDON_UART #endif #if AMP_HW_ADDON_LCD #define JSE_HW_ADDON_LCD #endif #if AMP_HW_ADDON_WDG #define JSE_HW_ADDON_WDG #endif /* network */ #if AMP_NET_ADDON_UDP #define JSE_NET_ADDON_UDP #endif #if AMP_NET_ADDON_TCP #define JSE_NET_ADDON_TCP #endif #if AMP_NET_ADDON_MQTT #define JSE_NET_ADDON_MQTT #endif #if AMP_NET_ADDON_HTTP #define JSE_NET_ADDON_HTTP #endif #if AMP_NET_ADDON_NETMGR #define JSE_NET_ADDON_NETMGR #endif #if AMP_NET_ADDON_WIFI #define JSE_NET_ADDON_WIFI #endif #if AMP_NET_ADDON_CELLULAR #define JSE_NET_ADDON_CELLULAR #endif /* advanced component */ #if AMP_ADVANCED_ADDON_AIOT_DEVICE #define JSE_ADVANCED_ADDON_AIOT_DEVICE #endif #if AMP_ADVANCED_ADDON_AIOT_GATEWAY #define JSE_ADVANCED_ADDON_AIOT_GATEWAY #endif #if (defined(BOARD_HAAS100) || defined(BOARD_HAASEDUK1)) #if AMP_ADVANCED_ADDON_AUDIOPLAYER #define JSE_ADVANCED_ADDON_AUDIOPLAYER #endif #endif #if AMP_ADVANCED_ADDON_TTS #define JSE_ADVANCED_ADDON_TTS #endif #if AMP_ADVANCED_ADDON_LOCATION #define JSE_ADVANCED_ADDON_LOCATION #endif #if AMP_ADVANCED_ADDON_KEYPAD #define JSE_ADVANCED_ADDON_KEYPAD #endif #if AMP_ADVANCED_ADDON_UND #define JSE_ADVANCED_ADDON_UND #endif /* wireless */ #if AMP_WIRELESS_ADDON_BT_HOST #define JSE_WIRELESS_ADDON_BT_HOST #endif #if AMP_ADVANCED_ADDON_BLECFGNET #define JSE_ADVANCED_ADDON_BLECFGNET #endif #if AMP_ADVANCED_ADDON_UI #define JSE_ADVANCED_ADDON_UI #endif #if (defined(BOARD_HAAS100) || defined(BOARD_HAASEDUK1)) #if AMP_ADVANCED_ADDON_OSS #define JSE_ADVANCED_ADDON_OSS #endif #endif /* recovery switch & status led */ #define AMP_REPL_PROMPT "amp > " /* manager channel device info for porject */ #define AMP_INTERNAL_PRODUCTKEY_VALUE "" #define AMP_INTERNAL_PRODUCTSECRET_VALUE ""
YifuLiu/AliOS-Things
components/amp/aos_config/amp_config.h
C
apache-2.0
3,581
/*! * @file amp_at.h * * Copyright (C) 2015-2021 Alibaba Group Holding Limited */ #ifndef _AMP_AT_H_ #define _AMP_AT_H_ #include "at.h" int amp_at_init(int at_uart_port, uint32_t baud_rate, char *send_delimiter); int amp_at_register_callback(const char *prefix, at_recv_cb cb); int amp_at_read(char *outbuf, int readsize); int amp_at_send_wait_reply(const char *cmd, int cmdlen, bool delimiter, const char *data, int datalen, const char *expectrsp); #endif
YifuLiu/AliOS-Things
components/amp/components/at/include/amp_at.h
C
apache-2.0
487
/*! * @file at.h * * Copyright (C) 2015-2017 Alibaba Group Holding Limited */ #ifndef _AT_PARSER_H_ #define _AT_PARSER_H_ #include <stdbool.h> #include <stdint.h> /** @addtogroup aos_at at * AT parser, which is used to ease the operation of AT modules. * * @{ */ /** * AT dev type */ typedef enum { AT_DEV_UART = 0, AT_DEV_USB = 1, /* add more types here when necessary */ AT_DEV_TYPE_MAX } at_dev_type_t; /* * AT dev ops type */ typedef struct { at_dev_type_t type; int (*init)(void *dev); int (*recv)(void *dev, void *data, uint32_t expect_size, uint32_t *recv_size, uint32_t timeout); int (*send)(void *dev, void *data, uint32_t size, uint32_t timeout); int (*deinit)(void *dev); } at_dev_ops_t; /** * The reply format of the AT commands. */ typedef struct { char *reply_prefix; //!< reply prefix char *reply_success_postfix; //!< reply postfix indicating success char *reply_fail_postfix; //!< reply postfix indicating failure } at_reply_config_t; /** * The config for the AT device. */ typedef struct { uint8_t port; //!< dev port. Compulsory at_dev_type_t type; //!< dev type. Compulsory void *dev_cfg; //!< dev config. Compulsory. For UART, see uart_config_t in hal/uart.h at_reply_config_t reply_cfg; //!< AT receive prefix and postfix. Compulsory. char *send_delimiter; //!< AT sending delimiter between command and data. Optional, "\r" uint32_t timeout_ms; //!< AT send or receive timeout in millisecond. Optional, 1000 ms by defaut uint8_t send_wait_prompt; //!< whether AT send waits prompt before sending data. Optional, 0 by default uint32_t prompt_timeout_ms; //!< AT send wait prompt timeout in millisecond. Optional, 200 ms by default uint8_t send_data_no_wait; //!< whether AT send waits response after sending data. Optional, 0 by default int recv_task_priority; //!< AT recv task priority. Optional, 32 by default int recv_task_stacksize; //!< AT recv task stacksize. Optional, 1K by default } at_config_t; #ifndef bool #define bool unsigned char #endif #ifndef true #define true 1 #endif #ifndef false #define false 0 #endif /** * The is the defition of the AT oob callback function. * * @param[in] arg The arguments for the callback function. * @param[in] buf The buffer to store the result when user uses * prefix and postfix to match a patterned AT event, * e.g. domain-to-ip event on some platforms. * @param[in] buflen The length of the buffer. * * @return none. */ typedef void (*at_recv_cb)(void *arg, char *buf, int buflen); /** * Initialization for AT parser module * * @return success: 0; fail: -1 */ int at_init(void); /** * Deinitialization for AT parser module * * @return success: 0; fail: -1 */ int at_deinit(void); /** * Add a new AT device * * @param[in] config AT config (e.g. port number, AT send delimiter). * See definition for at_config_t. MUST not be NULL. * * @return success: fd for AT device; fail: -1 */ int at_add_dev(at_config_t *config); /** * Delete AT device by fd * * @param[in] fd fd for AT device * * @return success: 0; fail: -1 */ int at_delete_dev(int fd); /** * AT send (format: command + delimiter + data) and wait reply * * @param[in] fd fd for AT device * @param[in] cmd AT command sending buf. MUST not be NULL. * @param[in] cmdlen AT command length. * @param[in] delimiter whether sending delimiter, usually value is true * @param[in] data data sending buf. NULL if no data. * @param[in] datalen data length. Zero if no data. * @param[in,out] replybuf reply buffer. MUST not be NULL. * @param[in] bufsize reply buffer size * @param[in] atcmdconfig AT cmd reply format config. Use default if NULL * * @return success: 0; fail: -1 */ int at_send_wait_reply(int fd, const char *cmd, int cmdlen, bool delimiter, const char *data, int datalen, char *replybuf, int bufsize, const at_reply_config_t *atcmdconfig); /** * AT send (format: data + delimiter) and does not wait reply * * @param[in] fd fd for AT device * @param[in] data sending buffer. * @param[in] datalen sending length. * @param[in] delimiter whether sending delimiter, usually value is false * * @return success: 0; fail: -1 */ int at_send_no_reply(int fd, const char *data, int datalen, bool delimiter); /** * AT read for certain bytes of data * * @param[in] fd fd for AT device * @param[in,out] outbuf output buffer. * @param[in] readsize read size. * * @return success: read length; fail: -1 */ int at_read(int fd, char *outbuf, int readsize); /** * AT register callback for recv * * @param[in] fd fd for AT device * @param[in] prefix interested string. * @param[in] postfix intersted postfix. * @param[in,out] recvbuf recv buffer. * @param[in] bufsize recv buffer len. * @param[in] cb callback handle function. * @param[in] arg callback handle function args. * * @return success: 0; fail: -1 * * @note * - The recvbuf and bufsize must be present if postfix is used, * which are used to store the result and length if any data * that match the prefix & postfix pattern. */ int at_register_callback(int fd, const char *prefix, const char *postfix, char *recvbuf, int bufsize, at_recv_cb cb, void *arg); /** * AT yield receive function. Only used in single task scenario * * @param[in] fd fd for AT device. * @param[in,out] replybuf reply buffer. * @param[in] bufsize reply buffer size. * @param[in] atcmdconfig AT cmd reply format config. Use default if NULL. * @param[in] timeout_ms receive timeout in millisecond. * * @return success: 0; fail: -1 */ int at_yield(int fd, char *replybuf, int bufsize, const at_reply_config_t *atcmdconfig, int timeout_ms); /** @} */ /* end of group aos_at */ #endif
YifuLiu/AliOS-Things
components/amp/components/at/include/at.h
C
apache-2.0
6,437
#include "stdlib.h" #include "stdint.h" #include "stdbool.h" #include "stdarg.h" #include "at.h" #include "at_internal.h" #include "atcmd_config_module.h" #include "aos_hal_uart.h" #include "aos_network.h" static uart_dev_t uart_dev; static int at_dev_fd = -1; #define AT_CMD_RSP_LEN 512 #define AT_RECV_TIMEOUT_MS 100 int amp_at_yield(int fd, char *replybuf, int bufsize, int timeout_ms) { return at_yield(at_dev_fd, replybuf, bufsize, NULL, timeout_ms); } int amp_at_read(char *outbuf, int readsize) { return at_read(at_dev_fd, outbuf, readsize); } int amp_at_send_no_reply(const char *data, int datalen, bool delimiter) { return at_send_no_reply(at_dev_fd, data, datalen, delimiter); } int amp_at_send_wait_reply(const char *cmd, int cmdlen, bool delimiter, const char *data, int datalen, const char *expectrsp) { char *rsp = NULL; char *str = NULL; int ret = 0; rsp = aos_malloc(AT_CMD_RSP_LEN); ret = at_send_wait_reply(at_dev_fd, cmd, cmdlen, delimiter, data, datalen, rsp, AT_CMD_RSP_LEN, NULL); if (expectrsp != NULL) { str = strstr(rsp, expectrsp); } aos_free(rsp); if ((expectrsp != NULL) && (str == NULL)) { return -1; } return ret; } int amp_at_register_callback(const char *prefix, at_recv_cb cb, void *arg) { return at_register_callback(at_dev_fd, prefix, NULL, NULL, 0, cb, arg); } void amp_at_debug(char *str) { aos_hal_uart_send(&uart_dev, str, strlen(str), -1); } void amp_at_debug_c(char c) { aos_hal_uart_send(&uart_dev, &c, 1, -1); } void amp_at_deinit() { at_deinit(); } void amp_at_set_echo(int flag) { at_set_echo(flag); } int amp_at_init(int at_uart_port, uint32_t baud_rate, char *send_delimiter) { at_config_t at_config = {0}; at_init(); /* UART config */ uart_dev.port = at_uart_port; uart_dev.config.baud_rate = baud_rate; uart_dev.config.data_width = DATA_WIDTH_8BIT; uart_dev.config.parity = NO_PARITY; uart_dev.config.stop_bits = STOP_BITS_1; uart_dev.config.flow_control = FLOW_CONTROL_DISABLED; uart_dev.config.mode = MODE_TX_RX; /* AT config, which has the UART config included */ at_config.type = AT_DEV_UART; at_config.port = uart_dev.port; at_config.dev_cfg = &uart_dev; at_config.send_delimiter = send_delimiter; /* must be global memory string */ at_config.timeout_ms = AT_RECV_TIMEOUT_MS; /* Add AT device, and save the returned fd which will be used later */ if ((at_dev_fd = at_add_dev(&at_config)) < 0) { AT_LOGE("AT parser device add failed!\n"); return -1; } return 0; } static int amp_at_get_cimi(void *arg, char *buf, int buflen) { char imei[33] = {0}; char *reply = NULL; reply = aos_malloc(64); memset(imei, '3', 32); snprintf(reply, 64, "\nAT+CIMI\nIMEI=%s\n", imei); amp_at_send_no_reply(reply, strlen(reply), true); aos_free(reply); aos_printf("at cmd get imei %s\n", imei); return 0; } int amp_at_instance_init() { int ret = 0; ret = amp_at_register_callback("AT+CIMI", amp_at_get_cimi, NULL); aos_printf("register cmd %s ret %d\n", "AT+CIMI", ret); ret = amp_at_register_callback("AT+TEST", amp_at_get_cimi, NULL); aos_printf("register cmd %s ret %d\n", "AT+TEST", ret); } int amp_at_test() { int ret = 0; ret = amp_at_init(3, 115200, "\r\n"); aos_printf("amp_at_init result %d\n", ret); amp_at_instance_init(); aos_printf("amp_at_init end\n"); }
YifuLiu/AliOS-Things
components/amp/components/at/src/amp_at.c
C
apache-2.0
3,749
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include <stdint.h> #include "at_internal.h" #define TAG "at" #define atpsr_debug(format, ...) LOGD(TAG, format, ##__VA_ARGS__) #define atpsr_err(format, ...) LOGE(TAG, format, ##__VA_ARGS__) static uint8_t inited = 0; static uint8_t reg_ops_num = 0; static at_dev_t at_dev[ATPSR_DEV_MAX_NUM] = { 0 }; static at_dev_ops_t *at_dev_ops[AT_DEV_TYPE_MAX] = { 0 }; static int echo_flag = 0; #define RECV_BUFFER_SIZE 512 int register_at_dev_ops(at_dev_ops_t *at_ops) { if (!at_ops || at_ops->type < 0 || at_ops->type >= AT_DEV_TYPE_MAX) { return -1; } if (at_dev_ops[at_ops->type] != NULL) { return -1; } at_dev_ops[at_ops->type] = at_ops; reg_ops_num++; return 0; } static void unregister_at_dev_ops(void) { memset(at_dev_ops, 0, AT_DEV_TYPE_MAX * sizeof(at_dev_ops_t *)); reg_ops_num = 0; return; } static int check_fd_valid(int fd) { return (fd >= 0 && fd < ATPSR_DEV_MAX_NUM); } static int check_type_valid(at_dev_type_t type) { return (type >= 0 && type < AT_DEV_TYPE_MAX); } static int check_dev_ready(int fd) { return (at_dev[fd]._inited == 1); } static at_dev_t *obtain_dev_by_fd(int fd) { return &at_dev[fd]; } static at_dev_ops_t *obtain_op_by_type(at_dev_type_t type) { return at_dev_ops[type]; } static void at_scan_for_callback(int fd, char c, char *buf, int buf_size, int *index) { int k; oob_t *oob = NULL; int offset = *index; at_dev_t *dev = NULL; if (!buf || buf_size <= 0 || offset < 0) { return; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return; dev = obtain_dev_by_fd(fd); for (k = 0; k < dev->_oobs_num; k++) { oob = &(dev->_oobs[k]); if (oob->reallen > 0 || (offset >= strlen(oob->prefix) && memcmp(oob->prefix, buf + offset - strlen(oob->prefix), strlen(oob->prefix)) == 0)) { atpsr_debug("AT! %s\r\n", oob->prefix); if (oob->postfix == NULL) { if(echo_flag) { amp_at_debug("\r\n"); } oob->cb(oob->arg, NULL, 0); memset(buf, 0, offset); offset = 0; } else { if (oob->reallen == 0) { int len = strlen(oob->prefix) - 1; len = len > 0 ? len : 0; memset(oob->oobinputdata, 0, oob->maxlen); memcpy(oob->oobinputdata, oob->prefix, len); oob->reallen += len; } if (oob->reallen < oob->maxlen) { oob->oobinputdata[oob->reallen] = c; oob->reallen++; if ((oob->reallen >= strlen(oob->prefix) + strlen(oob->postfix)) && (strncmp(oob->oobinputdata + oob->reallen - strlen(oob->postfix), oob->postfix, strlen(oob->postfix)) == 0)) { /*recv postfix*/ oob->cb(oob->arg, oob->oobinputdata, oob->reallen); memset(oob->oobinputdata, 0, oob->reallen); oob->reallen = 0; memset(buf, 0, offset); offset = 0; } } else { atpsr_err("invalid oob %s input , for oversize %s \r\n", oob->prefix, oob->oobinputdata); memset(oob->oobinputdata, 0, oob->reallen); oob->reallen = 0; memset(buf, 0, offset); offset = 0; } /*oob data maybe more than buf size */ if (offset > (buf_size - 2)) { memset(buf, 0, offset); offset = 0; } } continue; } } *index = offset; return; } static int at_getc(int fd, char *c, int timeout_ms) { int ret = 0; char data; uint32_t recv_size = 0; at_dev_t *dev = NULL; at_dev_ops_t *op = NULL; if (inited == 0) { atpsr_err("at module have not init yet\r\n"); return -1; } if (NULL == c) { return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); op = obtain_op_by_type(dev->_type); atpsr_mutex_lock(dev->_recv_mutex); ret = op->recv(dev->_dev, (void *)&data, 1, &recv_size, timeout_ms); atpsr_mutex_unlock(dev->_recv_mutex); if (ret != 0) { #ifdef WORKAROUND_DEVELOPERBOARD_DMA_UART if (ret == 1) { atpsr_debug("--->AT dma fail, restart!\n"); op->deinit(dev->_dev); op->init(dev->_dev); atpsr_debug("<----AT dma fail, restart!\n"); } #endif return -1; } if (recv_size == 1) { *c = data; return 0; } else { return -1; } } #if ATPSR_SINGLE_TASK static char at_rx_buf[RECV_BUFFER_SIZE]; static int at_yield_impl(int fd, char *replybuf, int bufsize, const at_reply_config_t *atcmdconfig, int timeout_ms) { int offset = 0; int ret = 0; int rsp_prefix_len = 0; int rsp_success_postfix_len = 0; int rsp_fail_postfix_len = 0; int at_reply_begin = 0; int at_reply_offset = 0; char c = 0; char *buf = NULL; char *rsp_prefix = NULL; char *rsp_success_postfix = NULL; char *rsp_fail_postfix = NULL; at_dev_t *dev = NULL; if (!inited) { atpsr_err("AT parser has not inited!\r\n"); return -1; } if (replybuf != NULL && bufsize <= 0) { atpsr_err("buffer size %d unmatched!\r\n", bufsize); return -1; } buf = at_rx_buf; if (NULL == buf) { atpsr_err("AT worker fail to malloc, task exist\r\n"); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); memset(buf, 0, RECV_BUFFER_SIZE); while (true) { /* read from uart and store buf */ ret = at_getc(fd, &c, timeout_ms); if (ret != 0) { atpsr_err("at yield timeout break loop"); break; } if (offset + 1 >= RECV_BUFFER_SIZE) { atpsr_err("buffer full"); break; } buf[offset++] = c; buf[offset] = 0; at_scan_for_callback(fd, c, buf, RECV_BUFFER_SIZE, &offset); if (dev->_wait_prompt && atcmdconfig && atcmdconfig->reply_success_postfix && strncmp(atcmdconfig->reply_success_postfix, AT_SEND_DEFAULT_DATA_PROMPT, strlen(AT_SEND_DEFAULT_DATA_PROMPT)) == 0) { if (offset >= strlen(AT_SEND_DEFAULT_DATA_PROMPT) && strncmp(buf + offset - strlen(AT_SEND_DEFAULT_DATA_PROMPT), AT_SEND_DEFAULT_DATA_PROMPT, strlen(AT_SEND_DEFAULT_DATA_PROMPT)) == 0) { return 0; } } if (replybuf == NULL || bufsize <= 0) { // if no task, continue recv continue; } if (NULL != atcmdconfig && NULL != atcmdconfig->reply_prefix) { rsp_prefix = atcmdconfig->reply_prefix; rsp_prefix_len = strlen(rsp_prefix); } else { rsp_prefix = dev->_default_recv_prefix; rsp_prefix_len = dev->_recv_prefix_len; } if (NULL != atcmdconfig && NULL != atcmdconfig->reply_success_postfix) { rsp_success_postfix = atcmdconfig->reply_success_postfix; rsp_success_postfix_len = strlen(rsp_success_postfix); } else { rsp_success_postfix = dev->_default_recv_success_postfix; rsp_success_postfix_len = dev->_recv_success_postfix_len; } if (NULL != atcmdconfig && NULL != atcmdconfig->reply_fail_postfix) { rsp_fail_postfix = atcmdconfig->reply_fail_postfix; rsp_fail_postfix_len = strlen(rsp_fail_postfix); } else { rsp_fail_postfix = dev->_default_recv_fail_postfix; rsp_fail_postfix_len = dev->_recv_fail_postfix_len; } if (offset >= rsp_prefix_len && at_reply_begin == 0 && (strncmp(buf + offset - rsp_prefix_len, rsp_prefix, rsp_prefix_len) == 0)) { at_reply_begin = 1; } if (at_reply_begin == 1) { if (at_reply_offset < bufsize) { replybuf[at_reply_offset] = c; at_reply_offset++; if ((at_reply_offset >= rsp_success_postfix_len && strncmp( replybuf + at_reply_offset - rsp_success_postfix_len, rsp_success_postfix, rsp_success_postfix_len) == 0) || (at_reply_offset >= rsp_fail_postfix_len && strncmp(replybuf + at_reply_offset - rsp_fail_postfix_len, rsp_fail_postfix, rsp_fail_postfix_len) == 0)) { return 0; } } else { memset(replybuf, 0, bufsize); strcpy(replybuf, rsp_fail_postfix); break; } } } return -1; } #else static int at_scan_for_response(int fd, char c, char *buf, int *index) { int rsp_prefix_len = 0; int rsp_success_postfix_len = 0; int rsp_fail_postfix_len = 0; at_task_t *tsk = NULL; char *rsp_prefix = NULL; char *rsp_success_postfix = NULL; char *rsp_fail_postfix = NULL; slist_t *cur = NULL; int offset = *index; int memcpy_size = 0; at_dev_t *dev = NULL; if (!buf || offset < 0) { return 0; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); atpsr_mutex_lock(dev->_task_mutex); slist_for_each_entry_safe(&dev->_task_l, cur, tsk, at_task_t, next) { if (tsk->rsp_state == AT_RSP_WAITPROMPT || tsk->rsp_state == AT_RSP_PENDING || tsk->rsp_state == AT_RSP_PROCESSING) break; } /* if no task, continue recv */ if (NULL == tsk) { /* atpsr_debug("No task in queue"); */ atpsr_mutex_unlock(dev->_task_mutex); return 0; } if (dev->_wait_prompt && tsk->rsp_state == AT_RSP_WAITPROMPT && offset >= strlen(AT_SEND_DEFAULT_DATA_PROMPT)) { if (strncmp(buf + offset - strlen(AT_SEND_DEFAULT_DATA_PROMPT), AT_SEND_DEFAULT_DATA_PROMPT, strlen(AT_SEND_DEFAULT_DATA_PROMPT)) == 0) { tsk->rsp_state = AT_RSP_PENDING; atpsr_sem_signal(tsk->prompt_smpr); memset(buf, 0, offset); offset = 0; } *index = offset; atpsr_mutex_unlock(dev->_task_mutex); return 0; } if (NULL != tsk->rsp_prefix && 0 != tsk->rsp_prefix_len) { rsp_prefix = tsk->rsp_prefix; rsp_prefix_len = tsk->rsp_prefix_len; } else { rsp_prefix = dev->_default_recv_prefix; rsp_prefix_len = dev->_recv_prefix_len; } if (NULL != tsk->rsp_success_postfix && 0 != tsk->rsp_success_postfix_len) { rsp_success_postfix = tsk->rsp_success_postfix; rsp_success_postfix_len = tsk->rsp_success_postfix_len; } else { rsp_success_postfix = dev->_default_recv_success_postfix; rsp_success_postfix_len = dev->_recv_success_postfix_len; } if (NULL != tsk->rsp_fail_postfix && 0 != tsk->rsp_fail_postfix_len) { rsp_fail_postfix = tsk->rsp_fail_postfix; rsp_fail_postfix_len = tsk->rsp_fail_postfix_len; } else { rsp_fail_postfix = dev->_default_recv_fail_postfix; rsp_fail_postfix_len = dev->_recv_fail_postfix_len; } if (offset < rsp_prefix_len && tsk->rsp_state == AT_RSP_PROCESSING) { tsk->rsp_state = AT_RSP_PENDING; memset(tsk->rsp, 0, tsk->rsp_len); tsk->rsp_offset = 0; } if (tsk->rsp_state == AT_RSP_PROCESSING) { if (tsk->rsp_offset < tsk->rsp_len) { tsk->rsp[tsk->rsp_offset] = c; tsk->rsp_offset++; if ((tsk->rsp_offset >= rsp_success_postfix_len && strncmp(tsk->rsp + tsk->rsp_offset - rsp_success_postfix_len, rsp_success_postfix, rsp_success_postfix_len) == 0) || (tsk->rsp_offset >= rsp_fail_postfix_len && strncmp(tsk->rsp + tsk->rsp_offset - rsp_fail_postfix_len, rsp_fail_postfix, rsp_fail_postfix_len) == 0)) { atpsr_sem_signal(tsk->smpr); tsk->rsp_state = AT_RSP_PROCESSED; tsk = NULL; memset(buf, 0, offset); offset = 0; } } else { memset(tsk->rsp, 0, tsk->rsp_len); tsk->rsp_state = AT_RSP_PENDING; } } else { if (offset >= rsp_prefix_len && tsk->rsp_state == AT_RSP_PENDING && (strncmp(buf + offset - rsp_prefix_len, rsp_prefix, rsp_prefix_len) == 0)) { tsk->rsp_state = AT_RSP_PROCESSING; } } *index = offset; atpsr_mutex_unlock(dev->_task_mutex); /* for buffer check */ memcpy_size = rsp_prefix_len > rsp_success_postfix_len ? rsp_prefix_len : rsp_success_postfix_len; memcpy_size = memcpy_size > rsp_fail_postfix_len ? memcpy_size : rsp_fail_postfix_len; return memcpy_size; } static void at_scan_check_buffer(char *buf, int buf_size, int *index, int copy_size) { int offset = *index; if (!buf || offset < 0 || copy_size < 0 || copy_size >= buf_size) { return; } if (offset > (buf_size - 2)) { atpsr_err("buffer full\r\n"); memcpy(buf, buf + offset - copy_size, copy_size); memset(buf + copy_size, 0, offset - copy_size); offset = copy_size; } *index = offset; } static void at_worker(void *arg) { int offset = 0; int ret = 0; int memcpy_size = 0; char c = 0; char *buf = NULL; at_task_para_t *para = NULL; at_dev_t *dev = NULL; para = (at_task_para_t *)arg; if (NULL == para || !check_fd_valid(para->fd)) { atpsr_err("Invalid at worker task para, task exit\n"); return; } buf = para->buf; if (NULL == buf) { atpsr_err("AT worker fail to allocate buffer, task exit\r\n"); return; } memset(buf, 0, para->buf_size); dev = obtain_dev_by_fd(para->fd); dev->_inited = 1; atpsr_sem_signal(dev->_task_start_sem); atpsr_debug("at_work_%d started", para->fd); while (dev->_inited) { if (dev->_worker_halt) { atpsr_sleep_ms(10); continue; } // read from uart and store buf ret = at_getc(para->fd, &c, dev->_timeout_ms); if (ret != 0) { continue; } else { if(echo_flag) { amp_at_debug_c(c); } } if (offset + 1 >= para->buf_size) { atpsr_err("Fatal error, no one is handling AT uart"); goto check_buffer; } buf[offset++] = c; buf[offset] = 0; /* STEP 1: check whether there is a prefix of resgistered callback */ at_scan_for_callback(para->fd, c, buf, para->buf_size, &offset); /* STEP 2: check whether there is a response for AT cmd sent */ memcpy_size = at_scan_for_response(para->fd, c, buf, &offset); /* STEP 3: check and clear buffer when it is full */ check_buffer: at_scan_check_buffer(buf, para->buf_size, &offset, memcpy_size); } atpsr_sem_signal(dev->_task_exit_sem); return; } static int stop_at_worker(int fd) { at_dev_t *dev = NULL; if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); dev->_inited = 0; if (atpsr_sem_wait(dev->_task_exit_sem, AT_TASK_DEFAULT_WAIT_TIME_MS) != 0) { return -1; } return 0; } static int at_worker_task_add(int fd, at_task_t *tsk) { at_dev_t *dev = NULL; if (NULL == tsk) { atpsr_err("invalid input %s \r\n", __func__); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); atpsr_mutex_lock(dev->_task_mutex); slist_add_tail(&tsk->next, &dev->_task_l); atpsr_mutex_unlock(dev->_task_mutex); return 0; } static int at_worker_task_del(int fd, at_task_t *tsk) { at_dev_t *dev = NULL; if (NULL == tsk) { atpsr_err("invalid input %s \r\n", __func__); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); atpsr_mutex_lock(dev->_task_mutex); slist_del(&tsk->next, &dev->_task_l); atpsr_mutex_unlock(dev->_task_mutex); if (tsk->smpr != NULL) { atpsr_sem_free(tsk->smpr); } if (tsk->prompt_smpr != NULL) { atpsr_sem_free(tsk->prompt_smpr); } if (tsk) { atpsr_free(tsk); } return 0; } #endif static int check_config_valid(at_config_t *config) { int i; if (NULL == config || NULL == config->dev_cfg) { atpsr_err("Invalid AT device config\n"); return -1; } /* check existence of port */ for (i = 0; i < ATPSR_DEV_MAX_NUM; i++) { if (at_dev[i]._inited) { if (at_dev[i]._port == config->port) { atpsr_err("Port exist\n"); return -1; } } } return 0; } static int assign_dev_fd(at_dev_type_t type) { int i; (void)type; for (i = 0; i < ATPSR_DEV_MAX_NUM; i++) { if (!at_dev[i]._inited) { return i; } } return -1; } static void deinit_dev(int fd) { at_dev_t *dev; at_dev_ops_t *op = NULL; oob_t *oob = NULL; int k = 0; if (!check_fd_valid(fd)) return; dev = obtain_dev_by_fd(fd); op = obtain_op_by_type(dev->_type); if(op) { op->deinit(dev->_dev); } if ((dev->_send_delimiter != NULL) && (strcmp(dev->_send_delimiter, AT_SEND_DEFAULT_DELIMITER) != 0)) { aos_free(dev->_send_delimiter); dev->_send_delimiter = NULL; } for (k = 0; k < dev->_oobs_num; k++) { oob = &(dev->_oobs[k]); if(oob->prefix != NULL) { aos_free(oob->prefix); oob->prefix = NULL; } if(oob->postfix != NULL) { aos_free(oob->postfix); oob->postfix = NULL; } } if (dev->_recv_mutex != NULL) { atpsr_mutex_free(dev->_recv_mutex); } if (dev->_send_mutex != NULL) { atpsr_mutex_free(dev->_send_mutex); } #if !ATPSR_SINGLE_TASK if (dev->_task_mutex != NULL) { atpsr_mutex_free(dev->_task_mutex); } if (dev->_task_start_sem != NULL) { atpsr_sem_free(dev->_task_start_sem); } if (dev->_task_exit_sem != NULL) { atpsr_sem_free(dev->_task_exit_sem); } if (dev->_task_para != NULL) { if (dev->_task_para->buf != NULL) { atpsr_free(dev->_task_para->buf); dev->_task_para->buf = NULL; } atpsr_free(dev->_task_para); } #endif memset(dev, 0, sizeof(at_dev_t)); } static int init_dev(int fd, at_config_t *config) { at_dev_t *dev = NULL; at_dev_ops_t *op = NULL; #if !ATPSR_SINGLE_TASK void *task; at_task_para_t *para = NULL; #endif if (inited == 0) { return -1; } if (!check_fd_valid(fd) || !config || !config->dev_cfg) { atpsr_err("init_dev invalid input\n"); return -1; } if (!check_type_valid(config->type) || (op = obtain_op_by_type(config->type)) == NULL) { atpsr_err("init_dev invalid type or at_dev_ops\n"); return -1; } if (op->init(config->dev_cfg) != 0) { atpsr_err("at dev init failed\n"); return -1; } dev = obtain_dev_by_fd(fd); memset(dev, 0, sizeof(at_dev_t)); dev->_port = config->port; dev->_type = config->type; dev->_dev = config->dev_cfg; if (config->timeout_ms > 0) { dev->_timeout_ms = config->timeout_ms; } else { dev->_timeout_ms = AT_SEND_RECV_DEFAULT_TIMEOUT_MS; } if (config->reply_cfg.reply_prefix) { dev->_default_recv_prefix = config->reply_cfg.reply_prefix; } else { dev->_default_recv_prefix = AT_RECV_DEFAULT_PREFIX; } if (config->reply_cfg.reply_success_postfix) { dev->_default_recv_success_postfix = config->reply_cfg.reply_success_postfix; } else { dev->_default_recv_success_postfix = AT_RECV_DEFAULT_SUCCESS_POSTFIX; } if (config->reply_cfg.reply_fail_postfix) { dev->_default_recv_fail_postfix = config->reply_cfg.reply_fail_postfix; } else { dev->_default_recv_fail_postfix = AT_RECV_DEFAULT_FAIL_POSTFIX; } dev->_recv_prefix_len = strlen(dev->_default_recv_prefix); dev->_recv_success_postfix_len = strlen(dev->_default_recv_success_postfix); dev->_recv_fail_postfix_len = strlen(dev->_default_recv_fail_postfix); if ((config->send_delimiter) && (strcmp(config->send_delimiter, AT_SEND_DEFAULT_DELIMITER) != 0)) { char *send_delimiter = aos_malloc(strlen(config->send_delimiter) + 1); memset(send_delimiter, 0, strlen(config->send_delimiter) + 1); memcpy(send_delimiter, config->send_delimiter, strlen(config->send_delimiter)); dev->_send_delimiter = send_delimiter; } else { dev->_send_delimiter = AT_SEND_DEFAULT_DELIMITER; } dev->_wait_prompt = config->send_wait_prompt; if (config->prompt_timeout_ms > 0) { dev->_prompt_timeout_ms = config->prompt_timeout_ms; } else { dev->_prompt_timeout_ms = AT_SEND_DEFAULT_PROMPT_TIMEOUT_MS; } dev->_send_data_no_wait = config->send_data_no_wait; dev->_recv_mutex = atpsr_mutex_new(); if (NULL == dev->_recv_mutex) { atpsr_err("create recv mutex failed\r\n"); goto err; } dev->_send_mutex = atpsr_mutex_new(); if (NULL == dev->_send_mutex) { atpsr_err("create send mutex failed\r\n"); goto err; } #if ATPSR_SINGLE_TASK dev->_inited = 1; #else dev->_task_mutex = atpsr_mutex_new(); if (NULL == dev->_task_mutex) { atpsr_err("create task mutex failed\r\n"); goto err; } dev->_task_start_sem = atpsr_sem_new(); if (NULL == dev->_task_start_sem) { atpsr_err("create task start sem failed\r\n"); goto err; } dev->_task_exit_sem = atpsr_sem_new(); if (NULL == dev->_task_exit_sem) { atpsr_err("create task exit sem failed\r\n"); goto err; } dev->_task_para = (at_task_para_t *)atpsr_malloc(sizeof(at_task_para_t)); if (NULL == dev->_task_para) { atpsr_err("create task para failed\r\n"); goto err; } dev->_task_para->fd = fd; dev->_task_para->buf_size = RECV_BUFFER_SIZE; dev->_task_para->buf = (char *)atpsr_malloc(RECV_BUFFER_SIZE); if (NULL == dev->_task_para->buf) { atpsr_err("create task para buffer failed\r\n"); goto err; } if (config->recv_task_priority > 0) { dev->_recv_task_prio = config->recv_task_priority; } else { dev->_recv_task_prio = AT_WORKER_DEFAULT_PRIORITY; } if (config->recv_task_stacksize > 0) { dev->_recv_task_stacksize = config->recv_task_stacksize; } else { dev->_recv_task_stacksize = AT_WORKER_DEFAULT_STACK_SIZE; } snprintf(dev->_task_name, AT_TASK_NAME_MAX_LEN, "at_worker_%d", fd); if (atpsr_task_new_ext(&task, dev->_task_name, at_worker, dev->_task_para, dev->_recv_task_stacksize, dev->_recv_task_prio) != 0) { atpsr_err("fail to create at task\r\n"); goto err; } if (atpsr_sem_wait(dev->_task_start_sem, 1000) != 0) { atpsr_err("fail to wait task start sem\r\n"); goto err; } slist_init(&dev->_task_l); #endif return 0; err: deinit_dev(fd); return -1; } /*------------------------------public interface----------------------------------*/ int at_init(void) { if (inited == 1) { atpsr_err("AT module Already inited\n"); return -1; } memset(at_dev, 0, ATPSR_DEV_MAX_NUM * sizeof(at_dev_t)); if (0 == reg_ops_num) { extern at_dev_ops_t at_uart_ops; if (register_at_dev_ops(&at_uart_ops) != 0) { atpsr_err("AT device register default ops failed\n"); return -1; } reg_ops_num++; } inited = 1; return 0; } int at_deinit(void) { int i; /* delete all at devices */ for (i = 0; i < ATPSR_DEV_MAX_NUM; i++) { at_delete_dev(i); } unregister_at_dev_ops(); inited = 0; return 0; } int at_add_dev(at_config_t *config) { int fd; if (inited == 0) { atpsr_err("AT module not inited\n"); return -1; } if (check_config_valid(config) != 0) return -1; if ((fd = assign_dev_fd(config->type)) < 0) { atpsr_err("assign dev fd fail\n"); return -1; } if (init_dev(fd, config) != 0) { atpsr_err("init dev fd fail\n"); return -1; } return fd; } int at_delete_dev(int fd) { if (!check_fd_valid(fd)) return -1; #if !ATPSR_SINGLE_TASK stop_at_worker(fd); #endif deinit_dev(fd); return 0; } int at_send_no_reply(int fd, const char *data, int datalen, bool delimiter) { int ret = 0; at_dev_t *dev = NULL; at_dev_ops_t *op = NULL; if (inited == 0) { atpsr_err("at module have not init yet\r\n"); return -1; } if (NULL == data || datalen <= 0) { atpsr_err("invalid input \r\n"); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); op = obtain_op_by_type(dev->_type); atpsr_mutex_lock(dev->_send_mutex); if ((ret = op->send(dev->_dev, (void *)data, datalen, dev->_timeout_ms)) != 0) { atpsr_err("uart send raw content (%s) failed", data); ret = -1; goto done; } if (delimiter) { if ((ret = op->send(dev->_dev, (void *)dev->_send_delimiter, strlen(dev->_send_delimiter), dev->_timeout_ms)) != 0) { atpsr_err("uart send delimiter failed"); ret = -1; goto done; } } done: atpsr_mutex_unlock(dev->_send_mutex); return ret; } int at_read(int fd, char *outbuf, int readsize) { int ret = 0; uint32_t recv_size, total_read = 0; at_dev_t *dev = NULL; at_dev_ops_t *op = NULL; if (inited == 0) { atpsr_err("at module have not init yet\r\n"); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); op = obtain_op_by_type(dev->_type); atpsr_mutex_lock(dev->_recv_mutex); while (total_read < readsize) { ret = op->recv(dev->_dev, (void *)(outbuf + total_read), readsize - total_read, &recv_size, dev->_timeout_ms); if (ret != 0) { atpsr_err("at_read failed on uart_recv. ret %d\n", ret); break; } if (recv_size <= 0) { continue; } total_read += recv_size; if (total_read >= readsize) { break; } } atpsr_mutex_unlock(dev->_recv_mutex); if (ret != 0) { return -1; } return total_read; } #if ATPSR_SINGLE_TASK int at_send_wait_reply(int fd ,const char *cmd, int cmdlen, bool delimiter, const char *data, int datalen, char *replybuf, int bufsize, const at_reply_config_t *atcmdconfig) { at_dev_t *dev = NULL; if (inited == 0) { atpsr_err("at module have not init yet\r\n"); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); if (at_send_no_reply(fd, cmd, cmdlen, delimiter) < 0) { return -1; } if (data && datalen) { if (dev->_wait_prompt) { at_reply_config_t prompt = {NULL, AT_SEND_DEFAULT_DATA_PROMPT, NULL}; if (at_yield(fd, NULL, 0, &prompt, dev->_prompt_timeout_ms) < 0) { return -1; } } if (at_send_no_reply(fd, data, datalen, false) < 0) { return -1; } } if (at_yield(fd, replybuf, bufsize, atcmdconfig, dev->_timeout_ms) < 0) { return -1; } return 0; } #else int at_send_wait_reply(int fd, const char *cmd, int cmdlen, bool delimiter, const char *data, int datalen, char *replybuf, int bufsize, const at_reply_config_t *atcmdconfig) { int ret = 0; at_dev_t *dev = NULL; at_dev_ops_t *op = NULL; at_task_t *tsk = NULL; if (inited == 0) { atpsr_err("at module have not init yet\r\n"); return -1; } if (NULL == cmd || cmdlen <= 0) { atpsr_err("%s invalid input \r\n", __FUNCTION__); return -1; } if (NULL == replybuf || 0 == bufsize) { atpsr_err("%s invalid input \r\n", __FUNCTION__); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); op = obtain_op_by_type(dev->_type); atpsr_mutex_lock(dev->_send_mutex); if (NULL == data || 0 == dev->_send_data_no_wait) { tsk = (at_task_t *)atpsr_malloc(sizeof(at_task_t)); if (NULL == tsk) { atpsr_err("tsk buffer allocating failed"); atpsr_mutex_unlock(dev->_send_mutex); return -1; } memset(tsk, 0, sizeof(at_task_t)); if (NULL == (tsk->smpr = atpsr_sem_new())) { atpsr_err("failed to allocate semaphore"); goto done; } if (atcmdconfig) { if (NULL != atcmdconfig->reply_prefix) { tsk->rsp_prefix = atcmdconfig->reply_prefix; tsk->rsp_prefix_len = strlen(atcmdconfig->reply_prefix); } if (NULL != atcmdconfig->reply_success_postfix) { tsk->rsp_success_postfix = atcmdconfig->reply_success_postfix; tsk->rsp_success_postfix_len = strlen(atcmdconfig->reply_success_postfix); } if (NULL != atcmdconfig->reply_fail_postfix) { tsk->rsp_fail_postfix = atcmdconfig->reply_fail_postfix; tsk->rsp_fail_postfix_len = strlen(atcmdconfig->reply_fail_postfix); } } tsk->command = (char *)cmd; tsk->rsp = replybuf; tsk->rsp_len = bufsize; if (dev->_wait_prompt && data != NULL && datalen > 0) { tsk->rsp_state = AT_RSP_WAITPROMPT; tsk->prompt_smpr = atpsr_sem_new(); if (NULL == (tsk->prompt_smpr)) { atpsr_err("failed to allocate prompt sem"); goto done; } } else { tsk->rsp_state = AT_RSP_PENDING; } at_worker_task_add(fd, tsk); } if ((ret = op->send(dev->_dev, (void *)cmd, cmdlen, dev->_timeout_ms)) != 0) { atpsr_err("uart send command failed"); goto done; } if (delimiter) { if ((ret = op->send(dev->_dev, (void *)dev->_send_delimiter, strlen(dev->_send_delimiter), dev->_timeout_ms)) != 0) { atpsr_err("uart send delimiter failed"); goto done; } } if (data != NULL && datalen > 0) { if (dev->_wait_prompt) { if (tsk != NULL) { if ((ret = atpsr_sem_wait(tsk->prompt_smpr, dev->_prompt_timeout_ms)) != 0) { atpsr_err("prompt wait timeout"); } } else { atpsr_sleep_ms(dev->_prompt_timeout_ms); } } if ((ret = op->send(dev->_dev, (void *)data, datalen, dev->_timeout_ms)) != 0) { atpsr_err("uart send delimiter failed"); goto done; } } if (tsk != NULL && (ret = atpsr_sem_wait(tsk->smpr, AT_TASK_DEFAULT_WAIT_TIME_MS)) != 0) { atpsr_err("sem_wait failed"); goto done; } done: if (tsk != NULL) at_worker_task_del(fd, tsk); atpsr_mutex_unlock(dev->_send_mutex); return ret; } #endif int at_register_callback(int fd, const char *prefix, const char *postfix, char *recvbuf, int bufsize, at_recv_cb cb, void *arg) { oob_t *oob = NULL; int i = 0; at_dev_t *dev = NULL; char *temp = NULL; if (inited == 0) { atpsr_err("at module have not init yet\r\n"); return -1; } if (bufsize < 0 || bufsize >= RECV_BUFFER_SIZE || NULL == prefix) { atpsr_err("%s invalid input \r\n", __func__); return -1; } if (NULL != postfix && (NULL == recvbuf || 0 == bufsize)) { atpsr_err("%s invalid postfix input \r\n", __func__); return -1; } if (!check_fd_valid(fd) || !check_dev_ready(fd)) return -1; dev = obtain_dev_by_fd(fd); if (dev->_oobs_num >= OOB_MAX) { atpsr_err("No place left in OOB.\r\n"); return -1; } /* check oob is exit */ for (i = 0; i < dev->_oobs_num; i++) { if (strcmp(prefix, dev->_oobs[i].prefix) == 0) { atpsr_debug("oob prefix %s is already exist.\r\n", prefix); return -1; } } oob = &(dev->_oobs[dev->_oobs_num++]); oob->oobinputdata = recvbuf; if (oob->oobinputdata != NULL) { memset(oob->oobinputdata, 0, bufsize); } oob->maxlen = bufsize; if(prefix != NULL) { temp = aos_malloc(strlen(prefix) + 1); memset(temp, 0, strlen(prefix) + 1); memcpy(temp, prefix, strlen(prefix)); oob->prefix = temp; } else { oob->prefix = (char *)prefix; } if(postfix != NULL) { temp = aos_malloc(strlen(postfix) + 1); memset(temp, 0, strlen(postfix) + 1); memcpy(temp, postfix, strlen(postfix)); oob->postfix = temp; } else { oob->postfix = (char *)postfix; } oob->cb = cb; oob->arg = arg; oob->reallen = 0; atpsr_debug("New oob registered (%s)", oob->prefix); return 0; } int at_yield(int fd, char *replybuf, int bufsize, const at_reply_config_t *atcmdconfig, int timeout_ms) { #if ATPSR_SINGLE_TASK return at_yield_impl(fd, replybuf, bufsize, atcmdconfig, timeout_ms); #else atpsr_err("at_yield should not be called in multiple task mode"); return -1; #endif } void at_worker_halt(int fd) { #if ATPSR_SINGLE_TASK return; #else at_dev_t *dev = NULL; if (!check_fd_valid(fd) || !check_dev_ready(fd)) return; dev = obtain_dev_by_fd(fd); dev->_worker_halt = 1; return; #endif } void at_worker_resume(int fd) { #if ATPSR_SINGLE_TASK return; #else at_dev_t *dev = NULL; if (!check_fd_valid(fd) || !check_dev_ready(fd)) return; dev = obtain_dev_by_fd(fd); dev->_worker_halt = 0; return; #endif } void at_set_echo(int flag) { echo_flag = flag; }
YifuLiu/AliOS-Things
components/amp/components/at/src/at.c
C
apache-2.0
36,736
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #ifndef _ATPARSER_INTERNAL_H_ #define _ATPARSER_INTERNAL_H_ #include "at.h" #include "at_opts.h" #include <stdarg.h> #include <stdio.h> #include "ulog.h" #define AT_LOGD(fmt, ...) LOGD("at",fmt,##__VA_ARGS__) #define AT_LOGI(fmt, ...) LOGI("at",fmt,##__VA_ARGS__) #define AT_LOGW(fmt, ...) LOGW("at",fmt,##__VA_ARGS__) #define AT_LOGE(fmt, ...) LOGE("at",fmt,##__VA_ARGS__) #define OOB_MAX 32 typedef enum { AT_RSP_WAITPROMPT = 0, AT_RSP_PENDING, AT_RSP_PROCESSING, AT_RSP_PROCESSED, AT_RSP_INVALID, } at_rsp_state_t; typedef struct oob_s { char * prefix; char * postfix; char * oobinputdata; uint32_t reallen; uint32_t maxlen; at_recv_cb cb; void * arg; } oob_t; #if !ATPSR_SINGLE_TASK #include "amp_list.h" /* * --> | slist | --> | slist | --> NULL * --------- --------- * | smhr | | smpr | * --------- --------- * | rsp | | rsp | * --------- --------- */ typedef struct at_task_s { slist_t next; void * smpr; void * prompt_smpr; char * command; char * rsp; char * rsp_prefix; char * rsp_success_postfix; char * rsp_fail_postfix; uint32_t rsp_prefix_len; uint32_t rsp_success_postfix_len; uint32_t rsp_fail_postfix_len; uint32_t rsp_offset; uint32_t rsp_len; at_rsp_state_t rsp_state; } at_task_t; typedef struct { int fd; char *buf; int buf_size; } at_task_para_t; #define AT_TASK_NAME_MAX_LEN 15 #endif /** * Parser structure for parsing AT commands */ typedef struct { uint8_t _inited; uint8_t _port; at_dev_type_t _type; void *_dev; uint32_t _timeout_ms; char *_default_recv_prefix; char *_default_recv_success_postfix; char *_default_recv_fail_postfix; char *_send_delimiter; uint8_t _wait_prompt; int _prompt_timeout_ms; uint8_t _send_data_no_wait; int _recv_prefix_len; int _recv_success_postfix_len; int _recv_fail_postfix_len; int _send_delim_size; oob_t _oobs[OOB_MAX]; int _oobs_num; void *_recv_mutex; void *_send_mutex; #if !ATPSR_SINGLE_TASK int _recv_task_prio; int _recv_task_stacksize; void *_task_mutex; char _task_name[AT_TASK_NAME_MAX_LEN]; at_task_para_t *_task_para; void *_task_start_sem; void *_task_exit_sem; slist_t _task_l; uint8_t _worker_halt; #endif } at_dev_t; void *atpsr_malloc(uint32_t size); void atpsr_free(void *ptr); void *atpsr_mutex_new(void); void atpsr_mutex_free(void *mutex); void atpsr_mutex_lock(void *mutex); void atpsr_mutex_unlock(void *mutex); void *atpsr_sem_new(void); void atpsr_sem_free(void *sem); void atpsr_sem_signal(void *sem); int atpsr_sem_wait(void *sem, uint32_t timeout_ms); int atpsr_task_new_ext(void *task, char *name, void (*fn)(void *), void *arg, int stack_size, int prio); void atpsr_sleep_ms(const unsigned int millisec); #endif
YifuLiu/AliOS-Things
components/amp/components/at/src/at_internal.h
C
apache-2.0
3,382
#ifndef _ATPARSER_OPTS_H_ #define _ATPARSER_OPTS_H_ #ifdef __cplusplus extern "C" { #endif #define ATPSR_OPT_ENABLED 1 #define ATPSR_OPT_DISABLED 0 #ifndef ATPSR_SINGLE_TASK #define ATPSR_SINGLE_TASK ATPSR_OPT_DISABLED #endif #ifndef ATPSR_DEV_MAX_NUM #define ATPSR_DEV_MAX_NUM 1 #endif #ifndef AT_TASK_DEFAULT_WAIT_TIME_MS #define AT_TASK_DEFAULT_WAIT_TIME_MS 5000 #endif #ifndef AT_SEND_RECV_DEFAULT_TIMEOUT_MS #define AT_SEND_RECV_DEFAULT_TIMEOUT_MS 3000 #endif #ifndef AT_SEND_DEFAULT_PROMPT_TIMEOUT_MS #define AT_SEND_DEFAULT_PROMPT_TIMEOUT_MS 200 #endif #ifndef AT_RECV_DEFAULT_PREFIX #define AT_RECV_DEFAULT_PREFIX "\r\n" #endif #ifndef AT_RECV_DEFAULT_SUCCESS_POSTFIX #define AT_RECV_DEFAULT_SUCCESS_POSTFIX "OK\r\n" #endif #ifndef AT_RECV_DEFAULT_FAIL_POSTFIX #define AT_RECV_DEFAULT_FAIL_POSTFIX "ERROR\r\n" #endif #ifndef AT_SEND_DEFAULT_DELIMITER #define AT_SEND_DEFAULT_DELIMITER "\r" #endif #ifndef AT_SEND_DEFAULT_DATA_PROMPT #define AT_SEND_DEFAULT_DATA_PROMPT ">" #endif #ifndef AT_WORKER_DEFAULT_STACK_SIZE #define AT_WORKER_DEFAULT_STACK_SIZE 4096 #endif #ifndef AT_WORKER_DEFAULT_PRIORITY #define AT_WORKER_DEFAULT_PRIORITY 32 /* Default AOS_DEFAULT_APP_PR */ #endif #ifdef __cplusplus } #endif #endif
YifuLiu/AliOS-Things
components/amp/components/at/src/at_opts.h
C
apache-2.0
1,382
/* * Copyright (C) 2015-2017 Alibaba Group Holding Limited */ #ifndef _ATCMD_CONFIG_MODULE #define _ATCMD_CONFIG_MODULE /** * AT related platform-dependent things are here, including: * 1. AT command; * 2. AT response code; * 3. AT delimiter; * 4. AT event; * 5. Uart port used by AT; * 6. ... */ // AT command #define AT_CMD_ENET_SEND "AT+ENETRAWSEND" #define AT_CMD_ENTER_ENET_MODE "AT+ENETRAWMODE=ON" #define AT_CMD_EHCO_OFF "AT+UARTE=OFF" #define AT_CMD_TEST "AT" // Delimiter #define AT_RECV_PREFIX "\r\n" #define AT_RECV_SUCCESS_POSTFIX "OK\r\n" #define AT_RECV_FAIL_POSTFIX "ERROR\r\n" #define AT_SEND_DELIMITER "\r" // send delay #define AT_SEND_DATA_DELAY_MS 50 // AT event #define AT_EVENT_ENET_DATA "+ENETEVENT:" #endif
YifuLiu/AliOS-Things
components/amp/components/at/src/atcmd_config_module.h
C
apache-2.0
760
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "at_internal.h" #include "aos_hal_uart.h" /*-----------------------------UART operates------------------------------------------*/ static int at_init_uart(void *dev) { int ret = 0; ret = aos_hal_uart_init((uart_dev_t *)dev); return ret; } static int at_recvfrom_uart(void *dev, void *data, uint32_t expect_size, uint32_t *recv_size, uint32_t timeout) { int ret = 0; ret = aos_hal_uart_recv_II((uart_dev_t *)dev, data, expect_size, recv_size, timeout); return ret; } static int at_sendto_uart(void *dev, void *data, uint32_t size, uint32_t timeout) { int ret = 0; ret = aos_hal_uart_send((uart_dev_t *)dev, data, size, timeout); return ret; } static int at_deinit_uart(void *dev) { int ret = 0; ret = aos_hal_uart_finalize((uart_dev_t *)dev); return ret; } at_dev_ops_t at_uart_ops = { .type = AT_DEV_UART, .init = at_init_uart, .recv = at_recvfrom_uart, .send = at_sendto_uart, .deinit = at_deinit_uart, }; /*-----------------------------Add other devices' operates below-----------------------------------------*/
YifuLiu/AliOS-Things
components/amp/components/at/src/hal_at_dev.c
C
apache-2.0
1,228
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include <stdlib.h> #include "aos_system.h" #include "at_opts.h" void *atpsr_malloc(uint32_t size) { return aos_malloc(size); } void atpsr_free(void *ptr) { aos_free(ptr); } #if ATPSR_SINGLE_TASK void *atpsr_mutex_new(void) { return (void*)1; } void atpsr_mutex_free(void *mutex) { return; } void atpsr_mutex_lock(void *mutex) { return; } void atpsr_mutex_unlock(void *mutex) { return; } void *atpsr_sem_new(void) { return (void*)1; } void atpsr_sem_free(void *sem) { return; } void atpsr_sem_signal(void *sem) { return; } int atpsr_sem_wait(void *sem, uint32_t timeout_ms) { return 0; } #else void *atpsr_mutex_new(void) { aos_mutex_t mutex; if (0 != aos_mutex_new(&mutex)) { return NULL; } return mutex; } void atpsr_mutex_free(void *mutex) { if (NULL != mutex) { aos_mutex_free((aos_mutex_t *)&mutex); } } void atpsr_mutex_lock(void *mutex) { if (NULL != mutex) { aos_mutex_lock((aos_mutex_t *)&mutex, AOS_WAIT_FOREVER); } } void atpsr_mutex_unlock(void *mutex) { if (NULL != mutex) { aos_mutex_unlock((aos_mutex_t *)&mutex); } } void *atpsr_sem_new(void) { aos_sem_t sem; if (0 != aos_sem_new(&sem, 0)) { return NULL; } return sem; } void atpsr_sem_free(void *sem) { aos_sem_free((aos_sem_t *)&sem); } void atpsr_sem_signal(void *sem) { aos_sem_signal((aos_sem_t *)&sem); } int atpsr_sem_wait(void *sem, uint32_t timeout_ms) { return aos_sem_wait((aos_sem_t *)&sem, timeout_ms); } int atpsr_task_new_ext(void *task, char *name, void (*fn)(void *), void *arg, int stack_size, int prio) { if (task == NULL) return -1; return aos_task_new_ext(&task, name, fn, arg, stack_size, AOS_DEFAULT_APP_PRI); } void atpsr_sleep_ms(const unsigned int millisec) { aos_msleep(millisec); } #endif
YifuLiu/AliOS-Things
components/amp/components/at/src/hal_at_os.c
C
apache-2.0
1,977
TARGET = libjsengine.a MODULE = duktape_engine MOD_SOURCES += \ addons/hardware/adc/module_adc.c \ addons/hardware/dac/module_dac.c \ addons/hardware/can/module_can.c \ addons/hardware/gpio/module_gpio.c \ addons/hardware/i2c/module_i2c.c \ addons/hardware/ir/module_ir.c \ addons/hardware/lcd/module_lcd.c \ addons/hardware/pwm/module_pwm.c \ addons/hardware/rtc/module_rtc.c \ addons/hardware/spi/module_spi.c \ addons/hardware/timer/module_timer.c \ addons/hardware/uart/module_uart.c \ addons/hardware/wdg/module_wdg.c MOD_SOURCES += \ addons/network/http/module_http.c \ addons/network/mqtt/module_mqtt.c \ addons/network/mqtt/module_mqtt_client.c \ addons/network/tcp/module_tcp.c \ addons/network/udp/module_udp.c \ addons/network/wifi/module_wifi.c \ addons/network/cellular/module_cellular.c MOD_SOURCES += \ addons/utils/builtin/module_builtin.c \ addons/utils/crypto/module_crypto.c \ addons/utils/fs/module_fs.c \ addons/utils/kv/module_kv.c \ addons/utils/system/module_system.c \ addons/utils/systimer/module_systimer.c \ addons/utils/pm/module_pm.c \ addons/utils/pm/module_battery.c \ addons/utils/pm/module_charger.c MOD_SOURCES += \ addons/advanced/audio/module_tts.c \ addons/advanced/und/module_und.c \ addons/advanced/aiot/module_aiot_device.c \ addons/advanced/aiot/module_aiot_gateway.c \ addons/advanced/aiot/module_aiot_mqtt.c \ addons/advanced/aiot/module_aiot_dynreg.c \ addons/advanced/aiot/module_aiot_activeinfo.c \ MOD_SOURCES += \ duktape/duktape.c MOD_SOURCES += \ be_module_node.c \ be_refs.c \ be.c \ repl.c \ startup/app_entry.c # including libjs MOD_SOURCES += \ addons/libjs.c MOD_INCLUDES := \ ./ \ duktape \ duktape/addons/advanced/aiot \ ../../main \ ../../adapter/include \ ../../adapter/include/peripheral \ ../../adapter/platform/linux \ ../../utils/mbedtls/include \ ../../utils/mbedtls/platform/include \ ../../utils/mbedtls/platform/amp/include \ ../../utils/cJSON \ ../../utils/list \ ../../services/amp_utils \ ../../services/board_mgr \ ../../services/recovery \ ../../components/linksdk/components/bootstrap \ ../../components/linksdk/components/data-model \ ../../components/linksdk/components/devinfo \ ../../components/linksdk/components/diag \ ../../components/linksdk/components/dynreg \ ../../components/linksdk/components/ntp \ ../../components/linksdk/components/subdev \ ../../components/linksdk/core \ ../../components/linksdk/core/sysdep \ ../../components/linksdk/core/utils \ ../../components/ulog \ ../../components/http/include \ ../../components/ota/include \ ../../components/und/include ifeq ($(ADDON), ui) MOD_SOURCES += \ addons/utils/ui/module_vm.c \ addons/utils/ui/module_ui.c \ startup/page_entry.c MOD_INCLUDES += \ ../../ui/render/include \ ../../ui/aui/aui_core \ ../../ui/aui/aui_draw \ ../../ui/aui/aui_fonts \ ../../ui/aui/aui_hal \ ../../ui/aui/aui_misc \ ../../ui/aui/aui_objx \ ../../ui/aui/aui_themes \ ../../ui/aui/libs \ ../../ui/aui/libs/lvgl \ ../../ui/aui/libs/lvgl/src\ ../../ui/aui/libs/lvgl/src/lv_misc \ ../../ui/aui/libs/lvgl/src/lv_font \ ../../ui/aui/libs/lvgl/src/lv_core \ ../../ui/aui/libs/lvgl/src/lv_draw \ ../../ui/aui/libs/lvgl/src/lv_hal \ ../../ui/aui/libs/lvgl/src/lv_objx \ ../../ui/aui/libs/lvgl/src/lv_themes \ ../../utils/ezxml \ ../../utils/lexbor \ ../../utils/lexbor/css \ ../../adapter/include endif include $(TOOLS_DIR)/rules.mk
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/Makefile
Makefile
apache-2.0
3,551
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "stdint.h" #include "aiot_mqtt_api.h" /* device active info report */ #define APPLICATION "soundbox" // product of application #define MODULE_NAME aos_get_platform_type() // module type /* device info report format */ #define DEVICE_INFO_UPDATE_FMT \ "[" \ "{\"attrKey\":\"SYS_SDK_LANGUAGE\",\"attrValue\":\"C\",\"domain\":\"SYSTEM\"}" \ "{\"attrKey\":\"SYS_LP_SDK_VERSION\",\"attrValue\":\"aos-r-3.0.0\",\"domain\":\"SYSTEM\"}" \ "{\"attrKey\":\"SYS_PARTNER_ID\",\"attrValue\":\"AliOS Things Team\",\"domain\":\"SYSTEM\"}" \ "{\"attrKey\":\"SYS_MODULE_ID\",\"attrValue\":\"haas-amp-%s@%s\",\"domain\":\"SYSTEM\"}" \ "]" typedef enum { AIOT_MQTT_CONNECT, AIOT_MQTT_RECONNECT, AIOT_MQTT_DISCONNECT, AIOT_MQTT_MESSAGE }aiot_mqtt_res_type_t; /** * @brief dev模块内部发生值得用户关注的状态变化时, 通知用户的事件类型 */ typedef enum { /** * @brief 非法的应答报文 */ AIOT_DEV_JSCALLBACK_INVALID_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_CREATE_DEV_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_SUBSCRIBE_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_UNSUBSCRIBE_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_PUBLISH_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_POST_PROPS_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_POST_EVENT_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_ONPROPS_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_ONSERVICE_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_REGISTER_DEV_REF, /** * @brief 应答报文的id字段非法 */ AIOT_DEV_JSCALLBACK_END_CLIENT_REF, /** * @brief 应答报文的code字段非法 */ AIOT_DEV_JSCALLBACK_INVALID_CODE } aiot_dev_jscallback_type_t; /** * @brief subdev模块内部发生值得用户关注的状态变化时, 通知用户的事件类型 */ typedef enum { /** * @brief 非法的应答报文 */ AIOT_SUBDEV_JSCALLBACK_INVALID_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_CREATE_GATEWAY_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_ADD_TOPO_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_GET_TOPO_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_REMOVE_TOPO_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_LOGIN_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_LOGOUT_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_ON_MQTT_MESSAGE_REF, /** * @brief 应答报文的code字段非法 */ AIOT_SUBDEV_JSCALLBACK_REGISTER_SUBDEV_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_SUBSCRIBE_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_UNSUBSCRIBE_REF, /** * @brief 应答报文的id字段非法 */ AIOT_SUBDEV_JSCALLBACK_PUBLISH_REF, /** * @brief 应答报文的code字段非法 */ AIOT_SUBDEV_JSCALLBACK_INVALID_CODE } aiot_subdev_jscallback_type_t; typedef struct iot_device_hanlde{ void *mqtt_handle; void *dm_handle; char *region; int js_cb_ref[AIOT_DEV_JSCALLBACK_INVALID_CODE]; uint16_t keepaliveSec; int res; }iot_device_handle_t; typedef struct iot_gateway_handle{ void *mqtt_handle; void *dm_handle; void *subdev_handle; int js_cb_ref[AIOT_SUBDEV_JSCALLBACK_INVALID_CODE]; uint16_t keepaliveSec; }iot_gateway_handle_t; typedef struct iot_gateway_response{ int js_cb_ref; int msg_id; int code; char productkey[IOTX_PRODUCT_KEY_LEN]; char devicename[IOTX_DEVICE_NAME_LEN]; char message[128]; }iot_gateway_response_t; typedef struct { aiot_mqtt_recv_type_t type; int code; int topic_len; int payload_len; char *topic; char *payload; } iot_mqtt_recv_t; typedef struct { aiot_mqtt_event_type_t type; int code; } iot_mqtt_event_t; typedef struct { aiot_mqtt_option_t option; iot_mqtt_recv_t recv; iot_mqtt_event_t event; }iot_mqtt_message_t; typedef struct { void (*callback)(iot_mqtt_message_t *message, void *userdata); void *handle; }iot_mqtt_userdata_t; /* create mqtt client */ int32_t aiot_mqtt_client_start(void **handle, int keepaliveSec, iot_mqtt_userdata_t *userdata); /* destroy mqtt client */ int32_t aiot_mqtt_client_stop(void **handle); /* app mqtt process thread */ void *aiot_app_mqtt_process_thread(void *args); /* app mqtt recv thread */ void *aiot_app_mqtt_recv_thread(void *args); /* property post */ int32_t aiot_app_send_property_post(void *dm_handle, char *params); /* event post */ int32_t aiot_app_send_event_post(void *dm_handle, char *event_id, char *params); /* device dynmic register */ int32_t aiot_dynreg_http(int js_cb_ref); /* device active info report */ int32_t amp_app_devinfo_report(void *mqtt_handle);
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/aiot/module_aiot.h
C
apache-2.0
5,566
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "aos_network.h" #include "aos/kv.h" #include "aiot_state_api.h" #include "aiot_sysdep_api.h" #include "aiot_mqtt_api.h" #include "aiot_devinfo_api.h" #include "module_aiot.h" #define MOD_STR "AIOT_ACTINFO" int32_t amp_app_devinfo_report(void *mqtt_handle) { int32_t res = STATE_SUCCESS; void *devinfo_handle = NULL; aiot_devinfo_msg_t *devinfo = NULL; char *msg = NULL; int32_t msg_len = 0; char product_key[IOTX_PRODUCT_KEY_LEN] = {0}; char device_name[IOTX_DEVICE_NAME_LEN] = {0}; int productkey_len = IOTX_PRODUCT_KEY_LEN; int devicename_len = IOTX_DEVICE_NAME_LEN; devinfo_handle = aiot_devinfo_init(); if (devinfo_handle == NULL) { amp_debug(MOD_STR, "ntp service init failed"); return -1; } res = aiot_devinfo_setopt(devinfo_handle, AIOT_DEVINFOOPT_MQTT_HANDLE, (void *)mqtt_handle); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "devinfo set mqtt handle failed"); aiot_devinfo_deinit(&devinfo_handle); return -1; } aos_kv_get(AMP_CUSTOMER_PRODUCTKEY, product_key, &productkey_len); aos_kv_get(AMP_CUSTOMER_DEVICENAME, device_name, &devicename_len); msg_len = strlen(DEVICE_INFO_UPDATE_FMT) + 32; msg = (char *)aos_malloc(msg_len); if (msg == NULL) { amp_debug(MOD_STR, "malloc msg err"); return -1; } memset(msg, 0, msg_len); /* devinfo update message */ res = snprintf(msg, msg_len, DEVICE_INFO_UPDATE_FMT, APPLICATION, MODULE_NAME ); if (res <= 0) { amp_debug(MOD_STR, "topic msg generate err"); aos_free(msg); return -1; } devinfo = aos_malloc(sizeof(aiot_devinfo_msg_t)); if (devinfo == NULL) { amp_debug(MOD_STR, "device update info malloc failed"); aos_free(msg); return -1; } memset(devinfo, 0, sizeof(aiot_devinfo_msg_t)); devinfo->product_key = aos_malloc(IOTX_PRODUCT_KEY_LEN); if (devinfo->product_key == NULL) { amp_debug(MOD_STR, "device update info malloc failed"); aos_free(msg); aos_free(devinfo); return -1; } memset(devinfo->product_key, 0, IOTX_PRODUCT_KEY_LEN); devinfo->device_name = aos_malloc(IOTX_DEVICE_NAME_LEN); if (devinfo->device_name == NULL) { amp_debug(MOD_STR, "device update info malloc failed"); aos_free(msg); aos_free(devinfo); return -1; } memset(devinfo->device_name, 0, IOTX_DEVICE_NAME_LEN); devinfo->data.update.params = aos_malloc(msg_len); if (devinfo == NULL) { amp_debug(MOD_STR, "device update info malloc failed"); aos_free(msg); aos_free(devinfo); return -1; } memset(devinfo->data.update.params, 0, msg_len); devinfo->type = AIOT_DEVINFO_MSG_UPDATE; memcpy(devinfo->product_key, product_key, strlen(product_key)); memcpy(devinfo->device_name, device_name, strlen(device_name)); memcpy(devinfo->data.update.params, msg, msg_len); res = aiot_devinfo_send(devinfo_handle, devinfo); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "das stepping failed"); aos_free(msg); aos_free(devinfo->product_key); aos_free(devinfo->device_name); aos_free(devinfo->data.update.params); aos_free(devinfo); aiot_devinfo_deinit(&devinfo_handle); return -1; } aos_free(msg); aos_free(devinfo->product_key); aos_free(devinfo->device_name); aos_free(devinfo->data.update.params); aos_free(devinfo); return res; }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/aiot/module_aiot_activeinfo.c
C
apache-2.0
3,806
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "aos/kv.h" #include "aiot_sysdep_api.h" #include "aiot_mqtt_api.h" #include "aiot_dm_api.h" #include "aiot_state_api.h" #include "be_inl.h" #include "ota_agent.h" #include "module_aiot.h" #define MOD_STR "AIOT" #define OTA_MODE_NAME "system" static char g_iot_close_flag = 0; static char g_iot_conn_flag = 0; static char g_iot_clean_flag = 0; static aos_sem_t g_iot_close_sem = NULL; ota_service_t g_aiot_device_appota_service; static ota_store_module_info_t module_info[3]; extern const char *amp_jsapp_version_get(void); typedef struct { iot_device_handle_t *iot_device_handle; char *topic; char *payload; char *service_id; char *params; int js_cb_ref; int ret_code; int topic_len; int payload_len; int params_len; int dm_recv; uint64_t msg_id; aiot_mqtt_option_t option; aiot_mqtt_event_type_t event_type; aiot_mqtt_recv_type_t recv_type; aiot_dm_recv_type_t dm_recv_type; aiot_dev_jscallback_type_t cb_type; } device_notify_param_t; static char *__amp_strdup(char *src) { char *dst; size_t len = 0; if (src == NULL) { return NULL; } len = strlen(src); dst = aos_malloc(len+1); if (dst == NULL) { return NULL; } memcpy(dst, src, len); dst[len] = '\0'; return dst; } static int user_jsapp_ota_triger_cb(void* pctx, char *ver, char *module_name) { int ret = OTA_TRANSPORT_PAR_FAIL; ota_service_t *ota_svc = (ota_service_t *)pctx; if ((ota_svc == NULL) || (ver == NULL) || (module_name == NULL)) { return ret; } if (strncmp(module_name, "default", strlen(module_name)) == 0) { char *current_ver = NULL; current_ver = amp_jsapp_version_get(); if (current_ver == NULL) { return ret; } ret = 0; if (strncmp(ver, current_ver, strlen(ver)) <= 0) { ret = OTA_TRANSPORT_VER_FAIL; amp_error(MOD_STR, "user ota version too old!"); } else { if (ota_svc->feedback_func.on_user_event_cb != NULL) { ota_svc->feedback_func.on_user_event_cb(OTA_EVENT_UPGRADE_TRIGGER, 0, ota_svc->feedback_func.param); } else { ret = OTA_TRANSPORT_PAR_FAIL; amp_error(MOD_STR, "user ota trigger cb is NULL!"); } } } else { int ret = OTA_TRANSPORT_PAR_FAIL; char current_amp_ver[64]; memset(current_amp_ver, 0x00, sizeof(current_amp_ver)); amp_app_version_get(current_amp_ver); ret = 0; if (strncmp(ver, current_amp_ver, strlen(ver)) <= 0) { ret = OTA_TRANSPORT_VER_FAIL; amp_error(MOD_STR, "system ota version too old!"); } else { if (ota_svc->feedback_func.on_user_event_cb != NULL) { ota_svc->feedback_func.on_user_event_cb(OTA_EVENT_UPGRADE_TRIGGER, 0, ota_svc->feedback_func.param); } else { ret = OTA_TRANSPORT_PAR_FAIL; amp_error(MOD_STR, "user ota trigger cb is NULL!"); } } } return ret; } static void aiot_device_notify(void *pdata) { device_notify_param_t *param = (device_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, param->js_cb_ref); if (param->dm_recv) { switch (param->dm_recv_type) { case AIOT_DMRECV_PROPERTY_SET: duk_push_object(ctx); duk_push_int(ctx, (unsigned long)param->msg_id); duk_put_prop_string(ctx, -2, "msg_id"); duk_push_int(ctx, param->params_len); duk_put_prop_string(ctx, -2, "params_len"); duk_push_lstring(ctx, param->params, param->params_len); duk_put_prop_string(ctx, -2, "params"); aos_free(param->params); break; case AIOT_DMRECV_ASYNC_SERVICE_INVOKE: duk_push_object(ctx); duk_push_int(ctx, (unsigned long)param->msg_id); duk_put_prop_string(ctx, -2, "msg_id"); duk_push_string(ctx, param->service_id); duk_put_prop_string(ctx, -2, "service_id"); duk_push_int(ctx, param->params_len); duk_put_prop_string(ctx, -2, "params_len"); duk_push_lstring(ctx, param->params, param->params_len); duk_put_prop_string(ctx, -2, "params"); aos_free(param->service_id); aos_free(param->params); break; default: aos_free(param); return; } } else if (param->option == AIOT_MQTTOPT_EVENT_HANDLER) { switch (param->event_type) { case AIOT_MQTTEVT_CONNECT: case AIOT_MQTTEVT_RECONNECT: case AIOT_MQTTEVT_DISCONNECT: duk_push_object(ctx); duk_push_int(ctx, param->ret_code); duk_put_prop_string(ctx, -2, "code"); duk_push_pointer(ctx, param->iot_device_handle); duk_put_prop_string(ctx, -2, "handle"); amp_error(MOD_STR, "%s: handle 0x%x", __func__, (unsigned int)param->iot_device_handle); amp_error(MOD_STR, "%s: mqtthandle 0x%x", __func__, (unsigned int)param->iot_device_handle->mqtt_handle); break; default: aos_free(param); return; } } else { switch (param->recv_type) { case AIOT_MQTTRECV_PUB: duk_push_object(ctx); duk_push_int(ctx, param->ret_code); duk_put_prop_string(ctx, -2, "code"); duk_push_pointer(ctx, param->iot_device_handle); duk_put_prop_string(ctx, -2, "handle"); duk_push_lstring(ctx, param->topic, param->topic_len); duk_put_prop_string(ctx, -2, "topic"); duk_push_lstring(ctx, param->payload, param->payload_len); duk_put_prop_string(ctx, -2, "payload"); aos_free(param->topic); aos_free(param->payload); break; default: aos_free(param); return; } } if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); aos_free(param); } /* 用户数据接收处理回调函数 */ static void aiot_app_dm_recv_handler(void *dm_handle, const aiot_dm_recv_t *recv, void *userdata) { iot_device_handle_t *iot_device_handle = (iot_device_handle_t *)userdata; duk_context *ctx = be_get_context(); device_notify_param_t *param; param = aos_malloc(sizeof(device_notify_param_t)); if (!param) { amp_error(MOD_STR, "alloc device_notify_param_t fail"); return; } memset(param, 0, sizeof(device_notify_param_t)); param->dm_recv = 1; param->dm_recv_type = recv->type; param->iot_device_handle = iot_device_handle; switch (recv->type) { /* 属性上报, 事件上报, 获取期望属性值或者删除期望属性值的应答 */ case AIOT_DMRECV_GENERIC_REPLY: { // printf("msg_id = %d, code = %d, data = %.*s, message = %.*s\r\n", // recv->data.generic_reply.msg_id, // recv->data.generic_reply.code, // recv->data.generic_reply.data_len, // recv->data.generic_reply.data, // recv->data.generic_reply.message_len, // recv->data.generic_reply.message); amp_free(param); return; } /* 属性设置 */ case AIOT_DMRECV_PROPERTY_SET: { amp_debug(MOD_STR, "msg_id = %ld, params = %.*s", (unsigned long)recv->data.property_set.msg_id, recv->data.property_set.params_len, recv->data.property_set.params); param->js_cb_ref = iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_ONPROPS_REF]; param->msg_id = recv->data.property_set.msg_id; param->params_len = recv->data.property_set.params_len; param->params = __amp_strdup(recv->data.property_set.params); param->cb_type = AIOT_DEV_JSCALLBACK_ONPROPS_REF; /* TODO: 以下代码演示如何对来自云平台的属性设置指令进行应答, 用户可取消注释查看演示效果 */ /* { aiot_dm_msg_t msg; memset(&msg, 0, sizeof(aiot_dm_msg_t)); msg.type = AIOT_DMMSG_PROPERTY_SET_REPLY; msg.data.property_set_reply.msg_id = recv->data.property_set.msg_id; msg.data.property_set_reply.code = 200; msg.data.property_set_reply.data = "{}"; int32_t res = aiot_dm_send(dm_handle, &msg); if (res < 0) { printf("aiot_dm_send failed\r\n"); } } */ } break; /* 异步服务调用 */ case AIOT_DMRECV_ASYNC_SERVICE_INVOKE: { amp_debug(MOD_STR, "msg_id = %ld, service_id = %s, params = %.*s", (unsigned long)recv->data.async_service_invoke.msg_id, recv->data.async_service_invoke.service_id, recv->data.async_service_invoke.params_len, recv->data.async_service_invoke.params); param->js_cb_ref = iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_ONSERVICE_REF]; param->msg_id = recv->data.async_service_invoke.msg_id; param->params_len = recv->data.async_service_invoke.params_len; param->service_id = __amp_strdup(recv->data.async_service_invoke.service_id); param->params = __amp_strdup(recv->data.async_service_invoke.params); param->cb_type = AIOT_DEV_JSCALLBACK_ONSERVICE_REF; /* TODO: 以下代码演示如何对来自云平台的异步服务调用进行应答, 用户可取消注释查看演示效果 * * 注意: 如果用户在回调函数外进行应答, 需要自行保存msg_id, 因为回调函数入参在退出回调函数后将被SDK销毁, 不可以再访问到 */ /* { aiot_dm_msg_t msg; memset(&msg, 0, sizeof(aiot_dm_msg_t)); msg.type = AIOT_DMMSG_ASYNC_SERVICE_REPLY; msg.data.async_service_reply.msg_id = recv->data.async_service_invoke.msg_id; msg.data.async_service_reply.code = 200; msg.data.async_service_reply.service_id = "ToggleLightSwitch"; msg.data.async_service_reply.data = "{\"dataA\": 20}"; int32_t res = aiot_dm_send(dm_handle, &msg); if (res < 0) { printf("aiot_dm_send failed\r\n"); } } */ } break; /* 同步服务调用 */ case AIOT_DMRECV_SYNC_SERVICE_INVOKE: { amp_debug(MOD_STR, "msg_id = %ld, rrpc_id = %s, service_id = %s, params = %.*s", (unsigned long)recv->data.sync_service_invoke.msg_id, recv->data.sync_service_invoke.rrpc_id, recv->data.sync_service_invoke.service_id, recv->data.sync_service_invoke.params_len, recv->data.sync_service_invoke.params); /* TODO: 以下代码演示如何对来自云平台的同步服务调用进行应答, 用户可取消注释查看演示效果 * * 注意: 如果用户在回调函数外进行应答, 需要自行保存msg_id和rrpc_id字符串, 因为回调函数入参在退出回调函数后将被SDK销毁, 不可以再访问到 */ /* { aiot_dm_msg_t msg; memset(&msg, 0, sizeof(aiot_dm_msg_t)); msg.type = AIOT_DMMSG_SYNC_SERVICE_REPLY; msg.data.sync_service_reply.rrpc_id = recv->data.sync_service_invoke.rrpc_id; msg.data.sync_service_reply.msg_id = recv->data.sync_service_invoke.msg_id; msg.data.sync_service_reply.code = 200; msg.data.sync_service_reply.service_id = "SetLightSwitchTimer"; msg.data.sync_service_reply.data = "{}"; int32_t res = aiot_dm_send(dm_handle, &msg); if (res < 0) { printf("aiot_dm_send failed\r\n"); } } */ amp_free(param); return; } /* 下行二进制数据 */ case AIOT_DMRECV_RAW_DATA: { amp_debug(MOD_STR, "raw data len = %d", recv->data.raw_data.data_len); /* TODO: 以下代码演示如何发送二进制格式数据, 若使用需要有相应的数据透传脚本部署在云端 */ /* { aiot_dm_msg_t msg; uint8_t raw_data[] = {0x01, 0x02}; memset(&msg, 0, sizeof(aiot_dm_msg_t)); msg.type = AIOT_DMMSG_RAW_DATA; msg.data.raw_data.data = raw_data; msg.data.raw_data.data_len = sizeof(raw_data); aiot_dm_send(dm_handle, &msg); } */ amp_free(param); return; } /* 二进制格式的同步服务调用, 比单纯的二进制数据消息多了个rrpc_id */ case AIOT_DMRECV_RAW_SYNC_SERVICE_INVOKE: { amp_debug(MOD_STR, "raw sync service rrpc_id = %s, data_len = %d", recv->data.raw_service_invoke.rrpc_id, recv->data.raw_service_invoke.data_len); amp_free(param); return; } default: amp_free(param); return; } amp_task_schedule_call(aiot_device_notify, param); } static void aiot_mqtt_message_cb(iot_mqtt_message_t *message, void *userdata) { iot_mqtt_userdata_t *udata = (iot_mqtt_userdata_t *)userdata; iot_device_handle_t *iot_device_handle; device_notify_param_t *param; if (!message || !udata) return; param = aos_malloc(sizeof(device_notify_param_t)); if (!param) { amp_error(MOD_STR, "alloc device notify param fail"); return; } memset(param, 0, sizeof(device_notify_param_t)); param->iot_device_handle = (iot_device_handle_t *)udata->handle; param->option = message->option; param->js_cb_ref = param->iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_CREATE_DEV_REF]; param->cb_type = AIOT_DEV_JSCALLBACK_CREATE_DEV_REF; if (message->option == AIOT_MQTTOPT_EVENT_HANDLER) { switch (message->event.type) { case AIOT_MQTTEVT_CONNECT: case AIOT_MQTTEVT_RECONNECT: case AIOT_MQTTEVT_DISCONNECT: param->ret_code = message->event.code; param->event_type = message->event.type; break; default: aos_free(param); return; } } else if (message->option == AIOT_MQTTOPT_RECV_HANDLER) { switch (message->recv.type) { case AIOT_MQTTRECV_PUB: param->ret_code = message->recv.code; param->topic_len = message->recv.topic_len; param->payload_len = message->recv.payload_len; param->topic = __amp_strdup(message->recv.topic); param->payload = __amp_strdup(message->recv.payload); param->recv_type = message->recv.type; break; default: aos_free(param); return; } } else { aos_free(param); return; } amp_task_schedule_call(aiot_device_notify, param); } static void aiot_device_connect(void *pdata) { int res = -1; //char current_amp_ver[64]; //ota_service_t *ota_svc = &g_aiot_device_appota_service; iot_device_handle_t *iot_device_handle = (iot_device_handle_t *)pdata; iot_mqtt_userdata_t *userdata; uint16_t keepaliveSec = 0; keepaliveSec = iot_device_handle->keepaliveSec; userdata = aos_malloc(sizeof(iot_mqtt_userdata_t)); if (!userdata) { amp_error(MOD_STR, "alloc mqtt userdata fail"); return; } userdata->callback = aiot_mqtt_message_cb; userdata->handle = iot_device_handle; res = aiot_mqtt_client_start(&iot_device_handle->mqtt_handle, keepaliveSec, userdata); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "mqtt client create failed"); aos_free(userdata); aos_free(iot_device_handle); return; } g_iot_conn_flag = 1; iot_device_handle->res = res; /* device model service */ iot_device_handle->dm_handle = aiot_dm_init(); if (iot_device_handle->dm_handle == NULL) { amp_debug(MOD_STR, "aiot_dm_init failed"); aos_free(userdata); aos_free(iot_device_handle); return; } /* 配置MQTT实例句柄 */ aiot_dm_setopt(iot_device_handle->dm_handle, AIOT_DMOPT_MQTT_HANDLE, iot_device_handle->mqtt_handle); /* 配置消息接收处理回调函数 */ aiot_dm_setopt(iot_device_handle->dm_handle, AIOT_DMOPT_RECV_HANDLER, (void *)aiot_app_dm_recv_handler); /* 配置回调函数参数 */ aiot_dm_setopt(iot_device_handle->dm_handle, AIOT_DMOPT_USERDATA, iot_device_handle); /* app device active info report */ res = amp_app_devinfo_report(iot_device_handle->mqtt_handle); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "device active info report failed"); } while (!g_iot_close_flag){ aos_msleep(1000); } duk_context *ctx = be_get_context(); aiot_mqtt_client_stop(&iot_device_handle->mqtt_handle); aos_free(userdata); aos_free(iot_device_handle); g_iot_conn_flag = 0; aos_sem_signal(&g_iot_close_sem); aos_task_exit(0); return; } /************************************************************************************* * Function: native_aiot_create_device * Description: js native addon for UDP.createSocket(); * Called by: js api * Input: none * Output: return socket fd when create socket success, * return error number when create socket fail **************************************************************************************/ static duk_ret_t native_aiot_create_device(duk_context *ctx) { int res = -1; void *mqtt_handle = NULL; const char *productKey; const char *productSecret; const char *deviceName; const char *deviceSecret; int keepaliveSec = 0; int js_cb_ref = 0; aos_task_t iot_device_task; iot_device_handle_t *iot_device_handle = NULL; ota_service_t *ota_svc = &g_aiot_device_appota_service; /* check paramters */ if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be object and function"); goto out; } if (g_iot_clean_flag) { amp_warn(MOD_STR, "module source clean, ignore"); goto out; } /* get device certificate */ duk_get_prop_string(ctx, 0, "productKey"); duk_get_prop_string(ctx, 0, "deviceName"); duk_get_prop_string(ctx, 0, "deviceSecret"); duk_get_prop_string(ctx, 0, "keepaliveSec"); if (!duk_is_string(ctx, -4) || !duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "Parameter invalid"); res = -2; duk_pop_n(ctx, 4); goto out; } productKey = duk_get_string(ctx, -4); deviceName = duk_get_string(ctx, -3); deviceSecret = duk_get_string(ctx, -2); keepaliveSec = duk_get_number(ctx, -1); memset(ota_svc->pk, 0, sizeof(ota_svc->pk)); memset(ota_svc->dn, 0, sizeof(ota_svc->dn)); memset(ota_svc->ds, 0, sizeof(ota_svc->ds)); memcpy(ota_svc->pk, productKey, strlen(productKey)); memcpy(ota_svc->dn, deviceName, strlen(deviceName)); memcpy(ota_svc->ds, deviceSecret, strlen(deviceSecret)); aos_kv_set(AMP_CUSTOMER_PRODUCTKEY, productKey, IOTX_PRODUCT_KEY_LEN, 1); aos_kv_set(AMP_CUSTOMER_DEVICENAME, deviceName, IOTX_DEVICE_NAME_LEN, 1); aos_kv_set(AMP_CUSTOMER_DEVICESECRET, deviceSecret, IOTX_DEVICE_SECRET_LEN, 1); duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); iot_device_handle =(iot_device_handle_t *)aos_malloc(sizeof(iot_device_handle_t)); if (!iot_device_handle) { amp_error(MOD_STR, "allocate memory failed\n"); goto out; } iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_CREATE_DEV_REF] = js_cb_ref; iot_device_handle->keepaliveSec = keepaliveSec; res = aos_task_new_ext(&iot_device_task, "amp aiot device task", aiot_device_connect, iot_device_handle, 1024 * 10, AOS_DEFAULT_APP_PRI); if (res != STATE_SUCCESS) { amp_warn(MOD_STR, "iot create task failed"); aos_free(iot_device_handle); goto out; } out: duk_push_int(ctx, res); return 1; } /* dynmic register */ static duk_ret_t native_aiot_dynreg(duk_context *ctx) { int res = -1; int js_cb_ref = 0; if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (object, function)"); goto out; } duk_get_prop_string(ctx, 0, "productKey"); duk_get_prop_string(ctx, 0, "deviceName"); duk_get_prop_string(ctx, 0, "productSecret"); char *productKey = (char *)duk_get_string(ctx, -3); char *deviceName = (char *)duk_get_string(ctx, -2); char *productSecret = (char *)duk_get_string(ctx, -1); aos_kv_set(AMP_CUSTOMER_PRODUCTKEY, productKey, IOTX_PRODUCT_KEY_LEN, 1); aos_kv_set(AMP_CUSTOMER_DEVICENAME, deviceName, IOTX_DEVICE_NAME_LEN, 1); aos_kv_set(AMP_CUSTOMER_PRODUCTSECRET, productSecret, IOTX_PRODUCT_SECRET_LEN, 1); duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); res = aiot_dynreg_http(js_cb_ref); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "device dynmic register failed"); } out: duk_push_int(ctx, res); return 1; } /* post event */ static duk_ret_t native_aiot_postEvent(duk_context *ctx) { int res = -1; iot_device_handle_t *iot_device_handle = NULL; char *event_id; char *event_payload; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (number, object, function)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); duk_get_prop_string(ctx, 1, "id"); duk_get_prop_string(ctx, 1, "params"); event_id = (char *)duk_get_string(ctx, -2); event_payload = (char *)duk_get_string(ctx, -1); res = aiot_app_send_event_post(iot_device_handle->dm_handle, event_id, event_payload); if (res < STATE_SUCCESS) { amp_warn(MOD_STR, "post event failed!"); } out: duk_push_int(ctx, res); return 1; } /* post props */ static duk_ret_t native_aiot_postProps(duk_context *ctx) { int res = -1; iot_device_handle_t *iot_device_handle = NULL; char *params; if (!duk_is_pointer(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, string, function)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); params = (char *)duk_get_string(ctx, 1); res = aiot_app_send_property_post(iot_device_handle->dm_handle, params); if (res < STATE_SUCCESS) { amp_warn(MOD_STR, "property post failed"); } out: duk_push_int(ctx, res); return 1; } /* onprops */ static duk_ret_t native_aiot_onProps(duk_context *ctx) { int res = STATE_SUCCESS; iot_device_handle_t *iot_device_handle = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer, function)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); duk_dup(ctx, 1); iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_ONPROPS_REF] = be_ref(ctx); out: duk_push_int(ctx, res); return 1; } /* onService */ static duk_ret_t native_aiot_onService(duk_context *ctx) { int res = STATE_SUCCESS; iot_device_handle_t *iot_device_handle = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer, function)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); duk_dup(ctx, 1); iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_ONSERVICE_REF] = be_ref(ctx); out: duk_push_int(ctx, res); return 1; } /* publish */ static duk_ret_t native_aiot_publish(duk_context *ctx) { int res = -1; iot_device_handle_t *iot_device_handle = NULL; char *topic; char *payload; uint16_t payload_len = 0; uint8_t qos = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); if (iot_device_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } duk_get_prop_string(ctx, 1, "topic"); duk_get_prop_string(ctx, 1, "payload"); duk_get_prop_string(ctx, 1, "qos"); if (!duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "invalid params"); duk_pop_n(ctx, 3); goto out; } qos = duk_get_number(ctx, -1); payload = (char *)duk_get_string(ctx, -2); topic = (char *)duk_get_string(ctx, -3); payload_len = strlen(payload); amp_debug(MOD_STR, "publish topic: %s, payload: %s, qos is: %d", topic, payload, qos); res = aiot_mqtt_pub(iot_device_handle->mqtt_handle, topic, payload, payload_len, qos); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "aiot app mqtt publish failed\n"); goto out; } out: duk_push_int(ctx, res); return 1; } /* unsubscribe */ static duk_ret_t native_aiot_unsubscribe(duk_context *ctx) { int res = -1; iot_device_handle_t *iot_device_handle = NULL; char *topic; uint8_t qos = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, string)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); if (iot_device_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } topic = (char *)duk_get_string(ctx, 1); amp_debug(MOD_STR, "unsubscribe topic: %s", topic); res = aiot_mqtt_unsub(iot_device_handle->mqtt_handle, topic); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "aiot app mqtt unsubscribe failed"); goto out; } out: duk_push_int(ctx, res); return 1; } /* subscribe */ static duk_ret_t native_aiot_subscribe(duk_context *ctx) { int res = -1; iot_device_handle_t *iot_device_handle = NULL; char *topic = NULL; uint8_t qos = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); if (iot_device_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } duk_get_prop_string(ctx, 1, "topic"); duk_get_prop_string(ctx, 1, "qos"); if (!duk_is_number(ctx, -1) || !duk_is_string(ctx, -2)) { amp_warn(MOD_STR, "invalid params"); duk_pop_n(ctx, 2); goto out; } qos = duk_get_number(ctx, -1); topic = (char *)duk_get_string(ctx, -2); amp_debug(MOD_STR, "subscribe topic: %s, qos is: %d", topic, qos); res = aiot_mqtt_sub(iot_device_handle->mqtt_handle, topic, NULL, qos, NULL); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "aiot app mqtt subscribe failed\n"); goto out; } out: duk_push_int(ctx, res); return 1; } /************************************************************************************* * Function: native_aiot_close * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ static duk_ret_t native_aiot_close(duk_context *ctx) { int res = -1; iot_device_handle_t *iot_device_handle = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be pointer and function"); goto out; } iot_device_handle = duk_get_pointer(ctx, 0); if (iot_device_handle == NULL) { amp_warn(MOD_STR, "iot_device_hanle is null"); goto out; } duk_dup(ctx, 1); iot_device_handle->js_cb_ref[AIOT_DEV_JSCALLBACK_END_CLIENT_REF] = be_ref(ctx); g_iot_close_flag = 1; aos_sem_wait(&g_iot_close_sem, 200 + 50); res = aiot_mqtt_client_stop(&iot_device_handle->mqtt_handle); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "aiot stop failed"); goto out; } g_iot_close_flag = 0; duk_push_int(ctx, 0); aos_free(iot_device_handle); return 1; out: duk_push_int(ctx, res); return 1; } static void module_iot_source_clean(void) { duk_context *ctx = be_get_context(); if (g_iot_conn_flag) { g_iot_close_flag = 1; aos_sem_wait(&g_iot_close_sem, 5100); g_iot_close_flag = 0; aos_msleep(10); } g_iot_clean_flag = 1; } void module_aiot_device_register(void) { duk_context *ctx = be_get_context(); if (!g_iot_close_sem) { if (aos_sem_new(&g_iot_close_sem, 0) != 0) { amp_error(MOD_STR, "create iot sem fail"); return; } } g_iot_clean_flag = 0; amp_module_free_register(module_iot_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("device", native_aiot_create_device, 2); AMP_ADD_FUNCTION("subscribe", native_aiot_subscribe, 3); AMP_ADD_FUNCTION("unsubscribe", native_aiot_unsubscribe, 3); AMP_ADD_FUNCTION("publish", native_aiot_publish, 3); AMP_ADD_FUNCTION("postProps", native_aiot_postProps, 3); AMP_ADD_FUNCTION("onProps", native_aiot_onProps, 2); AMP_ADD_FUNCTION("postEvent", native_aiot_postEvent, 3); AMP_ADD_FUNCTION("register", native_aiot_dynreg, 2); AMP_ADD_FUNCTION("onService", native_aiot_onService, 2); AMP_ADD_FUNCTION("end", native_aiot_close, 2); duk_put_prop_string(ctx, -2, "AIOT_DEVICE"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/aiot/module_aiot_device.c
C
apache-2.0
30,902
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "aiot_state_api.h" #include "aiot_sysdep_api.h" #include "aiot_dynreg_api.h" #include "aiot_mqtt_api.h" #include "module_aiot.h" #include "be_inl.h" #define MOD_STR "AIOT_DYNREG" /* 位于portfiles/aiot_port文件夹下的系统适配函数集合 */ extern aiot_sysdep_portfile_t g_aiot_sysdep_portfile; /* 位于external/ali_ca_cert.c中的服务器证书 */ extern const char *ali_ca_cert; void aiot_app_dynreg_recv_handler(void *handle, const aiot_dynreg_recv_t *packet, void *userdata) { int js_cb_ref = 0; if (packet->type == AIOT_DYNREGRECV_STATUS_CODE) { amp_debug(MOD_STR, "dynreg rsp code = %d", packet->data.status_code.code); } else if (packet->type == AIOT_DYNREGRECV_DEVICE_INFO) { amp_debug(MOD_STR, "dynreg DS = %s", packet->data.device_info.device_secret); aos_kv_set(AMP_CUSTOMER_DEVICESECRET, packet->data.device_info.device_secret, strlen(packet->data.device_info.device_secret), 1); int js_cb_ref = (int *)userdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, js_cb_ref); duk_push_string(ctx, packet->data.device_info.device_secret); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } be_unref(ctx, js_cb_ref); duk_pop(ctx); duk_gc(ctx, 0); } } int32_t aiot_dynreg_http(int js_cb_ref) { int32_t res = STATE_SUCCESS; char *auth_url = "iot-auth.cn-shanghai.aliyuncs.com"; /* 阿里云平台上海站点的域名后缀 */ char host[100] = {0}; /* 用这个数组拼接设备连接的云平台站点全地址, 规则是 ${productKey}.iot-as-mqtt.cn-shanghai.aliyuncs.com */ uint16_t port = 443; /* 无论设备是否使用TLS连接阿里云平台, 目的端口都是443 */ aiot_sysdep_network_cred_t cred; /* 安全凭据结构体, 如果要用TLS, 这个结构体中配置CA证书等参数 */ /* get device tripple info */ char product_key[IOTX_PRODUCT_KEY_LEN] = {0}; char product_secret[IOTX_PRODUCT_SECRET_LEN] = {0}; char device_name[IOTX_DEVICE_NAME_LEN] = {0}; char device_secret[IOTX_DEVICE_SECRET_LEN] = {0}; int productkey_len = IOTX_PRODUCT_KEY_LEN; int productsecret_len = IOTX_PRODUCT_SECRET_LEN; int devicename_len = IOTX_DEVICE_NAME_LEN; int devicesecret_len = IOTX_DEVICE_SECRET_LEN; aos_kv_get(AMP_CUSTOMER_PRODUCTKEY, product_key, &productkey_len); aos_kv_get(AMP_CUSTOMER_PRODUCTSECRET, product_secret, &productsecret_len); aos_kv_get(AMP_CUSTOMER_DEVICENAME, device_name, &devicename_len); amp_debug(MOD_STR, "dev info pk: %s, ps: %s, dn: %s", product_key, product_secret, device_name); /* end get device tripple info */ /* 配置SDK的底层依赖 */ aiot_sysdep_set_portfile(&g_aiot_sysdep_portfile); /* 配置SDK的日志输出 */ // aiot_state_set_logcb(demo_state_logcb); /* 创建SDK的安全凭据, 用于建立TLS连接 */ memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t)); cred.option = AIOT_SYSDEP_NETWORK_CRED_SVRCERT_CA; /* 使用RSA证书校验MQTT服务端 */ cred.max_tls_fragment = 16384; /* 最大的分片长度为16K, 其它可选值还有4K, 2K, 1K, 0.5K */ cred.sni_enabled = 1; /* TLS建连时, 支持Server Name Indicator */ cred.x509_server_cert = ali_ca_cert; /* 用来验证MQTT服务端的RSA根证书 */ cred.x509_server_cert_len = strlen(ali_ca_cert); /* 用来验证MQTT服务端的RSA根证书长度 */ aos_kv_get(AMP_CUSTOMER_DEVICESECRET, device_secret, &devicesecret_len); if (device_secret[0] == '\0' || device_secret[IOTX_DEVICE_SECRET_LEN] != '\0') { if (product_secret[0] == '\0' || product_secret[IOTX_PRODUCT_SECRET_LEN] != '\0') { amp_error(MOD_STR, "need dynamic register, product secret is null"); return -1; } void *dynreg_handle = NULL; dynreg_handle = aiot_dynreg_init(); if (dynreg_handle == NULL) { amp_error(MOD_STR, "dynreg handle is null"); aos_task_exit(0); return NULL; } /* 配置网络连接的安全凭据, 上面已经创建好了 */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_NETWORK_CRED, (void *)&cred); /* 配置MQTT服务器地址 */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_HOST, (void *)auth_url); /* 配置MQTT服务器端口 */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_PORT, (void *)&port); /* 配置设备productKey */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_PRODUCT_KEY, (void *)product_key); /* 配置设备productSecret */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_PRODUCT_SECRET, (void *)product_secret); /* 配置设备deviceName */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_DEVICE_NAME, (void *)device_name); /* 配置DYNREG默认消息接收回调函数 */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_RECV_HANDLER, (void *)aiot_app_dynreg_recv_handler); /* 配置DYNREG默认消息接收回调函数参数 */ aiot_dynreg_setopt(dynreg_handle, AIOT_DYNREGOPT_USERDATA, js_cb_ref); res = aiot_dynreg_send_request(dynreg_handle); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "dynamic register send fail res = %d\n\r", res); aiot_dynreg_deinit(&dynreg_handle); return -1; } res = aiot_dynreg_recv(dynreg_handle); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "dynamic register recv fail res = %d\n\r", res); aiot_dynreg_deinit(&dynreg_handle); return -1; } aos_kv_get(AMP_CUSTOMER_DEVICESECRET, device_secret, &devicesecret_len); res = aiot_dynreg_deinit(&dynreg_handle); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "dynamic register deinit fail res = %d\n\r", res); return -1; } } else { amp_debug(MOD_STR, "device is already activated"); return -1; } return STATE_SUCCESS; }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/aiot/module_aiot_dynreg.c
C
apache-2.0
6,479
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "aos/kv.h" #include "aiot_sysdep_api.h" #include "aiot_mqtt_api.h" #include "aiot_dm_api.h" #include "aiot_subdev_api.h" #include "aiot_state_api.h" #include "be_inl.h" #include "ota_agent.h" #include "module_aiot.h" #define MOD_STR "AIOT" #define OTA_MODE_NAME "system" typedef struct { iot_gateway_handle_t *handle; char *message; char *topic; char *payload; int js_cb_ref; int ret_code; int topic_len; int payload_len; aiot_mqtt_option_t option; aiot_subdev_jscallback_type_t cb_type; } subdev_notify_param_t; static char g_iot_close_flag = 0; static char g_iot_conn_flag = 0; static char g_iot_clean_flag = 0; static aos_sem_t g_iot_close_sem = NULL; static ota_store_module_info_t g_module_info[3]; ota_service_t g_appota_service; static int g_on_message_cb_ref = 0; extern const char *amp_jsapp_version_get(void); static char *__amp_strdup(char *src) { char *dst; size_t len = 0; if (src == NULL) { return NULL; } len = strlen(src); dst = aos_malloc(len+1); if (dst == NULL) { return NULL; } memcpy(dst, src, len); dst[len] = '\0'; return dst; } static int user_jsapp_ota_triger_cb(void* pctx, char *ver, char *module_name) { int ret = OTA_TRANSPORT_PAR_FAIL; ota_service_t *ota_svc = (ota_service_t *)pctx; if ((pctx == NULL) || (ver == NULL) || (module_name == NULL)) { return ret; } if (strncmp(module_name, "default", strlen(module_name)) == 0) { char *current_ver = NULL; current_ver = amp_jsapp_version_get(); if (current_ver == NULL) { return ret; } ret = 0; if (strncmp(ver, current_ver, strlen(ver)) <= 0) { ret = OTA_TRANSPORT_VER_FAIL; amp_error(MOD_STR, "user ota version too old!"); } else { if (ota_svc->feedback_func.on_user_event_cb != NULL) { ota_svc->feedback_func.on_user_event_cb(OTA_EVENT_UPGRADE_TRIGGER, 0, ota_svc->feedback_func.param); } else { ret = OTA_TRANSPORT_PAR_FAIL; amp_error(MOD_STR, "user ota trigger cb is NULL!"); } } } else { char current_amp_ver[64]; memset(current_amp_ver, 0x00, sizeof(current_amp_ver)); amp_app_version_get(current_amp_ver); ret = 0; if (strncmp(ver, current_amp_ver, strlen(ver)) <= 0) { ret = OTA_TRANSPORT_VER_FAIL; amp_error(MOD_STR, "system ota version too old!"); } else { if (ota_svc->feedback_func.on_user_event_cb != NULL) { ota_svc->feedback_func.on_user_event_cb(OTA_EVENT_UPGRADE_TRIGGER, 0, ota_svc->feedback_func.param); } else { ret = OTA_TRANSPORT_PAR_FAIL; amp_error(MOD_STR, "user ota trigger cb is NULL!"); } } } return ret; } static void aiot_subdev_notify(void *pdata) { subdev_notify_param_t *param = (subdev_notify_param_t *)pdata; iot_gateway_handle_t *handle = param->handle; duk_context *ctx = be_get_context(); be_push_ref(ctx, param->js_cb_ref); switch (param->cb_type) { case AIOT_SUBDEV_JSCALLBACK_CREATE_GATEWAY_REF: duk_push_object(ctx); duk_push_int(ctx, param->ret_code); duk_put_prop_string(ctx, -2, "code"); duk_push_pointer(ctx, param->handle); duk_put_prop_string(ctx, -2, "handle"); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } break; case AIOT_SUBDEV_JSCALLBACK_LOGIN_REF: case AIOT_SUBDEV_JSCALLBACK_LOGOUT_REF: duk_push_int(ctx, param->ret_code); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } break; case AIOT_SUBDEV_JSCALLBACK_ADD_TOPO_REF: case AIOT_SUBDEV_JSCALLBACK_GET_TOPO_REF: case AIOT_SUBDEV_JSCALLBACK_REGISTER_SUBDEV_REF: duk_push_int(ctx, param->ret_code); duk_push_lstring(ctx, param->message, strlen(param->message)); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } aos_free(param->message); break; case AIOT_SUBDEV_JSCALLBACK_ON_MQTT_MESSAGE_REF: duk_push_object(ctx); duk_push_int(ctx, param->ret_code); duk_put_prop_string(ctx, -2, "code"); if (param->option == AIOT_MQTTOPT_RECV_HANDLER) { duk_push_lstring(ctx, param->topic, param->topic_len); duk_put_prop_string(ctx, -2, "topic"); duk_push_lstring(ctx, param->payload, param->payload_len); duk_put_prop_string(ctx, -2, "payload"); } if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } aos_free(param->topic); aos_free(param->payload); break; default: be_unref(ctx, param->js_cb_ref); aos_free(param); return; } duk_pop(ctx); if (param->cb_type != AIOT_SUBDEV_JSCALLBACK_ON_MQTT_MESSAGE_REF) { be_unref(ctx, param->js_cb_ref); } duk_gc(ctx, 0); aos_free(param); } static void aiot_subdev_packet_dump(const aiot_subdev_recv_t *packet) { printf("%s: packet->type %d\r\n", __func__, packet->type); switch (packet->type) { case AIOT_SUBDEVRECV_TOPO_ADD_REPLY: case AIOT_SUBDEVRECV_TOPO_DELETE_REPLY: case AIOT_SUBDEVRECV_TOPO_GET_REPLY: case AIOT_SUBDEVRECV_BATCH_LOGIN_REPLY: case AIOT_SUBDEVRECV_BATCH_LOGOUT_REPLY: case AIOT_SUBDEVRECV_SUB_REGISTER_REPLY: case AIOT_SUBDEVRECV_PRODUCT_REGISTER_REPLY: { printf("msgid : %d\r\n", packet->data.generic_reply.msg_id); printf("code : %d\r\n", packet->data.generic_reply.code); printf("product key : %s\r\n", packet->data.generic_reply.product_key); printf("device name : %s\r\n", packet->data.generic_reply.device_name); printf("message : %s\r\n", (packet->data.generic_reply.message == NULL)?("NULL"):(packet->data.generic_reply.message)); printf("data : %s\r\n", packet->data.generic_reply.data); } break; case AIOT_SUBDEVRECV_TOPO_CHANGE_NOTIFY: { printf("msgid : %d\r\n", packet->data.generic_notify.msg_id); printf("product key : %s\r\n", packet->data.generic_notify.product_key); printf("device name : %s\r\n", packet->data.generic_notify.device_name); printf("params : %s\r\n", packet->data.generic_notify.params); } break; default: { } } printf("%s exit\r\n", __func__); } static void aiot_subdev_recv_handler(void *handle, const aiot_subdev_recv_t *packet, void *user_data) { iot_gateway_handle_t *iot_gateway_handle = (iot_gateway_handle_t *)user_data; subdev_notify_param_t *param; param = aos_malloc(sizeof(subdev_notify_param_t)); if (!param) { amp_error(MOD_STR, "alloc gateway notify param fail"); return; } param->handle = iot_gateway_handle; aiot_subdev_packet_dump(packet); switch (packet->type) { case AIOT_SUBDEVRECV_TOPO_ADD_REPLY: param->cb_type = AIOT_SUBDEV_JSCALLBACK_ADD_TOPO_REF; param->ret_code = packet->data.generic_reply.code == 200 ? 0 : packet->data.generic_reply.code; param->message = __amp_strdup(packet->data.generic_reply.data); param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_ADD_TOPO_REF]; break; case AIOT_SUBDEVRECV_TOPO_DELETE_REPLY: param->cb_type = AIOT_SUBDEV_JSCALLBACK_REMOVE_TOPO_REF; param->ret_code = packet->data.generic_reply.code == 200 ? 0 : packet->data.generic_reply.code; param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_REMOVE_TOPO_REF]; break; case AIOT_SUBDEVRECV_TOPO_GET_REPLY: param->cb_type = AIOT_SUBDEV_JSCALLBACK_GET_TOPO_REF; param->ret_code = packet->data.generic_reply.code == 200 ? 0 : packet->data.generic_reply.code; param->message = __amp_strdup(packet->data.generic_reply.data); param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_GET_TOPO_REF]; break; case AIOT_SUBDEVRECV_BATCH_LOGIN_REPLY: param->cb_type = AIOT_SUBDEV_JSCALLBACK_LOGIN_REF; param->ret_code = packet->data.generic_reply.code == 200 ? 0 : packet->data.generic_reply.code; param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_LOGIN_REF]; break; case AIOT_SUBDEVRECV_BATCH_LOGOUT_REPLY: param->cb_type = AIOT_SUBDEV_JSCALLBACK_LOGOUT_REF; param->ret_code = packet->data.generic_reply.code == 200 ? 0 : packet->data.generic_reply.code; param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_LOGOUT_REF]; break; case AIOT_SUBDEVRECV_SUB_REGISTER_REPLY: param->cb_type = AIOT_SUBDEV_JSCALLBACK_REGISTER_SUBDEV_REF; param->ret_code = packet->data.generic_reply.code == 200 ? 0 : packet->data.generic_reply.code; param->message = __amp_strdup(packet->data.generic_reply.data); param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_REGISTER_SUBDEV_REF]; break; case AIOT_SUBDEVRECV_PRODUCT_REGISTER_REPLY: printf("msgid : %d\n", packet->data.generic_reply.msg_id); printf("code : %d\n", packet->data.generic_reply.code); printf("product key : %s\n", packet->data.generic_reply.product_key); printf("device name : %s\n", packet->data.generic_reply.device_name); printf("message : %s\n", (packet->data.generic_reply.message == NULL)?("NULL"):(packet->data.generic_reply.message)); printf("data : %s\n", packet->data.generic_reply.data); aos_free(param); return; case AIOT_SUBDEVRECV_TOPO_CHANGE_NOTIFY: printf("msgid : %d\n", packet->data.generic_notify.msg_id); printf("product key : %s\n", packet->data.generic_notify.product_key); printf("device name : %s\n", packet->data.generic_notify.device_name); printf("params : %s\n", packet->data.generic_notify.params); aos_free(param); return; default: { amp_error(MOD_STR, "%s: unknown type %d", __func__, packet->type); aos_free(param); return; } } amp_task_schedule_call(aiot_subdev_notify, param); } static void aiot_mqtt_message_cb(iot_mqtt_message_t *message, void *userdata) { iot_mqtt_userdata_t *udata = (iot_mqtt_userdata_t *)userdata; subdev_notify_param_t *param; if (!message || !udata) return; param = aos_malloc(sizeof(subdev_notify_param_t)); if (!param) { amp_error(MOD_STR, "alloc gateway notify param fail"); return; } param->handle = (iot_gateway_handle_t *)udata->handle; param->option = message->option; if (message->option == AIOT_MQTTOPT_RECV_HANDLER) { switch (message->recv.type) { case AIOT_MQTTRECV_PUB: if (g_on_message_cb_ref == 0) { aos_free(param); return; } param->cb_type = AIOT_SUBDEV_JSCALLBACK_ON_MQTT_MESSAGE_REF; param->js_cb_ref = g_on_message_cb_ref; param->ret_code = message->recv.code; param->topic_len = message->recv.topic_len; param->payload_len = message->recv.payload_len; param->topic = __amp_strdup(message->recv.topic); param->payload = __amp_strdup(message->recv.payload); break; default: aos_free(param); return; } } else if (message->option == AIOT_MQTTOPT_EVENT_HANDLER) { switch (message->event.type) { case AIOT_MQTTEVT_CONNECT: aos_free(param); return; case AIOT_MQTTEVT_RECONNECT: case AIOT_MQTTEVT_DISCONNECT: if (g_on_message_cb_ref == 0) { aos_free(param); return; } param->cb_type = AIOT_SUBDEV_JSCALLBACK_ON_MQTT_MESSAGE_REF; param->js_cb_ref = g_on_message_cb_ref; param->ret_code = message->event.code; break; default: aos_free(param); return; } } amp_task_schedule_call(aiot_subdev_notify, param); } #define SUBDEV_FILE_PATH AMP_FS_ROOT_DIR"pack.bin" #define OS_APP_PATH AMP_FS_ROOT_DIR"os_app.bin" #define OS_KERNEL_PATH AMP_FS_ROOT_DIR"os_kernel.bin" static void aiot_gateway_connect(void *pdata) { int res = -1; char current_amp_ver[64]; ota_service_t *ota_svc = &g_appota_service; iot_gateway_handle_t *iot_gateway_handle = (iot_gateway_handle_t *)pdata; subdev_notify_param_t *param; iot_mqtt_userdata_t *userdata; uint16_t keepaliveSec = 0; keepaliveSec = iot_gateway_handle->keepaliveSec; param = aos_malloc(sizeof(subdev_notify_param_t)); if (!param) { amp_error(MOD_STR, "alloc gateway notify param fail"); return; } param->cb_type = AIOT_SUBDEV_JSCALLBACK_CREATE_GATEWAY_REF; param->js_cb_ref = iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_CREATE_GATEWAY_REF]; param->handle = iot_gateway_handle; userdata = aos_malloc(sizeof(iot_mqtt_userdata_t)); if (!userdata) { amp_error(MOD_STR, "alloc mqtt userdata fail"); aos_free(param); return; } userdata->callback = aiot_mqtt_message_cb; userdata->handle = iot_gateway_handle; res = aiot_mqtt_client_start(&iot_gateway_handle->mqtt_handle, keepaliveSec, userdata); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "mqtt client create failed"); aos_free(userdata); aos_free(param); aos_free(iot_gateway_handle); return; } g_iot_conn_flag = 1; param->ret_code = res; /* gateway model service */ iot_gateway_handle->subdev_handle = aiot_subdev_init(); if (iot_gateway_handle->subdev_handle == NULL) { amp_debug(MOD_STR, "aiot_subdev_init failed"); aos_free(param); aos_free(iot_gateway_handle); return; } /* set mqtt handle */ aiot_subdev_setopt(iot_gateway_handle->subdev_handle , AIOT_SUBDEVOPT_MQTT_HANDLE, iot_gateway_handle->mqtt_handle); /* set subdev handler */ aiot_subdev_setopt(iot_gateway_handle->subdev_handle , AIOT_SUBDEVOPT_RECV_HANDLER, aiot_subdev_recv_handler); /* 配置回调函数参数 */ aiot_subdev_setopt(iot_gateway_handle->subdev_handle, AIOT_SUBDEVOPT_USERDATA, (void *)iot_gateway_handle); /* return aiot_device_handle */ amp_task_schedule_call(aiot_subdev_notify, param); /* app device active info report */ res = amp_app_devinfo_report(iot_gateway_handle->mqtt_handle); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "device active info report failed"); } /* app ota service */ ota_service_param_reset(ota_svc); memset(g_module_info, 0x00, sizeof(g_module_info)); ota_register_module_store(ota_svc, g_module_info, 3); ota_register_trigger_msg_cb(ota_svc, (void *)user_jsapp_ota_triger_cb, NULL); amp_debug(MOD_STR, "[%s %d]module",__func__,__LINE__); ota_set_module_information(ota_svc, OTA_MODE_NAME, OS_APP_PATH, OTA_UPGRADE_ALL); ota_set_module_information(ota_svc, "default", SUBDEV_FILE_PATH, OTA_UPGRADE_ALL); ota_svc->mqtt_client = iot_gateway_handle->mqtt_handle; res = ota_service_init(ota_svc); if (res >= 0) { amp_debug(MOD_STR, "user ota init ok!"); } else { amp_error(MOD_STR, "user ota init failed!"); } //report app js version res = ota_report_module_version(ota_svc, "default", amp_jsapp_version_get()); if(res < 0) { amp_error(MOD_STR, "user ota report ver failed!"); } memset(current_amp_ver, 0x00, sizeof(current_amp_ver)); amp_app_version_get(current_amp_ver); //report amp app version res = ota_report_module_version(ota_svc, OTA_MODE_NAME, current_amp_ver); if (res < 0) { amp_error(MOD_STR, "system ota report ver failed!"); } while (!g_iot_close_flag) { aos_msleep(1000); } duk_context *ctx = be_get_context(); aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); aos_free(userdata); aos_free(iot_gateway_handle); g_iot_conn_flag = 0; aos_sem_signal(&g_iot_close_sem); aos_task_exit(0); return; } /************************************************************************************* * Function: native_aiot_create_device * Description: js native addon for UDP.createSocket(); * Called by: js api * Input: none * Output: return socket fd when create socket success, * return error number when create socket fail **************************************************************************************/ static duk_ret_t native_aiot_create_gateway(duk_context *ctx) { int res = -1; void *mqtt_handle = NULL; const char *productKey; const char *productSecret; const char *deviceName; const char *deviceSecret; int keepaliveSec = 0; aos_task_t iot_device_task; iot_gateway_handle_t *iot_gateway_handle = NULL; ota_service_t *ota_svc = &g_appota_service; /* check paramters */ if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be object and function"); goto out; } if (g_iot_clean_flag) { amp_warn(MOD_STR, "module source clean, ignore"); goto out; } /* get device certificate */ duk_get_prop_string(ctx, 0, "productKey"); duk_get_prop_string(ctx, 0, "deviceName"); duk_get_prop_string(ctx, 0, "deviceSecret"); duk_get_prop_string(ctx, 0, "keepaliveSec"); if (!duk_is_string(ctx, -4) || !duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "Parameter invalid"); res = -2; duk_pop_n(ctx, 4); goto out; } productKey = duk_get_string(ctx, -4); deviceName = duk_get_string(ctx, -3); deviceSecret = duk_get_string(ctx, -2); keepaliveSec = duk_get_number(ctx, -1); memset(ota_svc->pk, 0, sizeof(ota_svc->pk)); memset(ota_svc->dn, 0, sizeof(ota_svc->dn)); memset(ota_svc->ds, 0, sizeof(ota_svc->ds)); memcpy(ota_svc->pk, productKey, strlen(productKey)); memcpy(ota_svc->dn, deviceName, strlen(deviceName)); memcpy(ota_svc->ds, deviceSecret, strlen(deviceSecret)); aos_kv_set(AMP_CUSTOMER_PRODUCTKEY, productKey, IOTX_PRODUCT_KEY_LEN, 1); aos_kv_set(AMP_CUSTOMER_DEVICENAME, deviceName, IOTX_DEVICE_NAME_LEN, 1); aos_kv_set(AMP_CUSTOMER_DEVICESECRET, deviceSecret, IOTX_DEVICE_SECRET_LEN, 1); duk_dup(ctx, 1); iot_gateway_handle =(iot_gateway_handle_t *)aos_malloc(sizeof(iot_gateway_handle_t)); if (!iot_gateway_handle) { amp_error(MOD_STR, "allocate memory failed\n"); goto out; } iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_CREATE_GATEWAY_REF] = be_ref(ctx); iot_gateway_handle->keepaliveSec = keepaliveSec; res = aos_task_new_ext(&iot_device_task, "amp aiot device task", aiot_gateway_connect, iot_gateway_handle, 1024 * 10, AOS_DEFAULT_APP_PRI); if (res != 0) { amp_warn(MOD_STR, "iot create task failed"); aos_free(iot_gateway_handle); goto out; } out: duk_push_int(ctx, res); return 1; } /* addTopo */ static duk_ret_t native_aiot_addTopo(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; aiot_subdev_dev_t *subdev; int subdev_length = 0; int i; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer), array)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); subdev_length = duk_get_length(ctx, 1); amp_debug(MOD_STR, "sub_dev num is: %d", subdev_length); subdev = aos_malloc(subdev_length * sizeof(aiot_subdev_dev_t)); if (subdev == NULL) { amp_debug(MOD_STR, "sub dev malloc failed"); goto out; } memset(subdev, 0, subdev_length * sizeof(aiot_subdev_dev_t)); for (i = 0; i < subdev_length; i++) { duk_get_prop_index(ctx, 1, i); /* get pk */ duk_get_prop_string(ctx, -1, "productKey"); duk_get_prop_string(ctx, -2, "deviceName"); duk_get_prop_string(ctx, -3, "deviceSecret"); subdev[i].product_key = __amp_strdup(duk_get_string(ctx, -3)); subdev[i].device_name = __amp_strdup(duk_get_string(ctx, -2)); subdev[i].device_secret = __amp_strdup(duk_get_string(ctx, -1)); duk_pop_n(ctx, 3); } duk_dup(ctx, 2); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_ADD_TOPO_REF] = be_ref(ctx); res = aiot_subdev_send_topo_add(iot_gateway_handle->subdev_handle, subdev, subdev_length); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "send subdev topo add failed, res: -0x%04X", -res); // aiot_subdev_deinit(&iot_gateway_handle->subdev_handle); // aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); } out: if (subdev) { for (i = 0; i < subdev_length; i++) { if (subdev[i].product_key) { aos_free(subdev[i].product_key); } if (subdev[i].device_name) { aos_free(subdev[i].device_name); } if (subdev[i].device_secret) { aos_free(subdev[i].device_secret); } } aos_free(subdev); } duk_push_int(ctx, res); return 1; } /* getTopo */ static duk_ret_t native_aiot_getTopo(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; int js_cb_ref = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer, object)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); duk_dup(ctx, 1); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_GET_TOPO_REF] = be_ref(ctx); res = aiot_subdev_send_topo_get(iot_gateway_handle->subdev_handle); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "send subdev topo get failed, res: -0x%04X", -res); // aiot_subdev_deinit(&iot_gateway_handle->subdev_handle); // aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); } out: duk_push_int(ctx, res); return 1; } /* removeTopo */ static duk_ret_t native_aiot_removeTopo(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; aiot_subdev_dev_t *subdev; int subdev_length = 0; int i; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); subdev_length = duk_get_length(ctx, 1); subdev = aos_malloc(subdev_length * sizeof(aiot_subdev_dev_t)); if (subdev == NULL) { amp_debug(MOD_STR, "sub dev malloc failed"); goto out; } for (i = 0; i < subdev_length; i++) { duk_get_prop_index(ctx, 1, i); /* get pk */ duk_get_prop_string(ctx, -1, "productKey"); duk_get_prop_string(ctx, -2, "deviceName"); duk_get_prop_string(ctx, -3, "deviceSecret"); subdev[i].product_key = __amp_strdup(duk_get_string(ctx, -3)); subdev[i].device_name = __amp_strdup(duk_get_string(ctx, -2)); subdev[i].device_secret = __amp_strdup(duk_get_string(ctx, -1)); duk_pop_n(ctx, 3); } duk_dup(ctx, 2); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_REMOVE_TOPO_REF] = be_ref(ctx); res = aiot_subdev_send_topo_delete(iot_gateway_handle->subdev_handle, subdev, subdev_length); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "send subdev topo remove failed, res: -0x%04X", -res); // aiot_subdev_deinit(&iot_gateway_handle->subdev_handle); // aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); } out: if (subdev) { for (i = 0; i < subdev_length; i++) { if (subdev[i].product_key) { aos_free(subdev[i].product_key); } if (subdev[i].device_name) { aos_free(subdev[i].device_name); } if (subdev[i].device_secret) { aos_free(subdev[i].device_secret); } } aos_free(subdev); } duk_push_int(ctx, res); return 1; } /* registerSubDevice */ static duk_ret_t native_aiot_registerSubDevice(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; aiot_subdev_dev_t *subdev; int subdev_length = 0; int i; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); subdev_length = duk_get_length(ctx, 1); subdev = aos_malloc(subdev_length * sizeof(aiot_subdev_dev_t)); if (subdev == NULL) { amp_debug(MOD_STR, "sub dev malloc failed"); goto out; } for (i = 0; i < subdev_length; i++) { duk_get_prop_index(ctx, 1, i); /* get pk */ duk_get_prop_string(ctx, -1, "productKey"); duk_get_prop_string(ctx, -2, "deviceName"); subdev[i].product_key = __amp_strdup(duk_get_string(ctx, -2)); subdev[i].device_name = __amp_strdup(duk_get_string(ctx, -1)); duk_pop_n(ctx, 3); } duk_dup(ctx, 2); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_REGISTER_SUBDEV_REF] = be_ref(ctx); res = aiot_subdev_send_sub_register(iot_gateway_handle->subdev_handle, subdev, subdev_length); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "send subdev register failed, res: -0x%04X", -res); // aiot_subdev_deinit(&iot_gateway_handle->subdev_handle); // aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); } out: if (subdev) { for (i = 0; i < subdev_length; i++) { if (subdev[i].product_key) { aos_free(subdev[i].product_key); } if (subdev[i].device_name) { aos_free(subdev[i].device_name); } } aos_free(subdev); } duk_push_int(ctx, res); return 1; } /* login */ static duk_ret_t native_aiot_login(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; aiot_subdev_dev_t *subdev; int subdev_length = 0; int i; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer), array)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); subdev_length = duk_get_length(ctx, 1); subdev = aos_malloc(subdev_length * sizeof(aiot_subdev_dev_t)); if (subdev == NULL) { amp_debug(MOD_STR, "sub dev malloc failed"); goto out; } for (i = 0; i < subdev_length; i++) { duk_get_prop_index(ctx, 1, i); /* get pk */ duk_get_prop_string(ctx, -1, "productKey"); duk_get_prop_string(ctx, -2, "deviceName"); duk_get_prop_string(ctx, -3, "deviceSecret"); subdev[i].product_key = __amp_strdup(duk_get_string(ctx, -3)); subdev[i].device_name = __amp_strdup(duk_get_string(ctx, -2)); subdev[i].device_secret = __amp_strdup(duk_get_string(ctx, -1)); duk_pop_n(ctx, 3); } duk_dup(ctx, 2); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_LOGIN_REF] = be_ref(ctx); res = aiot_subdev_send_batch_login(iot_gateway_handle->subdev_handle, subdev, subdev_length); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "send subdev batch login failed, res: -0x%04X", -res); // aiot_subdev_deinit(&iot_gateway_handle->subdev_handle); // aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); } out: if (subdev) { for (i = 0; i < subdev_length; i++) { if (subdev[i].product_key) { aos_free(subdev[i].product_key); } if (subdev[i].device_name) { aos_free(subdev[i].device_name); } if (subdev[i].device_secret) { aos_free(subdev[i].device_secret); } } aos_free(subdev); } duk_push_int(ctx, res); return 1; } /* logout */ static duk_ret_t native_aiot_logout(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; aiot_subdev_dev_t *subdev; int subdev_length = 0; int i; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer), array)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); subdev_length = duk_get_length(ctx, 1); subdev = aos_malloc(subdev_length * sizeof(aiot_subdev_dev_t)); if (subdev == NULL) { amp_debug(MOD_STR, "sub dev malloc failed"); goto out; } for (i = 0; i < subdev_length; i++) { duk_get_prop_index(ctx, 1, i); /* get pk */ duk_get_prop_string(ctx, -1, "productKey"); duk_get_prop_string(ctx, -2, "deviceName"); duk_get_prop_string(ctx, -3, "deviceSecret"); subdev[i].product_key = __amp_strdup(duk_get_string(ctx, -3)); subdev[i].device_name = __amp_strdup(duk_get_string(ctx, -2)); subdev[i].device_secret = __amp_strdup(duk_get_string(ctx, -1)); duk_pop_n(ctx, 3); } duk_dup(ctx, 2); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_LOGOUT_REF] = be_ref(ctx); res = aiot_subdev_send_batch_logout(iot_gateway_handle->subdev_handle, subdev, subdev_length); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "send subdev batch logout failed, res: -0x%04X", -res); // aiot_subdev_deinit(&iot_gateway_handle->subdev_handle); // aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); } out: if (subdev) { for (i = 0; i < subdev_length; i++) { if (subdev[i].product_key) { aos_free(subdev[i].product_key); } if (subdev[i].device_name) { aos_free(subdev[i].device_name); } if (subdev[i].device_secret) { aos_free(subdev[i].device_secret); } } aos_free(subdev); } duk_push_int(ctx, res); return 1; } /************************************************************************************* * Function: native_aiot_close * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ static duk_ret_t native_aiot_gateway_close(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be pointer"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); if (iot_gateway_handle == NULL) { amp_warn(MOD_STR, "iot_gateway_handle is null"); goto out; } g_iot_close_flag = 1; aos_sem_wait(&g_iot_close_sem, 200 + 50); res = aiot_mqtt_client_stop(&iot_gateway_handle->mqtt_handle); if (res < 0) { amp_debug(MOD_STR, "aiot stop failed"); goto out; } g_iot_close_flag = 0; duk_push_int(ctx, 0); aos_free(iot_gateway_handle); return 1; out: duk_push_int(ctx, res); return 1; } /* publish */ static duk_ret_t native_aiot_publish(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; char *topic; char *payload; uint16_t payload_len = 0; uint8_t qos = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); if (iot_gateway_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } duk_get_prop_string(ctx, 1, "topic"); duk_get_prop_string(ctx, 1, "payload"); duk_get_prop_string(ctx, 1, "qos"); if (!duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "invalid params"); duk_pop_n(ctx, 3); goto out; } qos = duk_get_number(ctx, -1); payload = (char *)duk_get_string(ctx, -2); topic = (char *)duk_get_string(ctx, -3); payload_len = strlen(payload); //duk_dup(ctx, 2); //iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_PUBLISH_REF] = be_ref(ctx); //amp_debug(MOD_STR, "publish topic: %s, payload: %s, qos is: %d", topic, payload, qos); res = aiot_mqtt_pub(iot_gateway_handle->mqtt_handle, topic, payload, payload_len, qos); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "aiot app mqtt publish failed\n"); goto out; } out: duk_push_int(ctx, res); return 1; } /* unsubscribe */ static duk_ret_t native_aiot_unsubscribe(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; char *topic; uint8_t qos = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, string)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); if (iot_gateway_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } topic = (char *)duk_get_string(ctx, 1); duk_dup(ctx, 2); iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_UNSUBSCRIBE_REF] = be_ref(ctx); amp_debug(MOD_STR, "unsubscribe topic: %s", topic); res = aiot_mqtt_unsub(iot_gateway_handle->mqtt_handle, topic); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "aiot app mqtt unsubscribe failed"); goto out; } out: duk_push_int(ctx, res); return 1; } /* subscribe */ static duk_ret_t native_aiot_subscribe(duk_context *ctx) { int res = -1; iot_gateway_handle_t *iot_gateway_handle = NULL; char *topic = NULL; uint8_t qos = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } iot_gateway_handle = duk_get_pointer(ctx, 0); if (iot_gateway_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } duk_get_prop_string(ctx, 1, "topic"); duk_get_prop_string(ctx, 1, "qos"); if (!duk_is_number(ctx, -1) || !duk_is_string(ctx, -2)) { amp_warn(MOD_STR, "invalid params"); duk_pop_n(ctx, 2); goto out; } qos = duk_get_number(ctx, -1); topic = (char *)duk_get_string(ctx, -2); //duk_dup(ctx, 2); //iot_gateway_handle->js_cb_ref[AIOT_SUBDEV_JSCALLBACK_SUBSCRIBE_REF] = be_ref(ctx); amp_debug(MOD_STR, "subscribe topic: %s, qos is: %d", topic, qos); res = aiot_mqtt_sub(iot_gateway_handle->mqtt_handle, topic, NULL, qos, NULL); if (res < STATE_SUCCESS) { amp_error(MOD_STR, "aiot app mqtt subscribe failed\n"); goto out; } out: duk_push_int(ctx, res); return 1; } /* on mqtt event */ static duk_ret_t native_aiot_on_mqtt_event(duk_context *ctx) { int res = STATE_SUCCESS; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } duk_dup(ctx, 0); g_on_message_cb_ref = be_ref(ctx); out: duk_push_int(ctx, res); return 1; } static void module_iot_source_clean(void) { duk_context *ctx = be_get_context(); g_on_message_cb_ref = 0; if (g_iot_conn_flag) { g_iot_close_flag = 1; aos_sem_wait(&g_iot_close_sem, 5100); g_iot_close_flag = 0; aos_msleep(10); } g_iot_clean_flag = 1; } void module_aiot_gateway_register(void) { duk_context *ctx = be_get_context(); if (!g_iot_close_sem) { if (aos_sem_new(&g_iot_close_sem, 0) != 0) { amp_error(MOD_STR, "create iot sem fail"); return; } } g_iot_clean_flag = 0; amp_module_free_register(module_iot_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("gateway", native_aiot_create_gateway, 2); AMP_ADD_FUNCTION("addTopo", native_aiot_addTopo, 3); AMP_ADD_FUNCTION("getTopo", native_aiot_getTopo, 2); AMP_ADD_FUNCTION("removeTopo", native_aiot_removeTopo, 3); AMP_ADD_FUNCTION("registerSubDevice", native_aiot_registerSubDevice, 3); AMP_ADD_FUNCTION("login", native_aiot_login, 3); AMP_ADD_FUNCTION("logout", native_aiot_logout, 3); AMP_ADD_FUNCTION("subscribe", native_aiot_subscribe, 3); AMP_ADD_FUNCTION("unsubscribe", native_aiot_unsubscribe, 3); AMP_ADD_FUNCTION("publish", native_aiot_publish, 3); AMP_ADD_FUNCTION("onMqttMessage", native_aiot_on_mqtt_event, 1); duk_put_prop_string(ctx, -2, "AIOT_GATEWAY"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/aiot/module_aiot_gateway.c
C
apache-2.0
38,343
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "aos/kv.h" #include "aiot_state_api.h" #include "aiot_sysdep_api.h" #include "aiot_mqtt_api.h" #include "aiot_dm_api.h" #include "aiot_subdev_api.h" #include "be_inl.h" #include "module_aiot.h" #ifdef AOS_COMP_UAGENT #include "uagent.h" #endif #define MOD_STR "AIOT_MQTT" /* 位于portfiles/aiot_port文件夹下的系统适配函数集合 */ extern aiot_sysdep_portfile_t g_aiot_sysdep_portfile; /* 位于external/ali_ca_cert.c中的服务器证书 */ extern const char *ali_ca_cert; uint8_t g_app_mqtt_process_thread_running = 0; uint8_t g_app_mqtt_recv_thread_running = 0; static char *__amp_strdup(char *src, int len) { char *dst; if (src == NULL) { return NULL; } dst = aos_malloc(len+1); if (dst == NULL) { return NULL; } memcpy(dst, src, len); dst[len] = '\0'; return dst; } /* 执行aiot_mqtt_process的线程, 包含心跳发送和QoS1消息重发 */ void *aiot_app_mqtt_process_thread(void *args) { int32_t res = STATE_SUCCESS; while (g_app_mqtt_process_thread_running) { res = aiot_mqtt_process(args); if (res == STATE_USER_INPUT_EXEC_DISABLED) { break; } aos_msleep(1000); } aos_task_exit(0); return; } /* 执行aiot_mqtt_recv的线程, 包含网络自动重连和从服务器收取MQTT消息 */ void *aiot_app_mqtt_recv_thread(void *args) { int32_t res = STATE_SUCCESS; while (g_app_mqtt_recv_thread_running) { res = aiot_mqtt_recv(args); if (res < STATE_SUCCESS) { if (res == STATE_USER_INPUT_EXEC_DISABLED) { break; } aos_msleep(1000); } } aos_task_exit(0); return; } /* MQTT默认消息处理回调, 当SDK从服务器收到MQTT消息时, 且无对应用户回调处理时被调用 */ void aiot_app_mqtt_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata) { void (*callback)(void *userdata) = (void (*)(void *))userdata; switch (packet->type) { case AIOT_MQTTRECV_HEARTBEAT_RESPONSE: { // amp_debug(MOD_STR, "heartbeat response"); /* TODO: 处理服务器对心跳的回应, 一般不处理 */ } break; case AIOT_MQTTRECV_SUB_ACK: { amp_debug(MOD_STR, "suback, res: -0x%04X, packet id: %d, max qos: %d", -packet->data.sub_ack.res, packet->data.sub_ack.packet_id, packet->data.sub_ack.max_qos); /* TODO: 处理服务器对订阅请求的回应, 一般不处理 */ } break; case AIOT_MQTTRECV_PUB: { //amp_debug(MOD_STR, "pub, qos: %d, topic: %.*s", packet->data.pub.qos, packet->data.pub.topic_len, packet->data.pub.topic); //amp_debug(MOD_STR, "pub, payload: %.*s", packet->data.pub.payload_len, packet->data.pub.payload); /* TODO: 处理服务器下发的业务报文 */ iot_mqtt_userdata_t *udata = (iot_mqtt_userdata_t *)userdata; iot_mqtt_message_t message; memset(&message, 0, sizeof(iot_mqtt_message_t)); if (udata && udata->callback) { message.option = AIOT_MQTTOPT_RECV_HANDLER; message.recv.type = packet->type; message.recv.code = AIOT_MQTT_MESSAGE; message.recv.topic = __amp_strdup(packet->data.pub.topic, packet->data.pub.topic_len); message.recv.payload = __amp_strdup(packet->data.pub.payload, packet->data.pub.payload_len); message.recv.topic_len = packet->data.pub.topic_len; message.recv.payload_len = packet->data.pub.payload_len; udata->callback(&message, udata); aos_free(message.recv.topic); aos_free(message.recv.payload); } } break; case AIOT_MQTTRECV_PUB_ACK: { amp_debug(MOD_STR, "puback, packet id: %d", packet->data.pub_ack.packet_id); /* TODO: 处理服务器对QoS1上报消息的回应, 一般不处理 */ } break; default: { } } } /* MQTT事件回调函数, 当网络连接/重连/断开时被触发, 事件定义见core/aiot_mqtt_api.h */ void aiot_app_mqtt_event_handler(void *handle, const aiot_mqtt_event_t *event, void *userdata) { iot_mqtt_userdata_t *udata = (iot_mqtt_userdata_t *)userdata; iot_mqtt_message_t message; memset(&message, 0, sizeof(iot_mqtt_message_t)); message.option = AIOT_MQTTOPT_EVENT_HANDLER; message.event.type = event->type; switch (event->type) { /* SDK因为用户调用了aiot_mqtt_connect()接口, 与mqtt服务器建立连接已成功 */ case AIOT_MQTTEVT_CONNECT: { amp_debug(MOD_STR, "AIOT_MQTTEVT_CONNECT"); /* TODO: 处理SDK建连成功, 不可以在这里调用耗时较长的阻塞函数 */ message.event.code = AIOT_MQTT_CONNECT; } break; /* SDK因为网络状况被动断连后, 自动发起重连已成功 */ case AIOT_MQTTEVT_RECONNECT: { amp_debug(MOD_STR, "AIOT_MQTTEVT_RECONNECT"); /* TODO: 处理SDK重连成功, 不可以在这里调用耗时较长的阻塞函数 */ message.event.code = AIOT_MQTT_RECONNECT; } break; /* SDK因为网络的状况而被动断开了连接, network是底层读写失败, heartbeat是没有按预期得到服务端心跳应答 */ case AIOT_MQTTEVT_DISCONNECT: { char *cause = (event->data.disconnect == AIOT_MQTTDISCONNEVT_NETWORK_DISCONNECT) ? ("network disconnect") : ("heartbeat disconnect"); amp_debug(MOD_STR, "AIOT_MQTTEVT_DISCONNECT: %s", cause); /* TODO: 处理SDK被动断连, 不可以在这里调用耗时较长的阻塞函数 */ message.event.code = AIOT_MQTT_DISCONNECT; } break; default: { return; } } if (udata && udata->callback) udata->callback(&message, udata); } /* 属性上报函数演示 */ int32_t aiot_app_send_property_post(void *dm_handle, char *params) { aiot_dm_msg_t msg; memset(&msg, 0, sizeof(aiot_dm_msg_t)); msg.type = AIOT_DMMSG_PROPERTY_POST; msg.data.property_post.params = params; return aiot_dm_send(dm_handle, &msg); } /* 事件上报函数演示 */ int32_t aiot_app_send_event_post(void *dm_handle, char *event_id, char *params) { aiot_dm_msg_t msg; memset(&msg, 0, sizeof(aiot_dm_msg_t)); msg.type = AIOT_DMMSG_EVENT_POST; msg.data.event_post.event_id = event_id; msg.data.event_post.params = params; return aiot_dm_send(dm_handle, &msg); } int32_t aiot_mqtt_client_start(void **handle, int keepaliveSec, iot_mqtt_userdata_t *userdata) { int32_t res = STATE_SUCCESS; void *mqtt_handle = NULL; char *url = "iot-as-mqtt.cn-shanghai.aliyuncs.com"; /* 阿里云平台上海站点的域名后缀 */ char host[100] = {0}; /* 用这个数组拼接设备连接的云平台站点全地址, 规则是 ${productKey}.iot-as-mqtt.cn-shanghai.aliyuncs.com */ uint16_t port = 443; /* 无论设备是否使用TLS连接阿里云平台, 目的端口都是443 */ aiot_sysdep_network_cred_t cred; /* 安全凭据结构体, 如果要用TLS, 这个结构体中配置CA证书等参数 */ /* get device tripple info */ char product_key[IOTX_PRODUCT_KEY_LEN] = {0}; char device_name[IOTX_DEVICE_NAME_LEN] = {0}; char device_secret[IOTX_DEVICE_SECRET_LEN] = {0}; int productkey_len = IOTX_PRODUCT_KEY_LEN; int devicename_len = IOTX_DEVICE_NAME_LEN; int devicesecret_len = IOTX_DEVICE_SECRET_LEN; aos_kv_get(AMP_CUSTOMER_PRODUCTKEY, product_key, &productkey_len); aos_kv_get(AMP_CUSTOMER_DEVICENAME, device_name, &devicename_len); aos_kv_get(AMP_CUSTOMER_DEVICESECRET, device_secret, &devicesecret_len); /* end get device tripple info */ /* 配置SDK的底层依赖 */ aiot_sysdep_set_portfile(&g_aiot_sysdep_portfile); /* 配置SDK的日志输出 */ // aiot_state_set_logcb(demo_state_logcb); /* 创建SDK的安全凭据, 用于建立TLS连接 */ memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t)); cred.option = AIOT_SYSDEP_NETWORK_CRED_SVRCERT_CA; /* 使用RSA证书校验MQTT服务端 */ cred.max_tls_fragment = 16384; /* 最大的分片长度为16K, 其它可选值还有4K, 2K, 1K, 0.5K */ cred.sni_enabled = 1; /* TLS建连时, 支持Server Name Indicator */ cred.x509_server_cert = ali_ca_cert; /* 用来验证MQTT服务端的RSA根证书 */ cred.x509_server_cert_len = strlen(ali_ca_cert); /* 用来验证MQTT服务端的RSA根证书长度 */ /* 创建1个MQTT客户端实例并内部初始化默认参数 */ mqtt_handle = aiot_mqtt_init(); if (mqtt_handle == NULL) { amp_debug(MOD_STR, "aiot_mqtt_init failed"); aos_free(mqtt_handle); return -1; } /* TODO: 如果以下代码不被注释, 则例程会用TCP而不是TLS连接云平台 */ { memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t)); cred.option = AIOT_SYSDEP_NETWORK_CRED_NONE; } snprintf(host, 100, "%s.%s", product_key, url); /* 配置MQTT服务器地址 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_HOST, (void *)host); /* 配置MQTT服务器端口 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PORT, (void *)&port); /* 配置设备productKey */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PRODUCT_KEY, (void *)product_key); /* 配置设备deviceName */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_DEVICE_NAME, (void *)device_name); /* 配置设备deviceSecret */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_DEVICE_SECRET, (void *)device_secret); /* 配置网络连接的安全凭据, 上面已经创建好了 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_NETWORK_CRED, (void *)&cred); /* 配置MQTT心跳间隔 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_KEEPALIVE_SEC, (void *)&keepaliveSec); /* 配置回调参数 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_USERDATA, userdata); /* 配置MQTT默认消息接收回调函数 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_RECV_HANDLER, (void *)aiot_app_mqtt_recv_handler); /* 配置MQTT事件回调函数 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_EVENT_HANDLER, (void *)aiot_app_mqtt_event_handler); /* 与服务器建立MQTT连接 */ res = aiot_mqtt_connect(mqtt_handle); if (res < STATE_SUCCESS) { /* 尝试建立连接失败, 销毁MQTT实例, 回收资源 */ aiot_mqtt_deinit(&mqtt_handle); amp_debug(MOD_STR, "aiot_mqtt_connect failed: -0x%04X", -res); aos_task_exit(0); return -1; } /* 创建一个单独的线程, 专用于执行aiot_mqtt_process, 它会自动发送心跳保活, 以及重发QoS1的未应答报文 */ g_app_mqtt_process_thread_running = 1; aos_task_t mqtt_process_task; if (aos_task_new_ext(&mqtt_process_task, "mqtt_process", aiot_app_mqtt_process_thread, mqtt_handle, 1024 * 4, AOS_DEFAULT_APP_PRI) != 0) { amp_debug(MOD_STR, "management mqtt process task create failed!"); aiot_mqtt_deinit(&mqtt_handle); aos_task_exit(0); return -1; } amp_debug(MOD_STR, "app mqtt process start"); /* 创建一个单独的线程用于执行aiot_mqtt_recv, 它会循环收取服务器下发的MQTT消息, 并在断线时自动重连 */ g_app_mqtt_recv_thread_running = 1; aos_task_t mqtt_rec_task; if (aos_task_new_ext(&mqtt_rec_task, "mqtt_rec", aiot_app_mqtt_recv_thread, mqtt_handle, 1024 * 4, AOS_DEFAULT_APP_PRI) != 0) { amp_debug(MOD_STR, "management mqtt rec task create failed!"); aiot_mqtt_deinit(&mqtt_handle); aos_task_exit(0); return -1; } amp_debug(MOD_STR, "app mqtt rec start"); *handle = mqtt_handle; #ifdef AOS_COMP_UAGENT res = uagent_mqtt_client_set(mqtt_handle); if (res != 0) { amp_debug(MOD_STR, "uAgent mqtt handle set failed ret = %d\n", res); } res = uagent_ext_comm_start(product_key, device_name); if (res != 0) { amp_debug(MOD_STR, "uAgent ext comm start failed ret = %d\n", res); } #endif return 0; } /* mqtt stop */ int32_t aiot_mqtt_client_stop(void **handle) { int32_t res = STATE_SUCCESS; void *mqtt_handle = NULL; mqtt_handle = *handle; g_app_mqtt_process_thread_running = 0; g_app_mqtt_recv_thread_running = 0; /* 断开MQTT连接 */ res = aiot_mqtt_disconnect(mqtt_handle); if (res < STATE_SUCCESS) { aiot_mqtt_deinit(&mqtt_handle); amp_debug(MOD_STR, "aiot_mqtt_disconnect failed: -0x%04X", -res); return -1; } /* 销毁MQTT实例 */ res = aiot_mqtt_deinit(&mqtt_handle); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "aiot_mqtt_deinit failed: -0x%04X", -res); return -1; } return res; }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/aiot/module_aiot_mqtt.c
C
apache-2.0
13,258
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "aos_fs.h" #include "board_mgr.h" #include "be_inl.h" #include "uvoice_types.h" #include "uvoice_event.h" #include "uvoice_player.h" #include "uvoice_comb.h" #include "aos_pcm.h" #include "aos_tts.h" #define MOD_STR "audioplayer" typedef struct { uvoice_player_t *player; int js_cb_ref; int list_playing; int state; } audio_player_t; typedef struct { void *userdata; int js_cb_ref; int event; unsigned long timestamp; } audio_player_param_t; enum { AUDIOPLAYER_STAT_STOP = 0, AUDIOPLAYER_STAT_PAUSED = 1, AUDIOPLAYER_STAT_PLAYING = 2, AUDIOPLAYER_STAT_LIST_PLAY_BEGIN = 3, AUDIOPLAYER_STAT_LIST_PLAY_END = 4, AUDIOPLAYER_STAT_ERROR = 5, }; static audio_player_t *g_audioplayer; static void audioplayer_state_notify(void *arg) { audio_player_t *audioplayer = (audio_player_t *)arg; duk_context *ctx; ctx = be_get_context(); be_push_ref(ctx, audioplayer->js_cb_ref); duk_push_int(ctx, audioplayer->state); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void audioplayer_state_cb(uvoice_event_t *event, void *data) { duk_context *ctx; audio_player_t *audioplayer = (audio_player_t *)data; player_state_t state; int audioplayer_state = PLAYER_STAT_IDLE; int ret; if (!audioplayer) return; if (event->type != UVOICE_EV_PLAYER) return; if (event->code == UVOICE_CODE_PLAYER_STATE) { state = event->value; switch (state) { case PLAYER_STAT_RUNNING: case PLAYER_STAT_COMPLETE: case PLAYER_STAT_RESUME: audioplayer_state = AUDIOPLAYER_STAT_PLAYING; break; case PLAYER_STAT_PAUSED: audioplayer_state = AUDIOPLAYER_STAT_PAUSED; break; case PLAYER_STAT_STOP: case PLAYER_STAT_IDLE: case PLAYER_STAT_READY: audioplayer_state = AUDIOPLAYER_STAT_STOP; break; case PLAYER_STAT_ERROR: audioplayer_state = AUDIOPLAYER_STAT_ERROR; break; case PLAYER_STAT_LIST_PLAY_START: audioplayer_state = AUDIOPLAYER_STAT_LIST_PLAY_BEGIN; audioplayer->list_playing = 1; break; case PLAYER_STAT_LIST_PLAY_STOP: audioplayer_state = AUDIOPLAYER_STAT_LIST_PLAY_END; audioplayer->list_playing = 0; break; default: return; } } if (audioplayer->state == audioplayer_state) { return; } audioplayer->state = audioplayer_state; amp_task_schedule_call(audioplayer_state_notify, audioplayer); } static void audioplayer_play_cplt_notify(void *arg) { audio_player_param_t *param = (audio_player_param_t *)arg; duk_context *ctx; ctx = be_get_context(); be_push_ref(ctx, param->js_cb_ref); if (duk_pcall(ctx, 0) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, param->js_cb_ref); duk_gc(ctx, 0); aos_free(param); } static void audioplayer_play_cplt_cb(uvoice_event_t *event, void *data) { audio_player_param_t *param = (audio_player_param_t *)data; if (!param) return; if (event->type != UVOICE_EV_PLAYER) return; if (event->code == UVOICE_CODE_PLAYER_STATE && (event->value == PLAYER_STAT_COMPLETE || event->value == PLAYER_STAT_STOP) && (unsigned long)aos_now_ms() >= param->timestamp) { amp_task_schedule_call(audioplayer_play_cplt_notify, param); uvoice_event_unregister(UVOICE_EV_PLAYER, audioplayer_play_cplt_cb, param); } } static void audioplayer_listplay_cplt_cb(void *data, int event) { audio_player_param_t *param = (audio_player_param_t *)data; param->event = event; amp_task_schedule_call(audioplayer_play_cplt_notify, param); } static duk_ret_t native_audioplayer_play(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; audio_player_param_t *param; uvoice_player_t *player; char *audiosource, *source = NULL; int len; int is_http = 0; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (!duk_is_string(ctx, 0) || !duk_is_function(ctx, 1)) { amp_error(MOD_STR, "parameter must be (string, function)"); goto out; } param = aos_malloc(sizeof(audio_player_param_t)); if (!param) { amp_error(MOD_STR, "alloc param fail"); goto out; } audiosource = (char *)duk_get_string(ctx, 0); if (!audiosource) { amp_error(MOD_STR, "audio source null"); aos_free(param); goto out; } if (!strncmp(audiosource, "http", strlen("http"))) { is_http = 1; source = audiosource; } else { source = aos_malloc(strlen(audiosource) + 4); if (!source) { amp_error(MOD_STR, "alloc source fail"); aos_free(param); goto out; } snprintf(source, strlen(audiosource) + 4, "fs:%s", audiosource); } duk_dup(ctx, 1); param->js_cb_ref = be_ref(ctx); param->timestamp = (unsigned long)aos_now_ms(); if (comb_add_http_source(source, 0)) { amp_error(MOD_STR, "add source fail"); be_unref(ctx, param->js_cb_ref); aos_free(param); goto out; } if (uvoice_event_register(UVOICE_EV_PLAYER, audioplayer_play_cplt_cb, param)) { amp_error(MOD_STR, "register event fail"); be_unref(ctx, param->js_cb_ref); aos_free(param); goto out; } ret = 0; out: if (!is_http && source) { aos_free(source); } duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_stop(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->stop()) { comb_clr_http_source(); goto out; } player->clr_source(); comb_clr_http_source(); ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_pause(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->pause()) { amp_error(MOD_STR, "play pause fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_resume(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->resume()) { amp_error(MOD_STR, "play resume fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_seekto(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int ret = -1; int seconds; if (!audioplayer) goto out; player = audioplayer->player; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } seconds = duk_get_int(ctx, 0); if (seconds < 0) { amp_error(MOD_STR, "seconds %d invalid", seconds); goto out; } if (player->seek(seconds)) { amp_error(MOD_STR, "seek to %d fail", seconds); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_position_get(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int position = 0; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->get_position(&position)) { amp_error(MOD_STR, "get position fail"); goto out; } ret = position; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_duration_get(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int duration = 0; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->get_duration(&duration)) { amp_error(MOD_STR, "get duration fail"); goto out; } ret = duration; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_state_get(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; player_state_t state = PLAYER_STAT_IDLE; int audioplayer_state; int ret = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->get_state(&state)) { amp_error(MOD_STR, "get player state fail"); goto out; } switch (state) { case PLAYER_STAT_RUNNING: case PLAYER_STAT_COMPLETE: case PLAYER_STAT_RESUME: audioplayer_state = AUDIOPLAYER_STAT_PLAYING; break; case PLAYER_STAT_PAUSED: audioplayer_state = AUDIOPLAYER_STAT_PAUSED; break; case PLAYER_STAT_STOP: case PLAYER_STAT_IDLE: case PLAYER_STAT_READY: audioplayer_state = AUDIOPLAYER_STAT_STOP; break; case PLAYER_STAT_ERROR: audioplayer_state = AUDIOPLAYER_STAT_ERROR; break; case PLAYER_STAT_LIST_PLAY_START: audioplayer_state = AUDIOPLAYER_STAT_LIST_PLAY_BEGIN; break; case PLAYER_STAT_LIST_PLAY_STOP: audioplayer_state = AUDIOPLAYER_STAT_LIST_PLAY_END; break; default: audioplayer_state = AUDIOPLAYER_STAT_STOP; break; } ret = audioplayer_state; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_state_on(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; int ret = -1; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } duk_dup(ctx, 0); audioplayer->js_cb_ref = be_ref(ctx); if (uvoice_event_register(UVOICE_EV_PLAYER, audioplayer_state_cb, audioplayer)) { amp_error(MOD_STR, "register event fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_volume_set(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int ret = -1; int volume; if (!audioplayer) goto out; player = audioplayer->player; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } volume = duk_get_int(ctx, 0); if (volume < 0) { amp_error(MOD_STR, "volume %d invalid", volume); goto out; } if (player->set_volume(volume)) { amp_error(MOD_STR, "set volume fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_volume_get(duk_context *ctx) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; int ret = -1; int volume = -1; if (!audioplayer) goto out; player = audioplayer->player; if (player->get_volume(&volume)) { amp_error(MOD_STR, "get volume fail"); goto out; } ret = volume; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_play_list(duk_context *ctx) { audio_player_param_t *param; char *source; int arr_idx; int arr_cnt; int i, ret = -1; int error = 0; struct aos_stat stat; comb_source_info_t *info; if (!duk_is_array(ctx, 0) || !duk_is_function(ctx, 1)) { amp_error(MOD_STR, "parameter must be (array, function)"); goto out; } param = aos_malloc(sizeof(audio_player_param_t)); if (!param) { amp_error(MOD_STR, "alloc param fail"); goto out; } info = aos_malloc(sizeof(comb_source_info_t)); if (!info) { amp_error(MOD_STR, "alloc info fail"); aos_free(param); goto out; } memset(info, 0, sizeof(comb_source_info_t)); arr_idx = duk_normalize_index(ctx, 0); arr_cnt = duk_get_length(ctx, arr_idx); if (arr_cnt > COMB_SOURCE_LIST_MAX) { amp_error(MOD_STR, "list count out of limit"); aos_free(param); aos_free(info); goto out; } duk_dup(ctx, 1); param->js_cb_ref = be_ref(ctx); for (i = 0; i < arr_cnt; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_string(ctx, -1)) { amp_error(MOD_STR, "array element %d is not string", i); duk_pop(ctx); be_unref(ctx, param->js_cb_ref); aos_free(param); aos_free(info); goto out; } source = duk_get_string(ctx, -1); if (strlen(source) >= COMB_SOURCE_PATH_LEN) { amp_error(MOD_STR, "source %s path too long", source); duk_pop(ctx); be_unref(ctx, param->js_cb_ref); aos_free(param); aos_free(info); goto out; } memset(&stat, 0, sizeof(aos_stat)); ret = aos_stat(source, &stat); if (ret < 0 || !S_ISREG(stat.st_mode)) { amp_error(MOD_STR, "source %s not exist", source); duk_pop(ctx); be_unref(ctx, param->js_cb_ref); aos_free(param); aos_free(info); ret = -1; goto out; } info->count++; snprintf(info->sources[i], COMB_SOURCE_PATH_LEN, "%s", source); duk_pop(ctx); } info->callback = audioplayer_listplay_cplt_cb; info->userdata = param; if (comb_add_file_source_list(info)) { error = -1; } aos_free(info); ret = error; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_play_list_stop(duk_context *ctx) { comb_play_stop(); comb_clr_http_source(); duk_push_int(ctx, 0); return 1; } static int native_audioplayer_config_parse(uvoice_player_t *player) { item_handle_t item_handle; item_handle.handle = NULL; aos_audio_dev_t *audio_dev = NULL; audio_extpa_info_t pa_info; if (board_attach_item(MODULE_AUDIO, "audio", &item_handle)) { player->set_out_device(AOS_SND_DEVICE_OUT_HEADPHONE); #ifdef JSE_ADVANCED_ADDON_TTS aos_tts_set_out_device(AOS_SND_DEVICE_OUT_HEADPHONE); #endif } else { audio_dev = board_get_node_by_handle(MODULE_AUDIO, &item_handle); if (!audio_dev) { amp_warn(MOD_STR, "get audio module fail"); return -1; } else { amp_info(MOD_STR, "out device %d, ext pa %s, pin %d, delay %d, active %d", audio_dev->out_device, audio_dev->external_pa ? "enable" : "disable", audio_dev->external_pa_pin, audio_dev->external_pa_delay_ms, audio_dev->external_pa_active_high); } if (audio_dev->out_device >= AOS_SND_DEVICE_OUT_SPEAKER && audio_dev->out_device < AOS_SND_DEVICE_MAX) { if (player->set_out_device) player->set_out_device(audio_dev->out_device); #ifdef JSE_ADVANCED_ADDON_TTS aos_tts_set_out_device(audio_dev->out_device); #endif } else { if (player->set_out_device) player->set_out_device(AOS_SND_DEVICE_OUT_HEADPHONE); #ifdef JSE_ADVANCED_ADDON_TTS aos_tts_set_out_device(AOS_SND_DEVICE_OUT_HEADPHONE); #endif } if (audio_dev->external_pa) { pa_info.used = audio_dev->external_pa; pa_info.active_high = audio_dev->external_pa_active_high; pa_info.pin = audio_dev->external_pa_pin; pa_info.delay_ms = audio_dev->external_pa_delay_ms; if (player->set_external_pa) player->set_external_pa(&pa_info); #ifdef JSE_ADVANCED_ADDON_TTS aos_tts_set_external_pa(audio_dev->external_pa_pin, audio_dev->external_pa_active_high, audio_dev->external_pa_delay_ms); #endif } } return 0; } static void module_audioplayer_source_clean(void) { audio_player_t *audioplayer = g_audioplayer; uvoice_player_t *player; if (!audioplayer) return; player = audioplayer->player; if (!player) { return; } comb_play_stop(); comb_clr_http_source(); player->stop(); player->clr_source(); uvoice_player_release(player); aos_free(audioplayer); g_audioplayer = NULL; comb_deinit(); uvoice_free(); } void module_audioplayer_register(void) { duk_context *ctx = be_get_context(); audio_player_t *audioplayer; uvoice_init(); comb_init(); audioplayer = aos_malloc(sizeof(audio_player_t)); if (!audioplayer) { amp_error(MOD_STR, "alloc audio player fail"); return; } audioplayer->player = uvoice_player_create(); if (!audioplayer->player) { amp_error(MOD_STR, "create uvoice player fail"); aos_free(audioplayer); return; } native_audioplayer_config_parse(audioplayer->player); audioplayer->state = -1; g_audioplayer = audioplayer; amp_module_free_register(module_audioplayer_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("listPlay", native_audioplayer_play_list, 2); AMP_ADD_FUNCTION("listPlayStop",native_audioplayer_play_list_stop, 0); AMP_ADD_FUNCTION("play", native_audioplayer_play, 2); AMP_ADD_FUNCTION("stop", native_audioplayer_stop, 0); AMP_ADD_FUNCTION("pause", native_audioplayer_pause, 0); AMP_ADD_FUNCTION("resume", native_audioplayer_resume, 0); AMP_ADD_FUNCTION("seekto", native_audioplayer_seekto, 1); AMP_ADD_FUNCTION("getPosition", native_audioplayer_position_get, 0); AMP_ADD_FUNCTION("getDuration", native_audioplayer_duration_get, 0); AMP_ADD_FUNCTION("getState", native_audioplayer_state_get, 0); AMP_ADD_FUNCTION("onState", native_audioplayer_state_on, 1); AMP_ADD_FUNCTION("setVolume", native_audioplayer_volume_set, 1); AMP_ADD_FUNCTION("getVolume", native_audioplayer_volume_get, 0); duk_put_prop_string(ctx, -2, "audioplayer"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/audio/module_audioplayer.c
C
apache-2.0
18,774
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "aos_system.h" #include "amp_defines.h" #include "dev_model_api.h" #include "be_inl.h" #include "fibo_opencpu.h" #define MOD_STR "audioplayer" #define PLAY_LIST_FILE_COUNT_MAX 32 #define PLAY_LIST_FILE_PATH_LEN_MAX 64 static char g_play_list[PLAY_LIST_FILE_COUNT_MAX][PLAY_LIST_FILE_PATH_LEN_MAX]; static int g_play_cb_js_ref; enum { AUDIOPLAYER_STAT_STOP = 0, AUDIOPLAYER_STAT_PLAYING = 1 }; static void __audioplayer_complete_cb(void) { duk_context *ctx; ctx = be_get_context(); be_push_ref(ctx, g_play_cb_js_ref); if (duk_pcall(ctx, 0) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static duk_ret_t native_audioplayer_play(duk_context *ctx) { char *audiosource, *source = NULL; char root_dir[16]; int ret = -1; if (!duk_is_string(ctx, 0) || !duk_is_function(ctx, 1)) { amp_error(MOD_STR, "parameter must be (string, function)"); goto out; } if (fibo_get_audio_status()) { amp_error(MOD_STR, "player busy"); goto out; } audiosource = (char *)duk_get_string(ctx, 0); if (!audiosource) { amp_error(MOD_STR, "audio source null"); goto out; } duk_dup(ctx, 1); g_play_cb_js_ref = be_ref(ctx); memset(root_dir, 0, sizeof(root_dir)); amp_get_user_dir(root_dir); if (!strncmp(audiosource, "http", strlen("http"))) { amp_error(MOD_STR, "http play not support"); goto out; } else { source = aos_malloc(strlen(audiosource) + strlen(root_dir) + 1); if (!source) { amp_error(MOD_STR, "alloc source fail"); goto out; } snprintf(source, strlen(audiosource) + strlen(root_dir) + 1, "%s%s", root_dir, audiosource); } if (fibo_audio_path_play(1, source, __audioplayer_complete_cb) < 0) { amp_error(MOD_STR, "play %s fail", source); goto out; } aos_free(source); ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_stop(duk_context *ctx) { int ret = -1; if (fibo_audio_stop() < 0) { amp_error(MOD_STR, "play stop fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_pause(duk_context *ctx) { int ret = -1; if (fibo_audio_pause() < 0) { amp_error(MOD_STR, "play pause fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_resume(duk_context *ctx) { int ret = -1; if (fibo_audio_resume() < 0) { amp_error(MOD_STR, "play resume fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_state_get(duk_context *ctx) { int ret; if (fibo_get_audio_status()) { ret = AUDIOPLAYER_STAT_PLAYING; } else { ret = AUDIOPLAYER_STAT_STOP; } duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_state_on(duk_context *ctx) { int ret = -1; int js_cb_ref; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } //duk_dup(ctx, 0); //js_cb_ref = be_ref(ctx); ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_seekto(duk_context *ctx) { int ret = -1; int seconds; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } seconds = duk_get_int(ctx, 0); if (seconds < 0) { amp_error(MOD_STR, "seconds %d invalid", seconds); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_position_get(duk_context *ctx) { int position = 0; int ret = -1; ret = position; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_duration_get(duk_context *ctx) { int duration = 0; int ret = -1; ret = duration; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_volume_set(duk_context *ctx) { int ret = -1; int volume; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } volume = duk_get_int(ctx, 0); if (volume < 0 || volume > 100) { amp_error(MOD_STR, "volume %d invalid", volume); goto out; } if (fibo_set_volume_external(AUDIO_PLAY_VOLUME, volume) < 0) { amp_error(MOD_STR, "set volume fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_volume_get(duk_context *ctx) { int ret; ret = fibo_get_volume_external(AUDIO_PLAY_VOLUME); if (ret < 0) { amp_error(MOD_STR, "get volume fail"); ret = -1; goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_play_list(duk_context *ctx) { char *source; char root_dir[16] = {0}; int rootdir_len; int arr_idx; int arr_cnt; int i, j, len, ret = -1; if (!duk_is_array(ctx, 0) || !duk_is_function(ctx, 1)) { amp_error(MOD_STR, "parameter must be (array, function)"); goto out; } arr_idx = duk_normalize_index(ctx, 0); arr_cnt = duk_get_length(ctx, arr_idx); if (arr_cnt > PLAY_LIST_FILE_COUNT_MAX) { amp_error(MOD_STR, "list count out of limit"); goto out; } amp_get_user_dir(root_dir); rootdir_len = strlen(root_dir); for (i = 0; i < arr_cnt; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_string(ctx, -1)) { amp_error(MOD_STR, "array element %d is not string", i); duk_pop(ctx); goto out; } source = duk_get_string(ctx, -1); snprintf(g_play_list[i], PLAY_LIST_FILE_PATH_LEN_MAX, "%s%s", root_dir, source); duk_pop(ctx); } if (fibo_audio_list_play(g_play_list, arr_cnt) < 0) { amp_error(MOD_STR, "play list fail"); ret = -1; } else { ret = 0; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_audioplayer_play_list_stop(duk_context *ctx) { int ret = -1; if (fibo_audio_stop() < 0) { amp_error(MOD_STR, "play stop fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } void module_audioplayer_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("listPlay", native_audioplayer_play_list, 2); AMP_ADD_FUNCTION("listPlayStop",native_audioplayer_play_list_stop, 0); AMP_ADD_FUNCTION("play", native_audioplayer_play, 2); AMP_ADD_FUNCTION("stop", native_audioplayer_stop, 0); AMP_ADD_FUNCTION("pause", native_audioplayer_pause, 0); AMP_ADD_FUNCTION("resume", native_audioplayer_resume, 0); AMP_ADD_FUNCTION("seekto", native_audioplayer_seekto, 1); AMP_ADD_FUNCTION("getPosition", native_audioplayer_position_get, 0); AMP_ADD_FUNCTION("getDuration", native_audioplayer_duration_get, 0); AMP_ADD_FUNCTION("getState", native_audioplayer_state_get, 0); AMP_ADD_FUNCTION("onState", native_audioplayer_state_on, 1); AMP_ADD_FUNCTION("setVolume", native_audioplayer_volume_set, 1); AMP_ADD_FUNCTION("getVolume", native_audioplayer_volume_get, 0); duk_put_prop_string(ctx, -2, "audioplayer"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/audio/module_audioplayer_fibo.c
C
apache-2.0
7,736
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "be_inl.h" #include "aos_pcm.h" #include "aos_tts.h" #define MOD_STR "TTS" static int tts_js_cb_ref = 0; static void native_tts_event_callback(aos_tts_event_t event, char *content) { duk_context *ctx; if (tts_js_cb_ref == 0) { return; } ctx = be_get_context(); be_push_ref(ctx, tts_js_cb_ref); duk_push_int(ctx, event); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static duk_ret_t native_tts_play(duk_context *ctx) { int ret = -1; int encode_type; char *text; if (!duk_is_string(ctx, 0)|| !duk_is_number(ctx, 1)) { amp_error(MOD_STR, "parameter must be (string, num)"); goto out; } text = (char *)duk_get_string(ctx, 0); if (!text) { amp_error(MOD_STR, "text null"); goto out; } encode_type = duk_get_number(ctx, 1); if (encode_type < 0) { amp_error(MOD_STR, "encode type invalid"); goto out; } if (aos_tts_is_playing()) { amp_warn(MOD_STR, "tts is playing, ignore"); goto out; } ret = aos_tts_play(text, encode_type); if (ret != 0) { amp_error(MOD_STR, "tts play failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_tts_stop(duk_context *ctx) { int ret = -1; ret = aos_tts_stop(); if (ret != 0) { amp_error(MOD_STR, "tts stop failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_tts_state_get(duk_context *ctx) { int state = -1; aos_tts_state_get(&state); duk_push_int(ctx, state); return 1; } static duk_ret_t native_tts_volume_set(duk_context *ctx) { int ret = -1; int volume; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } volume = duk_get_int(ctx, 0); if (volume < 0) { amp_error(MOD_STR, "volume invalid"); goto out; } ret = aos_tts_volume_set(volume); if (ret != 0) { amp_error(MOD_STR, "set tts volume failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_tts_volume_get(duk_context *ctx) { int volume = -1; aos_tts_volume_get(&volume); duk_push_int(ctx, volume); return 1; } static duk_ret_t native_tts_pitch_set(duk_context *ctx) { int ret = -1; int pitch; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } pitch = duk_get_int(ctx, 0); if (pitch < 0) { amp_error(MOD_STR, "pitch invalid"); goto out; } ret = aos_tts_pitch_set(pitch); if (ret != 0) { amp_error(MOD_STR, "set tts pitch failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_tts_speed_set(duk_context *ctx) { int ret = -1; int speed; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)\n"); goto out; } speed = duk_get_int(ctx, 0); if (speed < 0) { amp_error(MOD_STR, "speed invalid"); goto out; } ret = aos_tts_speed_set(speed); if (ret != 0) { amp_error(MOD_STR, "set tts speed failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_tts_speed_get(duk_context *ctx) { int speed = -1; aos_tts_speed_get(&speed); duk_push_int(ctx, speed); return 1; } static duk_ret_t native_tts_event_on(duk_context *ctx) { int ret = -1; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } duk_dup(ctx, 0); tts_js_cb_ref = be_ref(ctx); ret = 0; out: duk_push_int(ctx, ret); return 1; } static void native_tts_source_clean(void) { if (aos_tts_is_playing()) { aos_tts_stop(); } aos_tts_deinit(); tts_js_cb_ref = 0; } void module_tts_register(void) { duk_context *ctx = be_get_context(); aos_tts_init(native_tts_event_callback); amp_module_free_register(native_tts_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("play", native_tts_play, 2); AMP_ADD_FUNCTION("stop", native_tts_stop, 0); AMP_ADD_FUNCTION("getState", native_tts_state_get, 1); AMP_ADD_FUNCTION("onState", native_tts_event_on, 1); AMP_ADD_FUNCTION("setVolume", native_tts_volume_set, 1); AMP_ADD_FUNCTION("getVolume", native_tts_volume_get, 1); AMP_ADD_FUNCTION("setPitch", native_tts_pitch_set, 1); AMP_ADD_FUNCTION("setSpeed", native_tts_speed_set, 1); AMP_ADD_FUNCTION("getSpeed", native_tts_speed_get, 1); duk_put_prop_string(ctx, -2, "TTS"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/audio/module_tts.c
C
apache-2.0
5,034
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "be_inl.h" #define MOD_STR "BLECFGNET" static duk_ret_t native_blecfgnet_start(duk_context *ctx) { int ret = -1; ret = BleCfg_run(); if (ret != 0) { amp_warn(MOD_STR, "ble config net start failed"); } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_blecfgnet_recovery_wifi(duk_context *ctx) { int ret = -1; ret = BleCfg_recovery_wifi(); if (ret != 0) { amp_warn(MOD_STR, "ble config net recovery wifi failed"); } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_blecfgnet_recovery_devinfo(duk_context *ctx) { int ret = -1; ret = BleCfg_recovery_devinfo(); if (ret != 0) { amp_warn(MOD_STR, "ble config net recovery device info failed"); } out: duk_push_int(ctx, ret); return 1; } void module_blecfgnet_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("start", native_blecfgnet_start, 0); AMP_ADD_FUNCTION("recoveryWifi", native_blecfgnet_recovery_wifi, 0); AMP_ADD_FUNCTION("recoveryDevInfo", native_blecfgnet_recovery_devinfo, 0); duk_put_prop_string(ctx, -2, "BLECFGNET"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/bleconfig_wifi/module_blecfgnet.c
C
apache-2.0
1,387
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "amp_hal_keypad.h" #include "aos_system.h" #include "amp_task.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "Keypad" static int keypad_js_cb_ref; typedef struct { keypad_code_t code; int value; } keypad_notify_t; static int keypad_notify_callback(void *pdata) { duk_context *ctx; keypad_notify_t *param = (keypad_notify_t *)pdata; if (!param) return -1; ctx = be_get_context(); be_push_ref(ctx, keypad_js_cb_ref); duk_push_int(ctx, param->code); duk_push_int(ctx, param->value); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); aos_free(param); return 0; } static int keypad_event_callback(keypad_code_t code, int value) { keypad_notify_t *param = aos_malloc(sizeof(keypad_notify_t)); if (!param) return -1; param->code = code; param->value = value; amp_task_schedule_call(keypad_notify_callback, param); return 0; } static duk_ret_t native_keypad_on(duk_context *ctx) { int ret = -1; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } duk_dup(ctx, 0); keypad_js_cb_ref = be_ref(ctx); ret = amp_hal_keypad_event_register(keypad_event_callback); if (ret < 0) { amp_error(MOD_STR, "amp_hal_keypad_event_register fail!"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_keypad_open(duk_context *ctx) { //amp_hal_keypad_init(); duk_push_int(ctx, 0); return 1; } static duk_ret_t native_keypad_close(duk_context *ctx) { //amp_hal_keypad_finalize(); duk_push_int(ctx, 0); return 1; } void module_keypad_register(void) { amp_debug(MOD_STR, "module_keypad_register"); duk_context *ctx = be_get_context(); duk_push_object(ctx); duk_push_c_function(ctx, native_keypad_open, 1); duk_put_prop_string(ctx, -2, "open"); duk_push_c_function(ctx, native_keypad_on, 1); duk_put_prop_string(ctx, -2, "on"); duk_push_c_function(ctx, native_keypad_close, 1); duk_put_prop_string(ctx, -2, "close"); duk_put_prop_string(ctx, -2, "Keypad"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/keypad/module_keypad.c
C
apache-2.0
2,347
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "be_inl.h" #include "amp_location.h" #include "aos_network.h" #define MOD_STR "LOCATION" #define WIFI_SCAN_INFO_LEN 2048 #define WIFI_ACCESS_INFO_LEN 128 #define LBS_SCAN_INFO_LEN 2048 #define LBS_ACCESS_INFO_LEN 128 static char wifi_scan_info[WIFI_SCAN_INFO_LEN]; static char wifi_access_info[WIFI_ACCESS_INFO_LEN]; static char lbs_scan_info[LBS_SCAN_INFO_LEN]; static char lbs_access_info[LBS_ACCESS_INFO_LEN]; static duk_ret_t native_location_access_wifi_info(duk_context *ctx) { #if defined(AMP_N58) int ret = -1; amp_wifi_info_t wifi_info; memset(&wifi_info, 0, sizeof(wifi_info)); ret = amp_location_access_wifi_info(&wifi_info); if (ret != 0) { amp_debug(MOD_STR, "get location wifi info failed"); goto out; } memset(wifi_access_info, 0, sizeof(wifi_access_info)); snprintf(wifi_access_info, sizeof(wifi_access_info), "%02x:%02x:%02x:%02x:%02x:%02x,%d,%s", wifi_info.mac[0], wifi_info.mac[1], wifi_info.mac[2], wifi_info.mac[3], wifi_info.mac[4], wifi_info.mac[5], wifi_info.rssi, strlen(wifi_info.ssid) > 0 ? wifi_info.ssid : "TPLink"); duk_push_lstring(ctx, wifi_access_info, strlen(wifi_access_info)); return 1; out: duk_push_int(ctx, ret); #endif return 1; } static duk_ret_t native_location_scaned_wifi_info(duk_context *ctx) { #if defined(AMP_N58) int ret = -1; scanned_wifi_info_t scaned_info; amp_wifi_info_t *wifi_info; int len = 0; int i; memset(&scaned_info, 0, sizeof(scaned_info)); ret = amp_location_scaned_wifi_info(&scaned_info); if (ret != 0) { amp_debug(MOD_STR, "get location wifi info failed"); goto out; } memset(wifi_scan_info, 0, sizeof(wifi_scan_info)); for (i = 0; i < scaned_info.num; i++) { wifi_info = &scaned_info.wifi_info[i]; if (i == 0) { len += snprintf(wifi_scan_info + len, WIFI_SCAN_INFO_LEN - len, "%02x:%02x:%02x:%02x:%02x:%02x,%d,%s", wifi_info->mac[0], wifi_info->mac[1], wifi_info->mac[2], wifi_info->mac[3], wifi_info->mac[4], wifi_info->mac[5], wifi_info->rssi, strlen(wifi_info->ssid) > 0 ? wifi_info->ssid : "TPLink"); } else { len += snprintf(wifi_scan_info + len, WIFI_SCAN_INFO_LEN - len, "|%02x:%02x:%02x:%02x:%02x:%02x,%d,%s", wifi_info->mac[0], wifi_info->mac[1], wifi_info->mac[2], wifi_info->mac[3], wifi_info->mac[4], wifi_info->mac[5], wifi_info->rssi, strlen(wifi_info->ssid) > 0 ? wifi_info->ssid : "TPLink"); } } duk_push_lstring(ctx, wifi_scan_info, strlen(wifi_scan_info)); return 1; out: duk_push_int(ctx, ret); #endif return 1; } static duk_ret_t native_location_access_lbs_info(duk_context *ctx) { int ret = -1; amp_locator_info_t locator_info; int i; ret = amp_get_locator_info(&locator_info); if (ret != 0) { amp_debug(MOD_STR, "get location wifi lbs failed"); goto out; } duk_push_object(ctx); duk_push_number(ctx, locator_info.cellid); duk_put_prop_string(ctx, -2, "cellid"); duk_push_number(ctx, locator_info.lac); duk_put_prop_string(ctx, -2, "lac"); duk_push_string(ctx, locator_info.mcc); duk_put_prop_string(ctx, -2, "mcc"); duk_push_string(ctx, locator_info.mnc); duk_put_prop_string(ctx, -2, "mnc"); duk_push_number(ctx, locator_info.signal); duk_put_prop_string(ctx, -2, "signal"); return 1; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_location_near_lbs_info(duk_context *ctx) { // int ret = -1; // scanned_locator_info_t nearbts; // int i; // ret = HAL_Get_Scanned_LocatorInfo(&nearbts); // if (ret != 0) { // amp_debug(MOD_STR, "get location wifi lbs failed"); // goto out; // } // duk_idx_t arr_idx = duk_push_array(ctx); // for (i = 0; i < nearbts.num; i++) { // duk_push_object(ctx); // duk_push_number(ctx, nearbts.locator_info[i].cellid); // duk_put_prop_string(ctx, -2, "cellid"); // duk_push_number(ctx, nearbts.locator_info[i].lac); // duk_put_prop_string(ctx, -2, "lac"); // duk_push_string(ctx, nearbts.locator_info[i].mcc); // duk_put_prop_string(ctx, -2, "mcc"); // duk_push_string(ctx, nearbts.locator_info[i].mnc); // duk_put_prop_string(ctx, -2, "mnc"); // duk_push_number(ctx, nearbts.locator_info[i].rsrp); // duk_put_prop_string(ctx, -2, "rsrp"); // } // return 1; // out: // duk_push_int(ctx, ret); // return 1; } void module_location_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("accessedWifi", native_location_access_wifi_info, 0); AMP_ADD_FUNCTION("scannedWifi", native_location_scaned_wifi_info, 0); AMP_ADD_FUNCTION("accessedLbs", native_location_access_lbs_info, 0); AMP_ADD_FUNCTION("nearbts", native_location_near_lbs_info, 0); duk_put_prop_string(ctx, -2, "LOCATION"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/location/module_location.c
C
apache-2.0
5,226
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "be_inl.h" #include "ota_agent.h" #include "ota_import.h" #include "module_aiot.h" #include "app_upgrade.h" #define MOD_STR "APP_OTA" static ota_service_t customer_ota_ctx = {0}; static ota_store_module_info_t customer_module_info[3]; static aos_task_t user_module_ota_task = NULL; typedef struct ota_package_info { int res; int js_cb_ref; unsigned int length; char version[64]; char module_name[64]; int hash_type; char hash[64]; char store_path[64]; char install_path[64]; char url[256]; } ota_package_info_t; static void ota_install_notify(void *pdata) { ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, ota_package_info->js_cb_ref); duk_push_int(ctx, ota_package_info->res); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); aos_free(ota_package_info); } static void ota_install_handler(void *pdata) { int res = -1; int js_cb_ref; ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; /* clear jsengine timer, distory js app*/ amp_module_free(); app_js_stop(); res = ota_install_jsapp(&customer_ota_ctx, ota_package_info->store_path, ota_package_info->length, ota_package_info->install_path); if (res < 0) { amp_error(MOD_STR, "module install failed!"); } else { /*启动app.js*/ res = ota_load_jsapp(&customer_ota_ctx); if(res < 0) { amp_error(MOD_STR, "module load failed!"); } } ota_package_info->res = res; amp_task_schedule_call(ota_install_notify, ota_package_info); aos_task_exit(0); } static duk_ret_t native_ota_upgrade(duk_context *ctx) { int res = -1; int js_cb_ref; aos_task_t ota_install_task; ota_package_info_t *ota_package_info = NULL; if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer and function)"); goto out; } /* get verify info */ duk_get_prop_string(ctx, 0, "length"); duk_get_prop_string(ctx, 0, "store_path"); duk_get_prop_string(ctx, 0, "install_path"); unsigned int length = duk_get_int(ctx, -3); const char *store_path = duk_get_string(ctx, -2); const char *install_path = duk_get_string(ctx, -1); duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); ota_package_info = aos_malloc(sizeof(ota_package_info_t)); if (!ota_package_info) { amp_error(MOD_STR, "alloc device notify param fail"); return; } memset(ota_package_info, 0x00, sizeof(ota_package_info_t)); ota_package_info->length = length; ota_package_info->js_cb_ref = js_cb_ref; strncpy(ota_package_info->store_path, store_path, sizeof(ota_package_info->store_path)); strncpy(ota_package_info->install_path, install_path, sizeof(ota_package_info->install_path)); res = aos_task_new_ext(&ota_install_task, "amp ota install task", ota_install_handler, ota_package_info, 1024 * 10, AOS_DEFAULT_APP_PRI); if (res != 0) { amp_warn(MOD_STR, "iot create task failed"); aos_free(ota_package_info); goto out; } out: duk_push_int(ctx, res); return 1; } static void ota_verify_notify(void *pdata) { ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, ota_package_info->js_cb_ref); duk_push_int(ctx, ota_package_info->res); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); aos_free(ota_package_info); } static void ota_verify_handler(void *pdata) { int res = -1; int js_cb_ref; ota_boot_param_t ota_param = {0}; ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; memset(&ota_param, 0, sizeof(ota_boot_param_t)); ota_param.len = ota_package_info->length; ota_param.hash_type = ota_package_info->hash_type; strncpy(ota_param.hash, ota_package_info->hash, strlen(ota_package_info->hash)); res = ota_verify_fsfile(&ota_param, ota_package_info->store_path); if (res < 0) { amp_error(MOD_STR, "amp jsota verified failed!"); } ota_package_info->res = res; amp_task_schedule_call(ota_verify_notify, ota_package_info); aos_task_exit(0); } static duk_ret_t native_ota_verify(duk_context *ctx) { int res = -1; int js_cb_ref; aos_task_t ota_verify_task; ota_package_info_t *ota_package_info = NULL; if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer and function)"); goto out; } /* get verify info */ duk_get_prop_string(ctx, 0, "length"); duk_get_prop_string(ctx, 0, "hash_type"); duk_get_prop_string(ctx, 0, "hash"); duk_get_prop_string(ctx, 0, "store_path"); unsigned int length = duk_get_int(ctx, -4); const char *hash_type = duk_get_string(ctx, -3); const char *hash = duk_get_string(ctx, -2); const char *store_path = duk_get_string(ctx, -1); duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); ota_package_info = aos_malloc(sizeof(ota_package_info_t)); if (!ota_package_info) { amp_error(MOD_STR, "alloc device notify param fail"); return; } memset(ota_package_info, 0x00, sizeof(ota_package_info_t)); ota_package_info->length = length; ota_package_info->js_cb_ref = js_cb_ref; if (strcmp(hash_type, "null") == 0) { ota_package_info->hash_type = 0; } else if(strcmp(hash_type, "md5") == 0) { ota_package_info->hash_type = 2; } else if(strcmp(hash_type, "sha256") == 0) { ota_package_info->hash_type = 1; } else { ota_package_info->hash_type = 3; } strncpy(ota_package_info->hash, hash, sizeof(ota_package_info->hash)); strncpy(ota_package_info->store_path, store_path, sizeof(ota_package_info->store_path)); res = aos_task_new_ext(&ota_verify_task, "amp ota verify task", ota_verify_handler, ota_package_info, 1024 * 10, AOS_DEFAULT_APP_PRI); if (res != 0) { amp_warn(MOD_STR, "iot create task failed"); aos_free(ota_package_info); goto out; } out: duk_push_int(ctx, res); return 1; } static void ota_download_notify(void *pdata) { ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, ota_package_info->js_cb_ref); duk_push_int(ctx, ota_package_info->res); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); aos_free(ota_package_info); } static void ota_download_handler(void *pdata) { int res = -1; int js_cb_ref; ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; res = ota_download_store_fs_start(ota_package_info->url, strlen(ota_package_info->url), ota_package_info->store_path, customer_ota_ctx.report_func.report_status_cb, customer_ota_ctx.report_func.param); if (res < 0) { amp_error(MOD_STR, "amp jsota download file failed!"); } ota_package_info->res = res; amp_task_schedule_call(ota_download_notify, ota_package_info); aos_task_exit(0); } static duk_ret_t native_ota_download(duk_context *ctx) { int res = -1; int js_cb_ref; aos_task_t ota_download_task; ota_package_info_t *ota_package_info = NULL; if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer and function)"); goto out; } /* get report info */ duk_get_prop_string(ctx, 0, "url"); duk_get_prop_string(ctx, 0, "store_path"); const char *url = duk_get_string(ctx, -2); const char *store_path = duk_get_string(ctx, -1); duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); ota_package_info = aos_malloc(sizeof(ota_package_info_t)); if (!ota_package_info) { amp_error(MOD_STR, "alloc device notify param fail"); return; } memset(ota_package_info, 0x00, sizeof(ota_package_info_t)); ota_package_info->js_cb_ref = js_cb_ref; strncpy(ota_package_info->url, url, sizeof(ota_package_info->url)); strncpy(ota_package_info->store_path, store_path, sizeof(ota_package_info->store_path)); res = aos_task_new_ext(&ota_download_task, "amp ota download task", ota_download_handler, ota_package_info, 1024 * 10, AOS_DEFAULT_APP_PRI); if (res != 0) { amp_warn(MOD_STR, "iot create task failed"); aos_free(ota_package_info); goto out; } out: duk_push_int(ctx, res); return 1; } static duk_ret_t native_ota_report(duk_context *ctx) { int res = -1; int js_cb_ref; iot_device_handle_t *iot_device_handle = NULL; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (pointer and function)"); goto out; } /* get report info */ duk_get_prop_string(ctx, 0, "device_handle"); duk_get_prop_string(ctx, 0, "product_key"); duk_get_prop_string(ctx, 0, "device_name"); duk_get_prop_string(ctx, 0, "module_name"); duk_get_prop_string(ctx, 0, "version"); iot_device_handle = duk_get_pointer(ctx, -5); const char *productkey = duk_get_string(ctx, -4); const char *devicename = duk_get_string(ctx, -3); const char *modulename = duk_get_string(ctx, -2); const char *ver = duk_get_string(ctx, -1); duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); amp_warn(MOD_STR, "js report ver!"); res = ota_transport_inform(iot_device_handle->mqtt_handle, productkey, devicename, modulename, ver); if (res < 0) { amp_error(MOD_STR, "amp jsota report ver failed!"); } out: duk_push_int(ctx, res); return 1; } static void ota_trigger_notify(void *pdata) { ota_package_info_t *ota_package_info = (ota_package_info_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, ota_package_info->js_cb_ref); duk_push_object(ctx); duk_push_int(ctx, (unsigned int)ota_package_info->length); duk_put_prop_string(ctx, -2, "length"); duk_push_string(ctx, ota_package_info->module_name); duk_put_prop_string(ctx, -2, "module_name"); duk_push_string(ctx, ota_package_info->version); duk_put_prop_string(ctx, -2, "version"); duk_push_string(ctx, ota_package_info->url); duk_put_prop_string(ctx, -2, "url"); duk_push_string(ctx, ota_package_info->hash); duk_put_prop_string(ctx, -2, "hash"); if (ota_package_info->hash_type == 0) { duk_push_string(ctx, "null"); } else if (ota_package_info->hash_type == 1) { duk_push_string(ctx, "sha256"); } else if (ota_package_info->hash_type == 2) { duk_push_string(ctx, "md5"); } else { duk_push_string(ctx, "sha512"); } duk_put_prop_string(ctx, -2, "hash_type"); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); aos_free(ota_package_info); } /* system image upgrade */ static int32_t customer_upgrade_cb(void *pctx, char *ver, char *module_name, void *args) { int32_t ret = OTA_TRANSPORT_PAR_FAIL; ota_package_info_t *ota_package_info = NULL; ota_boot_param_t ota_param = {0}; aos_task_t customer_ota_task; if ((pctx == NULL) || (ver == NULL) || (module_name == NULL) || (args == NULL)) { amp_error(MOD_STR, "amp:ota triggered param err!"); return ret; } if (strncmp(module_name, "system", strlen(module_name)) == 0) { ret = 0; int current_ver[128] = {0}; amp_app_version_get(current_ver); if (strncmp(ver, current_ver, strlen(ver)) <= 0) { ret = OTA_TRANSPORT_VER_FAIL; amp_error(MOD_STR, "amp ota version too old!"); } else { amp_debug(MOD_STR, "ota version:%s is coming, if OTA upgrade or not ?\n", ver); /* clear jsengine timer, distory js app*/ if (aos_task_new_ext(&customer_ota_task, "amp_customer_ota", internal_sys_upgrade_start, (void *)pctx, 1024 * 8, AOS_DEFAULT_APP_PRI) != 0) { amp_debug(MOD_STR, "internal ota task create failed!"); ret = OTA_TRANSPORT_PAR_FAIL; } amp_debug(MOD_STR, "app management center start"); } } else { /*读取ota 触发时云端下发的文件信息*/ ret = ota_read_parameter(&ota_param); if (ret < 0) { amp_error(MOD_STR, "get store ota param info failed\n"); } ota_package_info = aos_malloc(sizeof(ota_package_info_t)); if (!ota_package_info) { amp_error(MOD_STR, "alloc device notify param fail"); return; } ota_package_info->js_cb_ref = (int)args; ota_package_info->length = ota_param.len; ota_package_info->hash_type = ota_param.hash_type; strncpy(ota_package_info->url, ota_param.url, sizeof(ota_package_info->url)); strncpy(ota_package_info->version, ver, strlen(ver)); strncpy(ota_package_info->module_name, module_name, strlen(module_name)); strncpy(ota_package_info->hash, ota_param.hash, sizeof(ota_package_info->hash)); amp_task_schedule_call(ota_trigger_notify, ota_package_info); } } static duk_ret_t native_ota_init(duk_context *ctx) { int res = -1; int js_cb_ref; int productkey_len = IOTX_PRODUCT_KEY_LEN; int productsecret_len = IOTX_PRODUCT_SECRET_LEN; int devicename_len = IOTX_DEVICE_NAME_LEN; int devicesecret_len = IOTX_DEVICE_SECRET_LEN; iot_device_handle_t *iot_device_handle = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (pointer and function)"); goto out; } ota_service_param_reset(&customer_ota_ctx); /* get device info */ aos_kv_get(AMP_CUSTOMER_PRODUCTKEY, customer_ota_ctx.pk, &productkey_len); aos_kv_get(AMP_CUSTOMER_PRODUCTSECRET, customer_ota_ctx.ps, &productsecret_len); aos_kv_get(AMP_CUSTOMER_DEVICENAME, customer_ota_ctx.dn, &devicename_len); aos_kv_get(AMP_CUSTOMER_DEVICESECRET, customer_ota_ctx.ds, &devicesecret_len); memset(customer_module_info, 0x00, sizeof(customer_module_info)); iot_device_handle = duk_get_pointer(ctx, 0); customer_ota_ctx.mqtt_client = (void *)iot_device_handle->mqtt_handle; duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); ota_register_module_store(&customer_ota_ctx, customer_module_info, 3); ota_register_trigger_msg_cb(&customer_ota_ctx, (void *)customer_upgrade_cb, js_cb_ref); ota_set_module_information(&customer_ota_ctx, "system", OS_APP_PATH, OTA_UPGRADE_ALL); /* init ota service */ res = ota_service_init(&customer_ota_ctx); if (res < 0) { amp_error(MOD_STR, "customer ota init failed!"); } else { amp_warn(MOD_STR, "customer ota init success!"); } /*custom report version*/ int current_ver[128] = {0}; amp_app_version_get(current_ver); res = ota_report_module_version(&customer_ota_ctx, "system", current_ver); if (res < 0) { amp_error(MOD_STR, "amp ota report ver failed!"); } out: duk_push_int(ctx, res); return 1; } void module_app_ota_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("otaInit", native_ota_init, 2); AMP_ADD_FUNCTION("otaDownload", native_ota_download, 2); AMP_ADD_FUNCTION("otaVerify", native_ota_verify, 2); AMP_ADD_FUNCTION("otaReport", native_ota_report, 1); AMP_ADD_FUNCTION("otaUpgrade", native_ota_upgrade, 2); duk_put_prop_string(ctx, -2, "APPOTA"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/ota/module_appota.c
C
apache-2.0
16,126
/* * Copyright (C) 2015-2020 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "be_inl.h" #include "alipay_box_sdk.h" #include "alipay_box_sdk_api.h" #include "alipay_xp_sdk_api.h" #include "alipay_xp_sdk_ex_api.h" #include "ant_kal.h" #ifdef CUSTOM_PROFILE #include "custom_profile.h" #endif #define MOD_STR "PAYBOX" #define PAYBOX_APP_VERSION "1.2.1" typedef struct { const ant_char* mqtt_product_key; const ant_char* supplier_id; const ant_char* item_id; const ant_char* box_model; const ant_char* box_version; #ifdef USE_SERVER_XP const ant_char *xp_device_secret; const ant_char* xp_product_key; const ant_char* xp_product_secret; #endif } alipay_box_sdk_profile_t; typedef struct paybox_module { uint8_t flag; //uint8_t data[128]; int js_cb_ref; } paybox_module_t; static paybox_module_t g_paybox_module; static void (*g_network_status_cb)(int); static ant_char *__paybox_dn_dynamic_get(void) { #define XP_DN_MAX 200 static ant_char s_dn[XP_DN_MAX+1] = {0}; if(0 == strlen(s_dn)){ ant_s32 ret = ant_system_get_sn(s_dn,XP_DN_MAX); if(0 != ret){ ant_memset(s_dn, 0x0, XP_DN_MAX); amp_error(MOD_STR, "%s: get sn null,ret:%d", __func__,ret); return NULL; } } amp_debug(MOD_STR, "%s: %s", __func__, s_dn); return s_dn; } static char *__paybox_string_duplicate(char *src) { char *dst; size_t len = 0; if (src == NULL) { return NULL; } len = strlen(src); dst = aos_malloc(len+1); if (dst == NULL) { return NULL; } memcpy(dst, src, len); dst[len] = '\0'; return dst; } static int native_paybox_ota_attach(void) { static xp_ota_api_t pos_api = {0}; pos_api.start = ant_fota_start; pos_api.w = ant_fota_write; pos_api.upgrade = ant_fota_upgrade; pos_api.get_max_size = ant_fota_get_max; pos_api.erase_block = ant_fota_block_erase; pos_api.end = ant_fota_end; pos_api.get_security = ant_fota_get_security; return alipay_xp_sdk_fota_api_attach(pos_api); } static void native_paybox_event_notify(char *name) { duk_context *ctx; if (g_paybox_module.flag == 0) { return; } ctx = be_get_context(); be_push_ref(ctx, g_paybox_module.js_cb_ref); duk_push_string(ctx, name); duk_push_object(ctx); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void native_paybox_event_init_notify(char *name, alipay_box_sdk_init_event_t *data) { duk_context *ctx; if (name == NULL) { return; } if (data == NULL) { return; } if (g_paybox_module.flag == 0) { return; } ctx = be_get_context(); be_push_ref(ctx, g_paybox_module.js_cb_ref); duk_push_string(ctx, name); duk_push_object(ctx); duk_push_int(ctx, data->result); duk_put_prop_string(ctx, -2, "result"); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void native_paybox_event_login_notify(char *name, alipay_box_login_event_t *data) { duk_context *ctx; if (name == NULL) { return; } if (data == NULL) { return; } if (g_paybox_module.flag == 0) { return; } ctx = be_get_context(); be_push_ref(ctx, g_paybox_module.js_cb_ref); duk_push_string(ctx, name); duk_push_object(ctx); duk_push_int(ctx, data->bind_status); duk_put_prop_string(ctx, -2, "status"); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void native_paybox_event_trade_notify(char *name, alipay_box_trade_event_t *data) { duk_context *ctx; if (name == NULL) { return; } if (data == NULL) { return; } if (g_paybox_module.flag == 0) { return; } ctx = be_get_context(); be_push_ref(ctx, g_paybox_module.js_cb_ref); duk_push_string(ctx, name); duk_push_object(ctx); duk_push_string(ctx, data->trade_id); duk_put_prop_string(ctx, -2, "tradeid"); duk_push_string(ctx, data->money); duk_put_prop_string(ctx, -2, "amount"); duk_push_int(ctx, data->money_switch); duk_put_prop_string(ctx, -2, "moneySwitch"); #ifdef ALIPAY_BOX_ISV duk_push_string(ctx, data->prefix); duk_put_prop_string(ctx, -2, "prefix"); duk_push_string(ctx, data->suffix); duk_put_prop_string(ctx, -2, "suffix"); #else duk_push_string(ctx, data->file_id); duk_put_prop_string(ctx, -2, "fileId"); #endif if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void native_paybox_sdk_event_handler(alipay_box_sdk_event_t *event, void *user_data) { amp_debug(MOD_STR, "%s: receive event: %d", __func__, event->event_id); switch(event->event_id) { case ALIPAY_BOX_EVENT_SDK_INIT: amp_debug(MOD_STR, "%s: alipay_box_sdk init result: %d", __func__, event->data->init.result); native_paybox_event_init_notify("init", &(event->data->init)); break; case ALIPAY_BOX_EVENT_SERVER_CONNECTED: amp_debug(MOD_STR, "Paybox server connected"); native_paybox_event_notify("connect"); break; case ALIPAY_BOX_EVENT_SERVER_DISCONNECTED: amp_debug(MOD_STR, "Paybox server disconnected"); native_paybox_event_notify("disconnect"); break; case ALIPAY_BOX_EVENT_LOGIN: amp_debug(MOD_STR, "Paybox login with '%s'", (event->data->login.bind_status == 1) ? "BIND" : "UNBIND"); native_paybox_event_login_notify("login", &event->data->login); break; case ALIPAY_BOX_EVENT_BIND: amp_debug(MOD_STR, "Paybox bind"); native_paybox_event_notify("bind"); break; case ALIPAY_BOX_EVENT_UNBIND: amp_debug(MOD_STR, "Paybox unbind"); native_paybox_event_notify("unbind"); break; case ALIPAY_BOX_EVENT_TRADE: { alipay_box_trade_event_t *trade = &event->data->trade; amp_debug(MOD_STR, "Paybox trade event: %s", trade->money); native_paybox_event_trade_notify("trade", &event->data->trade); } break; default: break; } } void native_paybox_network_status_register(void (*cb)(int)) { g_network_status_cb = cb; amp_info(MOD_STR, "register network status callback success"); } static void native_paybox_event_handler(alipay_box_event_t *event, void *usr_data) { amp_debug(MOD_STR, "%s: receive event %d", __func__, event->event_id - ANT_MSG_ID_IDX_BASE); switch (event->event_id) { case ANT_EVENT_KEY: amp_debug(MOD_STR, "Paybox key"); break; case ANT_EVENT_TIMESYNC: amp_debug(MOD_STR, "Paybox time sync"); //alipay_box_sdk_init(native_paybox_sdk_event_handler, NULL, ALIPAY_BOX_MODE_NORMAL); break; case ANT_EVENT_NETWORK: amp_debug(MOD_STR, "Paybox network"); if (g_network_status_cb) g_network_status_cb(1); break; case ANT_EVENT_IDLE_EVENT: amp_debug(MOD_STR, "Paybox idle"); break; case ANT_EVENT_BATTERY_CHARGE_STATUS: amp_debug(MOD_STR, "Paybox battery charge status"); break; case ANT_EVENT_KEY_FUNC_LONG_PRESSED: amp_debug(MOD_STR, "Paybox key long press"); break; default: break; } } static int native_paybox_shutdown_handler(void) { amp_debug(MOD_STR, "Paybox shut down"); if (g_paybox_module.flag == 1) { native_paybox_event_notify("shutdown"); } return 1; } static duk_ret_t native_paybox_open(duk_context *ctx) { alipay_box_sdk_profile_t profile; alipay_xp_sdk_device_config_t devcfg; char *str; ant_char *p_dn = NULL; static char init_ok = 0; char dn_static = 1; int ret = -1; if (init_ok) { amp_warn(MOD_STR, "paybox init already, ignore"); ret = 0; goto out; } p_dn = __paybox_dn_dynamic_get(); if(!p_dn) { dn_static = 0; } if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object and function"); ret = -1; goto out; } duk_get_prop_string(ctx, 0, "mqttPrductKey"); duk_get_prop_string(ctx, 0, "supplierId"); duk_get_prop_string(ctx, 0, "itemId"); if (!duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "Parameter 1 must be an object like {mqttPrductKey: string, supplierId: string, itemId: string, " "boxModel: string, boxVersion: string, xpPrductKey: string, xpPrductSecret: string "); ret = -1; goto out; } str = (char*)duk_get_string(ctx, -3); profile.mqtt_product_key = __paybox_string_duplicate(str); str = (char*)duk_get_string(ctx, -2); profile.supplier_id = __paybox_string_duplicate(str); str = (char*)duk_get_string(ctx, -1); profile.item_id = __paybox_string_duplicate(str); duk_pop_3(ctx); duk_get_prop_string(ctx, 0, "boxModel"); duk_get_prop_string(ctx, 0, "boxVersion"); if (!duk_is_string(ctx, -2) || !duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "Parameter 1 must be an object like {mqttPrductKey: string, supplierId: string, itemId: string, " "boxModel: string, boxVersion: string, xpPrductKey: string, xpPrductSecret: string "); ret = -1; goto out; } str = (char*)duk_get_string(ctx, -2); profile.box_model = __paybox_string_duplicate(str); str = (char*)duk_get_string(ctx, -1); profile.box_version = __paybox_string_duplicate(str); duk_pop_2(ctx); duk_get_prop_string(ctx, 0, "xpPrductKey"); duk_get_prop_string(ctx, 0, "xpPrductSecret"); duk_get_prop_string(ctx, 0, "xpDeviceSecret"); if (!duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "Parameter 1 must be an object like {mqttPrductKey: string, supplierId: string, itemId: string, " "boxModel: string, boxVersion: string, xpPrductKey: string, xpPrductSecret: string "); ret = -1; goto out; } str = (char*)duk_get_string(ctx, -3); profile.xp_product_key = __paybox_string_duplicate(str); str = (char*)duk_get_string(ctx, -2); profile.xp_product_secret = __paybox_string_duplicate(str); str = (char *)duk_get_string(ctx, -1); profile.xp_device_secret = __paybox_string_duplicate(str); duk_pop_3(ctx); #if 0 //may be required in the future if (ret = alipay_box_sdk_set_mqtt_product_key(profile.mqtt_product_key)) { amp_warn(MOD_STR, "alipay_box_sdk_set_mqtt_product_key failed!"); ret = -1; goto out; } if (strcmp(profile.supplier_id, "null") && (ret = alipay_box_sdk_set_supplier_id(profile.supplier_id)) != 0) { amp_warn(MOD_STR, "alipay_box_sdk_set_supplier_id failed!"); ret = -1; goto out; } if (strcmp(profile.item_id, "null") && (ret = alipay_box_sdk_set_item_id(profile.item_id)) != 0) { amp_warn(MOD_STR, "alipay_box_sdk_set_item_id failed!"); ret = -1; goto out; } if (ret = alipay_box_sdk_set_box_model(profile.box_model)) { amp_warn(MOD_STR, "alipay_box_sdk_set_box_model failed!"); ret = -1; goto out; } if (ret = alipay_box_sdk_set_box_version(profile.box_version)) { amp_warn(MOD_STR, "alipay_box_sdk_set_box_version failed!"); ret = -1; goto out; } if (ret = alipay_box_sdk_set_xp_product_key(profile.xp_product_key)) { amp_warn(MOD_STR, "alipay_box_sdk_set_xp_product_key failed!"); ret = -1; goto out; } if (ret = alipay_box_sdk_set_xp_product_secret(profile.xp_product_secret)) { amp_warn(MOD_STR, "alipay_box_sdk_set_xp_product_secret failed!"); ret = -1; goto out; } #endif memset(&devcfg, 0, sizeof(devcfg)); devcfg.product_key = profile.xp_product_key; devcfg.product_secret = profile.xp_product_secret; devcfg.device_secret = profile.xp_device_secret; devcfg.version = PAYBOX_APP_VERSION; devcfg.device_name = p_dn; devcfg.dn_api = __paybox_dn_dynamic_get; if (!dn_static && !devcfg.dn_api) { amp_error(MOD_STR, "deviname is not found and devicename dynamic is null"); ret = -1; goto out; } ret = alipay_xp_sdk_device_init(devcfg); if (ret) { amp_error(MOD_STR, "xp sdk device init fail %d", ret); ret = -1; goto out; } ret = native_paybox_ota_attach(); if (ret) { amp_error(MOD_STR, "paybox ota attach fail %d", ret); ret = -1; goto out; } ret = alipay_sdk_init(native_paybox_event_handler, native_paybox_sdk_event_handler, native_paybox_shutdown_handler, NULL, NULL, NULL, ALIPAY_BOX_MODE_NORMAL); if (ret) { amp_error(MOD_STR, "alipaybox sdk init fail %d", ret); ret = -1; goto out; } amp_debug(MOD_STR, "%s: alipay sdk init success", __func__); init_ok = 1; duk_push_int(ctx, 0); return 1; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_paybox_on_data(duk_context *ctx) { int ret = -1; if (!duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle, function"); goto out; } duk_dup(ctx, 1); g_paybox_module.js_cb_ref = be_ref(ctx); g_paybox_module.flag = 1; ret = 1; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_paybox_close(duk_context *ctx) { int ret = -1; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number"); goto out; } memset(&g_paybox_module, 0, sizeof(g_paybox_module)); duk_push_int(ctx, 0); return 1; out: duk_push_int(ctx, ret); return 1; } static void native_paybox_clean(void) { } void module_paybox_register(void) { duk_context *ctx = be_get_context(); amp_module_free_register(native_paybox_clean); memset(&g_paybox_module, 0, sizeof(g_paybox_module)); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_paybox_open, 2); AMP_ADD_FUNCTION("on", native_paybox_on_data, 2); AMP_ADD_FUNCTION("close", native_paybox_close, 1); duk_put_prop_string(ctx, -2, "PAYBOX"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/paybox/module_paybox.c
C
apache-2.0
14,904
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "be_inl.h" #include "smartcard.h" #define MOD_STR "Smartcard" static duk_ret_t native_smartcard_init(duk_context *ctx) { int ret; ret = smartcard_init(); if (ret) { amp_error(MOD_STR, "smartcard init fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_smartcard_deinit(duk_context *ctx) { smartcard_deinit(); duk_push_int(ctx, 0); return 1; } static duk_ret_t native_smartcard_select(duk_context *ctx) { int ret = -1; int type; smartcard_change_operator_t _operator; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } type = duk_get_int(ctx, 0); switch (type) { case 1: _operator = SMARTCARD_CHANGE_TO_CM; break; case 2: _operator = SMARTCARD_CHANGE_TO_CU; break; case 3: _operator = SMARTCARD_CHANGE_TO_CT; break; case 4: _operator = SMARTCARD_CHANGE_TO_NEXT; break; default: amp_error(MOD_STR, "unknown operator %d", type); return -1; } ret = smartcard_change_operator(type); if (ret) { amp_error(MOD_STR, "change operator %d fail %d", type, ret); } out: duk_push_int(ctx, ret); return 1; } static void module_smartcard_clean(void) { smartcard_deinit(); } void module_smartcard_register(void) { duk_context *ctx = be_get_context(); amp_module_free_register(module_smartcard_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("init", native_smartcard_init, 0); AMP_ADD_FUNCTION("deinit", native_smartcard_deinit, 0); AMP_ADD_FUNCTION("select", native_smartcard_select, 1); duk_put_prop_string(ctx, -2, "smartcard"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/smartcard/module_smartcard.c
C
apache-2.0
2,003
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_config.h" #include "amp_defines.h" #include "und.h" #include "be_inl.h" #define MOD_STR "UND" /***************************************************************************** * Function: native_fs_issupport * Description: js native addon for FILE.issupport() * check if the js FILE object is support * Called by: js api * Input: none * Output: 1 :support ,0 :not support *****************************************************************************/ static duk_ret_t native_und_start(duk_context *ctx) { int32_t ret = -1; ret = und_init(); if (ret != 0) { amp_warn(MOD_STR, "und init failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_read * Description: js native addon for FILE.read(filepath) * read the file content * Called by: js api * Input: filepath : string * Output: a String object which the file content is *****************************************************************************/ static duk_ret_t native_und_update(duk_context *ctx) { int32_t ret = -1; int32_t cap_idx; int32_t reason_code; if (!duk_is_number(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } cap_idx = duk_get_int(ctx, 0); reason_code = duk_get_int(ctx, 1); ret = und_update_statis(cap_idx, reason_code); if (ret != 0) { amp_warn(MOD_STR, "und update statis failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_delete * Description: js native addon for FILE.delete(filepath) * delete the file * Called by: js api * Input: filepath : string * Output: 0 delete ok ;other delete fail *****************************************************************************/ static duk_ret_t native_und_stop(duk_context *ctx) { int32_t ret = -1; ret = und_deinit(); if (ret != 0) { amp_warn(MOD_STR, "und deinit failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } void module_und_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("start", native_und_start, 0); AMP_ADD_FUNCTION("update", native_und_update, 2); AMP_ADD_FUNCTION("stop", native_und_stop, 0); duk_put_global_string(ctx, "UND"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/advanced/und/module_und.c
C
apache-2.0
2,668
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ /* #define LOG_NDEBUG 0 */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_adc.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "ADC" static duk_ret_t native_adc_open(duk_context *ctx) { int8_t ret = -1; item_handle_t adc_handle; adc_handle.handle = NULL; adc_dev_t *adc_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_ADC, id, &adc_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!"); goto out; } amp_debug(MOD_STR, "adc handle:%u\n", adc_handle.handle); adc_device = board_get_node_by_handle(MODULE_ADC, &adc_handle); if (NULL == adc_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_adc_init(adc_device); out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_ADC, &adc_handle); } else { duk_push_pointer(ctx, (void *)adc_handle.handle); } return 1; } static duk_ret_t native_adc_close(duk_context *ctx) { int8_t ret = -1; item_handle_t adc_handle; adc_dev_t *adc_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } adc_handle.handle = duk_get_pointer(ctx, 0); adc_device = board_get_node_by_handle(MODULE_ADC, &adc_handle); if (NULL == adc_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_adc_finalize(adc_device); board_disattach_item(MODULE_ADC, &adc_handle); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_adc_read(duk_context *ctx) { int32_t adc_value = -1; item_handle_t adc_handle; adc_dev_t *adc_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } adc_handle.handle = duk_get_pointer(ctx, 0); adc_device = board_get_node_by_handle(MODULE_ADC, &adc_handle); if (NULL == adc_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } (void)aos_hal_adc_raw_value_get(adc_device, (void *)&adc_value, 0); amp_debug(MOD_STR, "adc value: %d\n", adc_value); out: duk_push_int(ctx, adc_value > 0 ? adc_value : -1); return 1; } void module_adc_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_adc_open, 1); AMP_ADD_FUNCTION("read", native_adc_read, 1); AMP_ADD_FUNCTION("close", native_adc_close, 1); duk_put_prop_string(ctx, -2, "ADC"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/adc/module_adc.c
C
apache-2.0
2,895
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "aos_hal_can.h" #include "board_mgr.h" #include "amp_task.h" #include "be_inl.h" #define MOD_STR "CAN" #define CAN_TIMEOUT (0xFFFFFF) #define MAX_CAN_RECV_LEN 8 #define MAX_CAN_PORT 2 typedef struct { can_dev_t *can_device; int js_cb_ref; } can_recv_param_t; typedef struct { uint8_t buf[MAX_CAN_RECV_LEN]; can_frameheader_t rx_header; int js_cb_ref; } can_recv_notify_param_t; static char g_can_close_flag = 0; static char g_can_recv_flag = 0; static aos_sem_t g_can_close_sem = NULL; can_dev_t g_can_handle[MAX_CAN_PORT]; static duk_ret_t native_can_open(duk_context *ctx) { int8_t ret = -1; item_handle_t can_handle; can_handle.handle = NULL; can_dev_t *can_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_CAN, id, &can_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!"); goto out; } amp_debug(MOD_STR, "can handle:%u", can_handle.handle); can_device = board_get_node_by_handle(MODULE_CAN, &can_handle); if (NULL == can_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_can_init(can_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_can_init fail!"); goto out; } g_can_handle[can_device->port] = *can_device; out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_CAN, &can_handle); } else { duk_push_pointer(ctx, (void *)can_handle.handle); } return 1; } static duk_ret_t native_can_close(duk_context *ctx) { int8_t ret = -1; item_handle_t can_handle; can_dev_t *can_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } can_handle.handle = duk_get_pointer(ctx, 0); can_device = board_get_node_by_handle(MODULE_CAN, &can_handle); if (NULL == can_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_can_finalize(can_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_spi_finalize fail!"); goto out; } board_disattach_item(MODULE_CAN, &can_handle); g_can_close_flag = 1; aos_sem_wait(&g_can_close_sem, CAN_TIMEOUT + 50); g_can_close_flag = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_can_send(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t can_handle; can_dev_t *can_device = NULL; can_frameheader_t tx_header; int arr_idx; uint32_t id; uint8_t rtr, dlc; int err = -1; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_array(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle object array"); goto out; } can_handle.handle = duk_get_pointer(ctx, 0); can_device = board_get_node_by_handle(MODULE_CAN, &can_handle); if (NULL == can_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } /* get can_frame header */ duk_get_prop_string(ctx, 1, "id"); duk_get_prop_string(ctx, 1, "rtr"); duk_get_prop_string(ctx, 1, "dlc"); if (!duk_is_number(ctx, -3) || !duk_is_number(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "Parameter 1 must be an object like {id: number, rtr: number, dlc: number"); ret = -2; goto out; } id = duk_get_uint(ctx, -3); rtr = duk_get_uint(ctx, -2); if (rtr > 1) { amp_warn(MOD_STR, "rtr is invalid"); goto out; } dlc = duk_get_uint(ctx, -1); if (dlc > 8) { amp_warn(MOD_STR, "dlc is invalid"); goto out; } duk_pop_3(ctx); tx_header.id = id; tx_header.rtr = rtr; tx_header.dlc = dlc; arr_idx = duk_normalize_index(ctx, 2); len = duk_get_length(ctx, arr_idx); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "data is not number, index: %d", i); duk_pop(ctx); goto out; } data[i] = (uint8_t)duk_get_int(ctx, -1); duk_pop(ctx); } ret = aos_hal_can_send(can_device, &tx_header, data, CAN_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "aos_hal_can_send fail!"); goto out; } err = 0; out: aos_free(data); duk_push_int(ctx, err); return 1; } static void can_recv_notify(void *pdata) { int i = 0; can_recv_notify_param_t *p = (can_recv_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_uint(ctx, p->rx_header.rtr); duk_push_uint(ctx, p->rx_header.id); int arr_idx = duk_push_array(ctx); if(p->rx_header.rtr == 0) { for (i = 0; i < p->rx_header.dlc; i++) { duk_push_int(ctx, p->buf[i]); duk_put_prop_index(ctx, arr_idx, i); } } if (duk_pcall(ctx, 3) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); // aos_free(p); } /************************************************************************************* * Function: udp_recv_routine * Description: create a task for blocking recvfrom call * Called by: **************************************************************************************/ static void can_recv_routine(void *arg) { int ret = -1; can_recv_param_t *recv_param = (can_recv_param_t *)arg; can_dev_t *can_device = (can_dev_t *)recv_param->can_device; can_recv_notify_param_t *p = aos_calloc(1, sizeof(*p)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); duk_context *ctx = be_get_context(); be_unref(ctx, recv_param->js_cb_ref); goto out; } g_can_recv_flag = 1; while(1) { ret = aos_hal_can_recv(can_device, &p->rx_header, p->buf, CAN_TIMEOUT); if (ret == 0) { p->js_cb_ref = recv_param->js_cb_ref; amp_task_schedule_call(can_recv_notify, p); } if (g_can_close_flag) { duk_context *ctx = be_get_context(); be_unref(ctx, recv_param->js_cb_ref); aos_free(p); break; } aos_msleep(10); } ret = aos_hal_can_finalize(can_device); if (ret != 0) { amp_error(MOD_STR, "hal can finalize failed"); } out: aos_free(recv_param); g_can_recv_flag = 0; aos_sem_signal(&g_can_close_sem); aos_task_exit(0); return; } static duk_ret_t native_can_receive(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; item_handle_t can_handle; can_dev_t *can_device = NULL; can_recv_param_t *recv_param; aos_task_t can_recv_task; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and function"); goto out; } can_handle.handle = duk_get_pointer(ctx, 0); can_device = board_get_node_by_handle(MODULE_CAN, &can_handle); if (NULL == can_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } amp_debug(MOD_STR, "can handle %p", can_device); recv_param = (can_recv_param_t *)aos_calloc(1, sizeof(*recv_param)); if (!recv_param) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } duk_dup(ctx, 1); recv_param->js_cb_ref = be_ref(ctx); recv_param->can_device = can_device; ret = aos_task_new_ext(&can_recv_task, "amp can recv task", can_recv_routine, recv_param, 1024 * 4, ADDON_TSK_PRIORRITY); if (ret != 0) { amp_warn(MOD_STR, "tcp recv task error"); goto out; } out: duk_push_int(ctx, ret); return 1; } static void module_can_clean(void) { if (g_can_recv_flag) { g_can_close_flag = 1; aos_sem_wait(&g_can_close_sem, CAN_TIMEOUT + 50); g_can_close_flag = 0; } } void module_can_register(void) { amp_debug(MOD_STR, "module_can_register"); duk_context *ctx = be_get_context(); if (!g_can_close_sem) { if (aos_sem_new(&g_can_close_sem, 0) != 0) { amp_error(MOD_STR, "create can sem fail"); return; } } amp_module_free_register(module_can_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_can_open, 1); AMP_ADD_FUNCTION("send", native_can_send, 3); AMP_ADD_FUNCTION("receive", native_can_receive, 2); AMP_ADD_FUNCTION("close", native_can_close, 1); duk_put_prop_string(ctx, -2, "CAN"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/can/module_can.c
C
apache-2.0
9,289
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_dac.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "DAC" static duk_ret_t native_dac_open(duk_context *ctx) { int8_t ret = -1; item_handle_t dac_handle; dac_handle.handle = NULL; dac_dev_t *dac_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_DAC, id, &dac_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!\n"); goto out; } amp_debug(MOD_STR, "dac handle:%u\n", dac_handle.handle); dac_device = board_get_node_by_handle(MODULE_DAC, &dac_handle); if (NULL == dac_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } ret = aos_hal_dac_init(dac_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_dac_init fail!\n"); goto out; } ret = aos_hal_dac_start(dac_device, dac_device->port); if (0 != ret) { amp_error(MOD_STR, "hal_dac_start fail!\n"); } out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_DAC, &dac_handle); } else { duk_push_pointer(ctx, (void *)dac_handle.handle); } return 1; } static duk_ret_t native_dac_setVol(duk_context *ctx) { int8_t ret = -1; uint32_t voltage = 0; item_handle_t dac_handle; dac_dev_t *dac_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } dac_handle.handle = duk_get_pointer(ctx, 0); dac_device = board_get_node_by_handle(MODULE_DAC, &dac_handle); if (NULL == dac_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } voltage = duk_get_int(ctx, 1); ret = aos_hal_dac_set_value(dac_device, dac_device->port, voltage); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_dac_getVol(duk_context *ctx) { int32_t ret = -1; item_handle_t dac_handle; dac_dev_t *dac_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } dac_handle.handle = duk_get_pointer(ctx, 0); dac_device = board_get_node_by_handle(MODULE_DAC, &dac_handle); if (NULL == dac_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } ret = (int)aos_hal_dac_get_value(dac_device, dac_device->port); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_dac_close(duk_context *ctx) { int8_t ret = -1; item_handle_t dac_handle; dac_dev_t *dac_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } dac_handle.handle = duk_get_pointer(ctx, 0); dac_device = board_get_node_by_handle(MODULE_DAC, &dac_handle); if (NULL == dac_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } aos_hal_dac_stop(dac_device, dac_device->port); ret = aos_hal_dac_finalize(dac_device); board_disattach_item(MODULE_DAC, &dac_handle); out: duk_push_int(ctx, ret); return 1; } void module_dac_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_dac_open, 1); AMP_ADD_FUNCTION("getVol", native_dac_getVol, 1); AMP_ADD_FUNCTION("setVol", native_dac_setVol, 2); AMP_ADD_FUNCTION("close", native_dac_close, 1); duk_put_prop_string(ctx, -2, "DAC"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/dac/module_dac.c
C
apache-2.0
3,860
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_gpio.h" #include "aos_system.h" #include "amp_task.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "GPIO" #define GPIO_IRQ_RISING_EDGE "rising" #define GPIO_IRQ_FALLING_EDGE "falling" #define GPIO_IRQ_BOTH_EDGE "both" static uint16_t gpio_init_flag = 0; static duk_ret_t native_gpio_open(duk_context *ctx) { int8_t ret = -1; item_handle_t gpio_handle; gpio_handle.handle = NULL; gpio_dev_t *gpio_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_GPIO, id, &gpio_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!, id %s", id); goto out; } amp_debug(MOD_STR, "gpio handle:%p\n", gpio_handle.handle); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } if (gpio_init_flag & (1 << gpio_device->port)) { amp_debug(MOD_STR, "gpio port [%d] is already inited", gpio_device->port); goto out; } ret = aos_hal_gpio_init(gpio_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_gpio_init fail!"); goto out; } // gpio_device->priv = NULL; gpio_init_flag |= (1 << gpio_device->port); out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_GPIO, &gpio_handle); } else { duk_push_pointer(ctx, (void *)gpio_handle.handle); } return 1; } static duk_ret_t native_gpio_close(duk_context *ctx) { int32_t ret = -1; item_handle_t gpio_handle; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_gpio_finalize(gpio_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_gpio_finalize fail!"); goto out; } board_disattach_item(MODULE_GPIO, &gpio_handle); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_gpio_toggle(duk_context *ctx) { int32_t ret = -1; item_handle_t gpio_handle; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_gpio_output_toggle(gpio_device); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_gpio_write(duk_context *ctx) { int8_t ret = -1; int8_t result = -1; int8_t level = 0; item_handle_t gpio_handle; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } level = duk_get_int(ctx, 1); if (level) { ret = aos_hal_gpio_output_high(gpio_device); } else { ret = aos_hal_gpio_output_low(gpio_device); } if (-1 == ret) { amp_error(MOD_STR, "gpio output set fail!"); goto out; } result = 0; out: duk_push_int(ctx, result); return 1; } static duk_ret_t native_gpio_read(duk_context *ctx) { item_handle_t gpio_handle; uint32_t level = 0; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } aos_hal_gpio_input_get(gpio_device, &level); out: duk_push_int(ctx, level); return 1; } typedef struct { int js_cb_ref; gpio_dev_t *dev; }gpio_irq_notify_param_t; static void gpio_irq_notify(void *arg) { gpio_irq_notify_param_t *param = (gpio_irq_notify_param_t *)arg; duk_context *ctx = be_get_context(); uint32_t value = 0; aos_hal_gpio_input_get(param->dev, &value); be_push_ref(ctx, param->js_cb_ref); duk_push_int(ctx, value); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); aos_free(param); } /* avoid stdout in irq function */ static void gpio_irq(void *arg) { static uint64_t irq_lasttime = 0; uint64_t irq_nowtime = aos_now_ms(); gpio_dev_t *gpio = (gpio_dev_t *)arg; gpio_params_t *priv = NULL; gpio_irq_notify_param_t *notify; if (NULL == gpio) { /* amp_error(MOD_STR, "param error!\n"); */ return; } priv = (gpio_params_t *)gpio->priv; int js_cb_ref = (int)priv->js_cb_ref; if (js_cb_ref <= 0) { /* amp_error(MOD_STR, "js cb ref error, ref: %d\n", js_cb_ref); */ return; } if(irq_nowtime - irq_lasttime < 200){ // demounce in 200ms return; } irq_lasttime = irq_nowtime; notify = aos_malloc(sizeof(gpio_irq_notify_param_t)); if (!notify) return; notify->js_cb_ref = js_cb_ref; notify->dev = gpio; if (amp_task_schedule_call(gpio_irq_notify, notify) < 0) { /* amp_warn(MOD_STR, "amp_task_schedule_call failed\n"); */ } } static duk_ret_t native_gpio_on(duk_context *ctx) { int8_t ret = -1; int8_t result = -1; int8_t irq_edge = 0; item_handle_t gpio_handle; gpio_handle.handle = NULL; gpio_dev_t *gpio_device = NULL; gpio_params_t *priv = NULL; const char *edge; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle, string and function"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } // edge = duk_get_string(ctx, 1); // if (0 == strcmp(GPIO_IRQ_RISING_EDGE, edge)) { // irq_edge = IRQ_TRIGGER_RISING_EDGE; // } else if (0 == strcmp(GPIO_IRQ_FALLING_EDGE, edge)) { // irq_edge = IRQ_TRIGGER_FALLING_EDGE; // } else if (0 == strcmp(GPIO_IRQ_BOTH_EDGE, edge)) { // irq_edge = IRQ_TRIGGER_BOTH_EDGES; // } else { // amp_error(MOD_STR, "irq edge wrong!"); // goto out; // } priv = (gpio_params_t *)gpio_device->priv; irq_edge = priv->irq_mode; // amp_debug(MOD_STR, "%p, irq_edge:%04x port:%d", gpio_device, irq_edge, gpio_device->port); ret = aos_hal_gpio_enable_irq(gpio_device, irq_edge, gpio_irq, gpio_device); if (ret < 0) { amp_error(MOD_STR, "aos_hal_gpio_enable_irq fail!"); goto out; } duk_dup(ctx, 1); int js_cb_ref = be_ref(ctx); priv->js_cb_ref = (void *)js_cb_ref; result = 0; out: duk_push_int(ctx, result); return 1; } void module_gpio_register(void) { amp_debug(MOD_STR, "module_gpio_register"); duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_gpio_open, 1); AMP_ADD_FUNCTION("read", native_gpio_read, 1); AMP_ADD_FUNCTION("write", native_gpio_write, 2); AMP_ADD_FUNCTION("toggle", native_gpio_toggle, 1); AMP_ADD_FUNCTION("on", native_gpio_on, 2); AMP_ADD_FUNCTION("close", native_gpio_close, 1); duk_put_prop_string(ctx, -2, "GPIO"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/gpio/module_gpio.c
C
apache-2.0
8,409
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_i2c.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "I2C" #define I2C_TIMEOUT (0xFFFFFF) static duk_ret_t native_i2c_open(duk_context *ctx) { int8_t ret = -1; item_handle_t i2c_handle; i2c_handle.handle = NULL; i2c_dev_t *i2c_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_I2C, id, &i2c_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!"); goto out; } amp_debug(MOD_STR, "i2c handle:%u", i2c_handle.handle); i2c_device = board_get_node_by_handle(MODULE_I2C, &i2c_handle); if (NULL == i2c_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_i2c_init(i2c_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_i2c_init fail!"); goto out; } out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_I2C, &i2c_handle); } else { duk_push_pointer(ctx, (void *)i2c_handle.handle); } return 1; } static duk_ret_t native_i2c_close(duk_context *ctx) { int8_t ret = -1; item_handle_t i2c_handle; i2c_dev_t *i2c_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } i2c_handle.handle = duk_get_pointer(ctx, 0); i2c_device = board_get_node_by_handle(MODULE_I2C, &i2c_handle); if (NULL == i2c_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_i2c_finalize(i2c_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_i2c_finalize fail!"); goto out; } board_disattach_item(MODULE_I2C, &i2c_handle); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_i2c_write(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t i2c_handle; i2c_dev_t *i2c_device = NULL; int arr_idx; int err = -1; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and array"); goto out; } i2c_handle.handle = duk_get_pointer(ctx, 0); i2c_device = board_get_node_by_handle(MODULE_I2C, &i2c_handle); if (NULL == i2c_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } arr_idx = duk_normalize_index(ctx, 1); len = duk_get_length(ctx, arr_idx); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "data is not number, index is %d", i); duk_pop(ctx); goto out; } data[i] = (uint8_t)duk_get_int(ctx, -1); duk_pop(ctx); } ret = aos_hal_i2c_master_send(i2c_device, i2c_device->config.dev_addr, data, len, I2C_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "aos_hal_i2c_master_send fail!"); goto out; } err = 0; out: aos_free(data); duk_push_int(ctx, err); return 1; } static duk_ret_t native_i2c_write_reg(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t i2c_handle; i2c_dev_t *i2c_device = NULL; uint16_t mem_addr; int arr_idx; int err = -1; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1) || !duk_is_array(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle number and array"); goto out; } i2c_handle.handle = duk_get_pointer(ctx, 0); i2c_device = board_get_node_by_handle(MODULE_I2C, &i2c_handle); if (NULL == i2c_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } mem_addr = (uint16_t)duk_get_int(ctx, 1); arr_idx = duk_normalize_index(ctx, 2); len = duk_get_length(ctx, arr_idx); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "data is not number, index is %d", i); duk_pop(ctx); goto out; } data[i] = (uint8_t)duk_get_int(ctx, -1); duk_pop(ctx); } ret = aos_hal_i2c_mem_write(i2c_device, i2c_device->config.dev_addr, mem_addr, 1, data, len, I2C_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "aos_hal_i2c_master_send fail!"); goto out; } err = 0; out: aos_free(data); duk_push_int(ctx, err); return 1; } static duk_ret_t native_i2c_read(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t i2c_handle; i2c_dev_t *i2c_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } i2c_handle.handle = duk_get_pointer(ctx, 0); i2c_device = board_get_node_by_handle(MODULE_I2C, &i2c_handle); if (NULL == i2c_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } len = duk_get_int(ctx, 1); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_error(MOD_STR, "allocate memory failed"); goto out; } ret = aos_hal_i2c_master_recv(i2c_device, i2c_device->config.dev_addr, data, len, I2C_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "aos_hal_i2c_master_recv fail!"); } out: if (!ret) { duk_idx_t arr_idx = duk_push_array(ctx); for (i = 0; i < len; i++) { duk_push_int(ctx, data[i]); duk_put_prop_index(ctx, arr_idx, i); } } else { duk_push_null(ctx); } aos_free(data); return 1; } static duk_ret_t native_i2c_read_reg(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t i2c_handle; i2c_dev_t *i2c_device = NULL; uint16_t mem_addr; int arr_idx; int err = -1; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1) || !duk_is_number(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle number and array"); goto out; } i2c_handle.handle = duk_get_pointer(ctx, 0); i2c_device = board_get_node_by_handle(MODULE_I2C, &i2c_handle); if (NULL == i2c_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } mem_addr = (uint16_t)duk_get_int(ctx, 1); len = duk_get_int(ctx, 2); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } ret = aos_hal_i2c_mem_read(i2c_device, i2c_device->config.dev_addr, mem_addr, 1, data, len, I2C_TIMEOUT); out: if (!ret) { duk_idx_t arr_idx = duk_push_array(ctx); for (i = 0; i < len; i++) { duk_push_int(ctx, data[i]); duk_put_prop_index(ctx, arr_idx, i); } } else { duk_push_null(ctx); } aos_free(data); return 1; } void module_i2c_register(void) { amp_debug(MOD_STR, "module_i2c_register"); duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_i2c_open, 1); AMP_ADD_FUNCTION("read", native_i2c_read, 2); AMP_ADD_FUNCTION("write", native_i2c_write, 2); AMP_ADD_FUNCTION("readReg", native_i2c_read_reg, 3); AMP_ADD_FUNCTION("writeReg", native_i2c_write_reg, 3); AMP_ADD_FUNCTION("close", native_i2c_close, 1); duk_put_prop_string(ctx, -2, "I2C"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/i2c/module_i2c.c
C
apache-2.0
8,478
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_gpio.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "IR" static void ir_learn_mode(uint32_t scl_pin, uint32_t sda_pin) { gpio_i2c_reset(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_set_low(scl_pin); gpio_i2c_delay_10us(8); gpio_i2c_set_high(scl_pin); jse_osal_delay(20); gpio_i2c_start(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_write_byte(scl_pin, sda_pin, 0x30); gpio_i2c_delay_10us(4); gpio_i2c_write_byte(scl_pin, sda_pin, 0x20); gpio_i2c_delay_10us(4); gpio_i2c_write_byte(scl_pin, sda_pin, 0x50); gpio_i2c_delay_10us(8); gpio_i2c_stop(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_reset(scl_pin, sda_pin); gpio_i2c_delay_10us(4); } static int8_t ir_learn_read(uint32_t scl_pin, uint32_t sda_pin, uint8_t *buff) { uint8_t value = 0; uint8_t i = 0; uint8_t checksum = 0; gpio_i2c_reset(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_set_low(scl_pin); gpio_i2c_delay_10us(8); gpio_i2c_set_high(scl_pin); jse_osal_delay(20); gpio_i2c_start(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_write_byte(scl_pin, sda_pin, 0x30); gpio_i2c_delay_10us(4); gpio_i2c_write_byte(scl_pin, sda_pin, 0x62); gpio_i2c_delay_10us(4); gpio_i2c_start(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_write_byte(scl_pin, sda_pin, 0x31); gpio_i2c_delay_10us(4); value = gpio_i2c_read_byte(scl_pin, sda_pin); gpio_i2c_delay_10us(4); if (0x00 != value) { gpio_i2c_stop(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_reset(scl_pin, sda_pin); gpio_i2c_delay_10us(4); return -1; } buff[i] = value; checksum = 0xc3; for (i = 1; i < 230; i++) { value = gpio_i2c_read_byte(scl_pin, sda_pin); gpio_i2c_delay_10us(4); buff[i] = value; checksum += value; } value = gpio_i2c_read_byte(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_stop(scl_pin, sda_pin); gpio_i2c_delay_10us(4); gpio_i2c_reset(scl_pin, sda_pin); gpio_i2c_delay_10us(4); return 0; } static int32_t ir_learn_start(uint32_t scl_pin, uint32_t sda_pin, uint32_t busy_bin, uint8_t buff[232]) { uint8_t sumValue = 0; int32_t count = 0; int8_t ret = -1; uint8_t i = 0; uint8_t tmp[512] = {0x00}; gpio_i2c_init(scl_pin, sda_pin); gpio_i2c_set_in(busy_bin); ir_learn_mode(scl_pin, sda_pin); jse_osal_delay(50); while (!gpio_i2c_read_pin(busy_bin)) gpio_i2c_delay_10us(10); ret = ir_learn_read(scl_pin, sda_pin, tmp); if (0 != ret) { return -1; } buff[0] = 0x30; sumValue += buff[0]; buff[1] = 0x03; sumValue += buff[1]; for (i = 1; i < 231; i++) { buff[i + 1] = tmp[i]; sumValue += tmp[i]; } buff[231] = sumValue; return 232; } static uint32_t ir_counts(gpio_dev_t *gpio, uint8_t level) { int8_t ret = 0; uint32_t value = 0; uint32_t counts = 0; do { ret = aos_hal_gpio_input_get(gpio, &value); counts += 1; jse_osal_delay10us(); } while ((0 == ret) && (value == level)); return counts; } static uint32_t ir_nec(gpio_dev_t *gpio) { uint32_t counts = 0; uint32_t value = 0; uint8_t i = 0; uint8_t j = 0; /*9ms*/ counts = ir_counts(gpio, 0); if (counts < 850 || counts > 950) { return 0; } /*4.5ms*/ counts = ir_counts(gpio, 1); if (counts < 400 || counts > 500) { return 0; } for (i = 0; i < 4; ++i) { for (j = 0; j < 8; ++j) { value <<= 1; counts = ir_counts(gpio, 0); if (counts < 30 || counts > 100) { return 0; } counts = ir_counts(gpio, 1); if (counts > 130 && counts < 200) { value |= 1; } else if (counts < 30 || counts > 100) { return 0; } } } return value; } static duk_ret_t native_ir_open(duk_context *ctx) { int8_t ret = -1; item_handle_t gpio_handle; gpio_handle.handle = NULL; gpio_dev_t *gpio_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_GPIO, id, &gpio_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!\n"); goto out; } amp_debug(MOD_STR, "ir handle:%u\n", gpio_handle.handle); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } ret = aos_hal_gpio_init(gpio_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_gpio_init fail!\n"); goto out; } gpio_device->priv = NULL; out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_GPIO, &gpio_handle); } else { duk_push_pointer(ctx, (void *)gpio_handle.handle); } return 1; } static duk_ret_t native_ir_close(duk_context *ctx) { int8_t result = -1; item_handle_t gpio_handle; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } aos_hal_gpio_disable_irq(gpio_device); gpio_device->priv = NULL; board_disattach_item(MODULE_GPIO, &gpio_handle); result = 0; out: duk_push_int(ctx, result); return 1; } struct gpio_irq_notify_param { int js_cb_ref; int value; }; static void gpio_irq_notify(void *arg) { struct gpio_irq_notify_param *p = (struct gpio_irq_notify_param *)arg; amp_debug(MOD_STR, "value: 0x%x\n", p->value); duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_int(ctx, p->value); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); aos_free(p); duk_gc(ctx, 0); } /* avoid stdout in irq function */ static void ir_handle(void *arg) { uint32_t value = 0; gpio_dev_t *gpio = (gpio_dev_t *)arg; if (NULL == gpio) { /* amp_error(MOD_STR, "param error!\n"); */ return; } value = ir_nec(gpio); if (0x00 == value) { return; } int js_cb_ref = (int)gpio->priv; if (js_cb_ref <= 0) { /* amp_error(MOD_STR, "js cb ref error, ref: %d\n", js_cb_ref); */ return; } struct gpio_irq_notify_param *p = (struct gpio_irq_notify_param *)aos_malloc(sizeof(*p)); p->js_cb_ref = js_cb_ref; p->value = value & 0xFFFF; if (amp_task_schedule_call(gpio_irq_notify, p) < 0) { /* amp_warn(MOD_STR, "amp_task_schedule_call failed\n"); */ aos_free(p); } } static duk_ret_t native_ir_on(duk_context *ctx) { int8_t ret = -1; item_handle_t gpio_handle; gpio_handle.handle = NULL; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and function"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } ret = aos_hal_gpio_enable_irq(gpio_device, IRQ_TRIGGER_FALLING_EDGE, ir_handle, gpio_device); if (ret < 0) { amp_error(MOD_STR, "aos_hal_gpio_enable_irq fail!\n"); goto out; } duk_dup(ctx, 1); int js_cb_ref = be_ref(ctx); gpio_device->priv = (void *)js_cb_ref; out: duk_push_int(ctx, ret); return 1; } static void ir_delay(uint32_t counts) { uint32_t i = 0; for (i = 0; i < counts; i++) jse_osal_delay10us(); } static void ir_byte(gpio_dev_t *sda, gpio_dev_t *scl, unsigned char bData) { int8_t i = 0; uint32_t val = 0; aos_hal_gpio_output_low(scl); ir_delay(4); for (i = 7; i >= 0; i--) { ir_delay(4); if ((bData >> i) & 0x01) { aos_hal_gpio_output_high(sda); } else { aos_hal_gpio_output_low(sda); } ir_delay(4); aos_hal_gpio_output_high(scl); ir_delay(4); aos_hal_gpio_output_low(scl); } aos_hal_gpio_output_high(sda); ir_delay(16); aos_hal_gpio_output_high(scl); ir_delay(16); aos_hal_gpio_input_get(sda, &val); ir_delay(16); aos_hal_gpio_output_low(scl); ir_delay(16); } static void ir_buff(gpio_dev_t *sda, gpio_dev_t *scl, uint8_t *data, uint32_t count) { uint32_t i = 0; aos_hal_gpio_output_high(sda); aos_hal_gpio_output_high(scl); ir_delay(4); aos_hal_gpio_output_low(scl); ir_delay(8); aos_hal_gpio_output_high(scl); jse_osal_delay(20); aos_hal_gpio_output_high(scl); aos_hal_gpio_output_high(sda); ir_delay(8); aos_hal_gpio_output_low(sda); ir_delay(40); aos_hal_gpio_output_low(scl); ir_delay(8); ir_delay(4); for (i = 0; i < count; i++) { ir_byte(sda, scl, data[i]); ir_delay(4); } ir_delay(4); aos_hal_gpio_output_low(scl); aos_hal_gpio_output_low(sda); ir_delay(4); aos_hal_gpio_output_high(scl); ir_delay(4); aos_hal_gpio_output_high(sda); ir_delay(8); aos_hal_gpio_output_low(sda); aos_hal_gpio_output_low(scl); ir_delay(4); aos_hal_gpio_output_high(scl); ir_delay(4); aos_hal_gpio_output_high(sda); ir_delay(8); } static duk_ret_t native_ir_send(duk_context *ctx) { uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t gpio_handle; gpio_dev_t *gpio_scl = NULL; gpio_dev_t *gpio_sda = NULL; int arr_idx; int err = -1; if (!duk_is_pointer(ctx, 0) || !duk_is_pointer(ctx, 1) || !duk_is_array(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle, handle and array"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_sda = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_sda) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 1); gpio_scl = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_scl) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } arr_idx = duk_normalize_index(ctx, 2); len = duk_get_length(ctx, arr_idx); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "data is not number, index: %d", i); duk_pop(ctx); goto out; } data[i] = (uint8_t)duk_get_int(ctx, -1); duk_pop(ctx); } ir_buff(gpio_sda, gpio_scl, data, len); ir_delay(10); ir_buff(gpio_sda, gpio_scl, data, len); ir_delay(10); /* ir_buff(gpio_sda,gpio_scl,data,len); */ err = 0; out: aos_free(data); duk_push_int(ctx, err); return 1; } static duk_ret_t native_ir_learn(duk_context *ctx) { uint32_t i = 0; int32_t ret = -1; uint8_t buff[232] = {0x00}; item_handle_t gpio_handle; gpio_dev_t *gpio_scl = NULL; gpio_dev_t *gpio_sda = NULL; gpio_dev_t *gpio_busy = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_pointer(ctx, 1) || !duk_is_pointer(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle, handle and handle"); goto failed; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_sda = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_sda) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto failed; } gpio_handle.handle = duk_get_pointer(ctx, 1); gpio_scl = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_scl) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto failed; } gpio_handle.handle = duk_get_pointer(ctx, 2); gpio_busy = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_busy) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto failed; } ret = ir_learn_start(gpio_scl->port, gpio_sda->port, gpio_busy->port, buff); if (ret <= 0) { amp_error(MOD_STR, "ir_learn_start fail!\n"); goto failed; } int arr_idx = duk_push_array(ctx); for (i = 0; i < 232; ++i) { duk_push_int(ctx, buff[i]); duk_put_prop_index(ctx, arr_idx, i); } return 1; failed: duk_push_null(ctx); return 1; } void module_ir_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_ir_open, 1); AMP_ADD_FUNCTION("on", native_ir_on, 2); AMP_ADD_FUNCTION("send", native_ir_send, 3); AMP_ADD_FUNCTION("learn", native_ir_learn, 3); AMP_ADD_FUNCTION("close", native_ir_close, 1); duk_put_prop_string(ctx, -2, "IR"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/ir/module_ir.c
C
apache-2.0
14,028
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #ifndef _MODULE__FONT_H #define _MODULE__FONT_H #ifdef __cplusplus extern "C" { #endif static const unsigned char g_asc2_1206[95][12] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ",0*/ {0x00, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!",1*/ {0x00, 0x00, 0x30, 0x00, 0x40, 0x00, 0x30, 0x00, 0x40, 0x00, 0x00, 0x00}, /*""",2*/ {0x09, 0x00, 0x0B, 0xC0, 0x3D, 0x00, 0x0B, 0xC0, 0x3D, 0x00, 0x09, 0x00}, /*"#",3*/ {0x18, 0xC0, 0x24, 0x40, 0x7F, 0xE0, 0x22, 0x40, 0x31, 0x80, 0x00, 0x00}, /*"$",4*/ {0x18, 0x00, 0x24, 0xC0, 0x1B, 0x00, 0x0D, 0x80, 0x32, 0x40, 0x01, 0x80}, /*"%",5*/ {0x03, 0x80, 0x1C, 0x40, 0x27, 0x40, 0x1C, 0x80, 0x07, 0x40, 0x00, 0x40}, /*"&",6*/ {0x10, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'",7*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x20, 0x40, 0x40, 0x20}, /*"(",8*/ {0x00, 0x00, 0x40, 0x20, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00}, /*")",9*/ {0x09, 0x00, 0x06, 0x00, 0x1F, 0x80, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00}, /*"*",10*/ {0x04, 0x00, 0x04, 0x00, 0x3F, 0x80, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00}, /*"+",11*/ {0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*",",12*/ {0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00}, /*"-",13*/ {0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".",14*/ {0x00, 0x20, 0x01, 0xC0, 0x06, 0x00, 0x38, 0x00, 0x40, 0x00, 0x00, 0x00}, /*"/",15*/ {0x1F, 0x80, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"0",16*/ {0x00, 0x00, 0x10, 0x40, 0x3F, 0xC0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00}, /*"1",17*/ {0x18, 0xC0, 0x21, 0x40, 0x22, 0x40, 0x24, 0x40, 0x18, 0x40, 0x00, 0x00}, /*"2",18*/ {0x10, 0x80, 0x20, 0x40, 0x24, 0x40, 0x24, 0x40, 0x1B, 0x80, 0x00, 0x00}, /*"3",19*/ {0x02, 0x00, 0x0D, 0x00, 0x11, 0x00, 0x3F, 0xC0, 0x01, 0x40, 0x00, 0x00}, /*"4",20*/ {0x3C, 0x80, 0x24, 0x40, 0x24, 0x40, 0x24, 0x40, 0x23, 0x80, 0x00, 0x00}, /*"5",21*/ {0x1F, 0x80, 0x24, 0x40, 0x24, 0x40, 0x34, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"6",22*/ {0x30, 0x00, 0x20, 0x00, 0x27, 0xC0, 0x38, 0x00, 0x20, 0x00, 0x00, 0x00}, /*"7",23*/ {0x1B, 0x80, 0x24, 0x40, 0x24, 0x40, 0x24, 0x40, 0x1B, 0x80, 0x00, 0x00}, /*"8",24*/ {0x1C, 0x00, 0x22, 0xC0, 0x22, 0x40, 0x22, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"9",25*/ {0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":",26*/ {0x00, 0x00, 0x00, 0x00, 0x04, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";",27*/ {0x00, 0x00, 0x04, 0x00, 0x0A, 0x00, 0x11, 0x00, 0x20, 0x80, 0x40, 0x40}, /*"<",28*/ {0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00}, /*"=",29*/ {0x00, 0x00, 0x40, 0x40, 0x20, 0x80, 0x11, 0x00, 0x0A, 0x00, 0x04, 0x00}, /*">",30*/ {0x18, 0x00, 0x20, 0x00, 0x23, 0x40, 0x24, 0x00, 0x18, 0x00, 0x00, 0x00}, /*"?",31*/ {0x1F, 0x80, 0x20, 0x40, 0x27, 0x40, 0x29, 0x40, 0x1F, 0x40, 0x00, 0x00}, /*"@",32*/ {0x00, 0x40, 0x07, 0xC0, 0x39, 0x00, 0x0F, 0x00, 0x01, 0xC0, 0x00, 0x40}, /*"A",33*/ {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x24, 0x40, 0x1B, 0x80, 0x00, 0x00}, /*"B",34*/ {0x1F, 0x80, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x30, 0x80, 0x00, 0x00}, /*"C",35*/ {0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"D",36*/ {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x2E, 0x40, 0x30, 0xC0, 0x00, 0x00}, /*"E",37*/ {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x2E, 0x00, 0x30, 0x00, 0x00, 0x00}, /*"F",38*/ {0x0F, 0x00, 0x10, 0x80, 0x20, 0x40, 0x22, 0x40, 0x33, 0x80, 0x02, 0x00}, /*"G",39*/ {0x20, 0x40, 0x3F, 0xC0, 0x04, 0x00, 0x04, 0x00, 0x3F, 0xC0, 0x20, 0x40}, /*"H",40*/ {0x20, 0x40, 0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x20, 0x40, 0x00, 0x00}, /*"I",41*/ {0x00, 0x60, 0x20, 0x20, 0x20, 0x20, 0x3F, 0xC0, 0x20, 0x00, 0x20, 0x00}, /*"J",42*/ {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x0B, 0x00, 0x30, 0xC0, 0x20, 0x40}, /*"K",43*/ {0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0xC0}, /*"L",44*/ {0x3F, 0xC0, 0x3C, 0x00, 0x03, 0xC0, 0x3C, 0x00, 0x3F, 0xC0, 0x00, 0x00}, /*"M",45*/ {0x20, 0x40, 0x3F, 0xC0, 0x0C, 0x40, 0x23, 0x00, 0x3F, 0xC0, 0x20, 0x00}, /*"N",46*/ {0x1F, 0x80, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"O",47*/ {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x24, 0x00, 0x18, 0x00, 0x00, 0x00}, /*"P",48*/ {0x1F, 0x80, 0x21, 0x40, 0x21, 0x40, 0x20, 0xE0, 0x1F, 0xA0, 0x00, 0x00}, /*"Q",49*/ {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x26, 0x00, 0x19, 0xC0, 0x00, 0x40}, /*"R",50*/ {0x18, 0xC0, 0x24, 0x40, 0x24, 0x40, 0x22, 0x40, 0x31, 0x80, 0x00, 0x00}, /*"S",51*/ {0x30, 0x00, 0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x30, 0x00, 0x00, 0x00}, /*"T",52*/ {0x20, 0x00, 0x3F, 0x80, 0x00, 0x40, 0x00, 0x40, 0x3F, 0x80, 0x20, 0x00}, /*"U",53*/ {0x20, 0x00, 0x3E, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x38, 0x00, 0x20, 0x00}, /*"V",54*/ {0x38, 0x00, 0x07, 0xC0, 0x3C, 0x00, 0x07, 0xC0, 0x38, 0x00, 0x00, 0x00}, /*"W",55*/ {0x20, 0x40, 0x39, 0xC0, 0x06, 0x00, 0x39, 0xC0, 0x20, 0x40, 0x00, 0x00}, /*"X",56*/ {0x20, 0x00, 0x38, 0x40, 0x07, 0xC0, 0x38, 0x40, 0x20, 0x00, 0x00, 0x00}, /*"Y",57*/ {0x30, 0x40, 0x21, 0xC0, 0x26, 0x40, 0x38, 0x40, 0x20, 0xC0, 0x00, 0x00}, /*"Z",58*/ {0x00, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x40, 0x20, 0x40, 0x20, 0x00, 0x00}, /*"[",59*/ {0x00, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x03, 0x80, 0x00, 0x40, 0x00, 0x00}, /*"\",60*/ {0x00, 0x00, 0x40, 0x20, 0x40, 0x20, 0x7F, 0xE0, 0x00, 0x00, 0x00, 0x00}, /*"]",61*/ {0x00, 0x00, 0x20, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^",62*/ {0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10}, /*"_",63*/ {0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`",64*/ {0x00, 0x00, 0x02, 0x80, 0x05, 0x40, 0x05, 0x40, 0x03, 0xC0, 0x00, 0x40}, /*"a",65*/ {0x20, 0x00, 0x3F, 0xC0, 0x04, 0x40, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"b",66*/ {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x04, 0x40, 0x06, 0x40, 0x00, 0x00}, /*"c",67*/ {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x24, 0x40, 0x3F, 0xC0, 0x00, 0x40}, /*"d",68*/ {0x00, 0x00, 0x03, 0x80, 0x05, 0x40, 0x05, 0x40, 0x03, 0x40, 0x00, 0x00}, /*"e",69*/ {0x00, 0x00, 0x04, 0x40, 0x1F, 0xC0, 0x24, 0x40, 0x24, 0x40, 0x20, 0x00}, /*"f",70*/ {0x00, 0x00, 0x02, 0xE0, 0x05, 0x50, 0x05, 0x50, 0x06, 0x50, 0x04, 0x20}, /*"g",71*/ {0x20, 0x40, 0x3F, 0xC0, 0x04, 0x40, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x40}, /*"h",72*/ {0x00, 0x00, 0x04, 0x40, 0x27, 0xC0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00}, /*"i",73*/ {0x00, 0x10, 0x00, 0x10, 0x04, 0x10, 0x27, 0xE0, 0x00, 0x00, 0x00, 0x00}, /*"j",74*/ {0x20, 0x40, 0x3F, 0xC0, 0x01, 0x40, 0x07, 0x00, 0x04, 0xC0, 0x04, 0x40}, /*"k",75*/ {0x20, 0x40, 0x20, 0x40, 0x3F, 0xC0, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00}, /*"l",76*/ {0x07, 0xC0, 0x04, 0x00, 0x07, 0xC0, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x00}, /*"m",77*/ {0x04, 0x40, 0x07, 0xC0, 0x04, 0x40, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x40}, /*"n",78*/ {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"o",79*/ {0x04, 0x10, 0x07, 0xF0, 0x04, 0x50, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"p",80*/ {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x04, 0x50, 0x07, 0xF0, 0x00, 0x10}, /*"q",81*/ {0x04, 0x40, 0x07, 0xC0, 0x02, 0x40, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00}, /*"r",82*/ {0x00, 0x00, 0x06, 0x40, 0x05, 0x40, 0x05, 0x40, 0x04, 0xC0, 0x00, 0x00}, /*"s",83*/ {0x00, 0x00, 0x04, 0x00, 0x1F, 0x80, 0x04, 0x40, 0x00, 0x40, 0x00, 0x00}, /*"t",84*/ {0x04, 0x00, 0x07, 0x80, 0x00, 0x40, 0x04, 0x40, 0x07, 0xC0, 0x00, 0x40}, /*"u",85*/ {0x04, 0x00, 0x07, 0x00, 0x04, 0xC0, 0x01, 0x80, 0x06, 0x00, 0x04, 0x00}, /*"v",86*/ {0x06, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x01, 0xC0, 0x06, 0x00, 0x00, 0x00}, /*"w",87*/ {0x04, 0x40, 0x06, 0xC0, 0x01, 0x00, 0x06, 0xC0, 0x04, 0x40, 0x00, 0x00}, /*"x",88*/ {0x04, 0x10, 0x07, 0x10, 0x04, 0xE0, 0x01, 0x80, 0x06, 0x00, 0x04, 0x00}, /*"y",89*/ {0x00, 0x00, 0x04, 0x40, 0x05, 0xC0, 0x06, 0x40, 0x04, 0x40, 0x00, 0x00}, /*"z",90*/ {0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x7B, 0xE0, 0x40, 0x20, 0x00, 0x00}, /*"{",91*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00}, /*"|",92*/ {0x00, 0x00, 0x40, 0x20, 0x7B, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}",93*/ {0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, 0x00}, /*"~",94*/ }; static const unsigned char g_asc2_1608[95][16] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ",0*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xCC, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!",1*/ {0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0x60, 0x00, 0x08, 0x00, 0x30, 0x00, 0x60, 0x00, 0x00, 0x00}, /*""",2*/ {0x02, 0x20, 0x03, 0xFC, 0x1E, 0x20, 0x02, 0x20, 0x03, 0xFC, 0x1E, 0x20, 0x02, 0x20, 0x00, 0x00}, /*"#",3*/ {0x00, 0x00, 0x0E, 0x18, 0x11, 0x04, 0x3F, 0xFF, 0x10, 0x84, 0x0C, 0x78, 0x00, 0x00, 0x00, 0x00}, /*"$",4*/ {0x0F, 0x00, 0x10, 0x84, 0x0F, 0x38, 0x00, 0xC0, 0x07, 0x78, 0x18, 0x84, 0x00, 0x78, 0x00, 0x00}, /*"%",5*/ {0x00, 0x78, 0x0F, 0x84, 0x10, 0xC4, 0x11, 0x24, 0x0E, 0x98, 0x00, 0xE4, 0x00, 0x84, 0x00, 0x08}, /*"&",6*/ {0x08, 0x00, 0x68, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'",7*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x18, 0x18, 0x20, 0x04, 0x40, 0x02, 0x00, 0x00}, /*"(",8*/ {0x00, 0x00, 0x40, 0x02, 0x20, 0x04, 0x18, 0x18, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*")",9*/ {0x02, 0x40, 0x02, 0x40, 0x01, 0x80, 0x0F, 0xF0, 0x01, 0x80, 0x02, 0x40, 0x02, 0x40, 0x00, 0x00}, /*"*",10*/ {0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x0F, 0xF8, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00}, /*"+",11*/ {0x00, 0x01, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*",",12*/ {0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80}, /*"-",13*/ {0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".",14*/ {0x00, 0x00, 0x00, 0x06, 0x00, 0x18, 0x00, 0x60, 0x01, 0x80, 0x06, 0x00, 0x18, 0x00, 0x20, 0x00}, /*"/",15*/ {0x00, 0x00, 0x07, 0xF0, 0x08, 0x08, 0x10, 0x04, 0x10, 0x04, 0x08, 0x08, 0x07, 0xF0, 0x00, 0x00}, /*"0",16*/ {0x00, 0x00, 0x08, 0x04, 0x08, 0x04, 0x1F, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"1",17*/ {0x00, 0x00, 0x0E, 0x0C, 0x10, 0x14, 0x10, 0x24, 0x10, 0x44, 0x11, 0x84, 0x0E, 0x0C, 0x00, 0x00}, /*"2",18*/ {0x00, 0x00, 0x0C, 0x18, 0x10, 0x04, 0x11, 0x04, 0x11, 0x04, 0x12, 0x88, 0x0C, 0x70, 0x00, 0x00}, /*"3",19*/ {0x00, 0x00, 0x00, 0xE0, 0x03, 0x20, 0x04, 0x24, 0x08, 0x24, 0x1F, 0xFC, 0x00, 0x24, 0x00, 0x00}, /*"4",20*/ {0x00, 0x00, 0x1F, 0x98, 0x10, 0x84, 0x11, 0x04, 0x11, 0x04, 0x10, 0x88, 0x10, 0x70, 0x00, 0x00}, /*"5",21*/ {0x00, 0x00, 0x07, 0xF0, 0x08, 0x88, 0x11, 0x04, 0x11, 0x04, 0x18, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"6",22*/ {0x00, 0x00, 0x1C, 0x00, 0x10, 0x00, 0x10, 0xFC, 0x13, 0x00, 0x1C, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"7",23*/ {0x00, 0x00, 0x0E, 0x38, 0x11, 0x44, 0x10, 0x84, 0x10, 0x84, 0x11, 0x44, 0x0E, 0x38, 0x00, 0x00}, /*"8",24*/ {0x00, 0x00, 0x07, 0x00, 0x08, 0x8C, 0x10, 0x44, 0x10, 0x44, 0x08, 0x88, 0x07, 0xF0, 0x00, 0x00}, /*"9",25*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":",26*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";",27*/ {0x00, 0x00, 0x00, 0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x00, 0x00}, /*"<",28*/ {0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x00, 0x00}, /*"=",29*/ {0x00, 0x00, 0x10, 0x04, 0x08, 0x08, 0x04, 0x10, 0x02, 0x20, 0x01, 0x40, 0x00, 0x80, 0x00, 0x00}, /*">",30*/ {0x00, 0x00, 0x0E, 0x00, 0x12, 0x00, 0x10, 0x0C, 0x10, 0x6C, 0x10, 0x80, 0x0F, 0x00, 0x00, 0x00}, /*"?",31*/ {0x03, 0xE0, 0x0C, 0x18, 0x13, 0xE4, 0x14, 0x24, 0x17, 0xC4, 0x08, 0x28, 0x07, 0xD0, 0x00, 0x00}, /*"@",32*/ {0x00, 0x04, 0x00, 0x3C, 0x03, 0xC4, 0x1C, 0x40, 0x07, 0x40, 0x00, 0xE4, 0x00, 0x1C, 0x00, 0x04}, /*"A",33*/ {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x04, 0x11, 0x04, 0x0E, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"B",34*/ {0x03, 0xE0, 0x0C, 0x18, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x08, 0x1C, 0x10, 0x00, 0x00}, /*"C",35*/ {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x08, 0x08, 0x07, 0xF0, 0x00, 0x00}, /*"D",36*/ {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x04, 0x17, 0xC4, 0x10, 0x04, 0x08, 0x18, 0x00, 0x00}, /*"E",37*/ {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x00, 0x17, 0xC0, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"F",38*/ {0x03, 0xE0, 0x0C, 0x18, 0x10, 0x04, 0x10, 0x04, 0x10, 0x44, 0x1C, 0x78, 0x00, 0x40, 0x00, 0x00}, /*"G",39*/ {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x84, 0x00, 0x80, 0x00, 0x80, 0x10, 0x84, 0x1F, 0xFC, 0x10, 0x04}, /*"H",40*/ {0x00, 0x00, 0x10, 0x04, 0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"I",41*/ {0x00, 0x03, 0x00, 0x01, 0x10, 0x01, 0x10, 0x01, 0x1F, 0xFE, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"J",42*/ {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x03, 0x80, 0x14, 0x64, 0x18, 0x1C, 0x10, 0x04, 0x00, 0x00}, /*"K",43*/ {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x0C, 0x00, 0x00}, /*"L",44*/ {0x10, 0x04, 0x1F, 0xFC, 0x1F, 0x00, 0x00, 0xFC, 0x1F, 0x00, 0x1F, 0xFC, 0x10, 0x04, 0x00, 0x00}, /*"M",45*/ {0x10, 0x04, 0x1F, 0xFC, 0x0C, 0x04, 0x03, 0x00, 0x00, 0xE0, 0x10, 0x18, 0x1F, 0xFC, 0x10, 0x00}, /*"N",46*/ {0x07, 0xF0, 0x08, 0x08, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x08, 0x08, 0x07, 0xF0, 0x00, 0x00}, /*"O",47*/ {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x84, 0x10, 0x80, 0x10, 0x80, 0x10, 0x80, 0x0F, 0x00, 0x00, 0x00}, /*"P",48*/ {0x07, 0xF0, 0x08, 0x18, 0x10, 0x24, 0x10, 0x24, 0x10, 0x1C, 0x08, 0x0A, 0x07, 0xF2, 0x00, 0x00}, /*"Q",49*/ {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x00, 0x11, 0xC0, 0x11, 0x30, 0x0E, 0x0C, 0x00, 0x04}, /*"R",50*/ {0x00, 0x00, 0x0E, 0x1C, 0x11, 0x04, 0x10, 0x84, 0x10, 0x84, 0x10, 0x44, 0x1C, 0x38, 0x00, 0x00}, /*"S",51*/ {0x18, 0x00, 0x10, 0x00, 0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00}, /*"T",52*/ {0x10, 0x00, 0x1F, 0xF8, 0x10, 0x04, 0x00, 0x04, 0x00, 0x04, 0x10, 0x04, 0x1F, 0xF8, 0x10, 0x00}, /*"U",53*/ {0x10, 0x00, 0x1E, 0x00, 0x11, 0xE0, 0x00, 0x1C, 0x00, 0x70, 0x13, 0x80, 0x1C, 0x00, 0x10, 0x00}, /*"V",54*/ {0x1F, 0xC0, 0x10, 0x3C, 0x00, 0xE0, 0x1F, 0x00, 0x00, 0xE0, 0x10, 0x3C, 0x1F, 0xC0, 0x00, 0x00}, /*"W",55*/ {0x10, 0x04, 0x18, 0x0C, 0x16, 0x34, 0x01, 0xC0, 0x01, 0xC0, 0x16, 0x34, 0x18, 0x0C, 0x10, 0x04}, /*"X",56*/ {0x10, 0x00, 0x1C, 0x00, 0x13, 0x04, 0x00, 0xFC, 0x13, 0x04, 0x1C, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"Y",57*/ {0x08, 0x04, 0x10, 0x1C, 0x10, 0x64, 0x10, 0x84, 0x13, 0x04, 0x1C, 0x04, 0x10, 0x18, 0x00, 0x00}, /*"Z",58*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x00, 0x00}, /*"[",59*/ {0x00, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x03, 0x80, 0x00, 0x60, 0x00, 0x1C, 0x00, 0x03, 0x00, 0x00}, /*"\",60*/ {0x00, 0x00, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"]",61*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00}, /*"^",62*/ {0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01}, /*"_",63*/ {0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`",64*/ {0x00, 0x00, 0x00, 0x98, 0x01, 0x24, 0x01, 0x44, 0x01, 0x44, 0x01, 0x44, 0x00, 0xFC, 0x00, 0x04}, /*"a",65*/ {0x10, 0x00, 0x1F, 0xFC, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"b",66*/ {0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x00, 0x88, 0x00, 0x00}, /*"c",67*/ {0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x11, 0x08, 0x1F, 0xFC, 0x00, 0x04}, /*"d",68*/ {0x00, 0x00, 0x00, 0xF8, 0x01, 0x44, 0x01, 0x44, 0x01, 0x44, 0x01, 0x44, 0x00, 0xC8, 0x00, 0x00}, /*"e",69*/ {0x00, 0x00, 0x01, 0x04, 0x01, 0x04, 0x0F, 0xFC, 0x11, 0x04, 0x11, 0x04, 0x11, 0x00, 0x18, 0x00}, /*"f",70*/ {0x00, 0x00, 0x00, 0xD6, 0x01, 0x29, 0x01, 0x29, 0x01, 0x29, 0x01, 0xC9, 0x01, 0x06, 0x00, 0x00}, /*"g",71*/ {0x10, 0x04, 0x1F, 0xFC, 0x00, 0x84, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x00, 0xFC, 0x00, 0x04}, /*"h",72*/ {0x00, 0x00, 0x01, 0x04, 0x19, 0x04, 0x19, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"i",73*/ {0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x01, 0x19, 0x01, 0x19, 0xFE, 0x00, 0x00, 0x00, 0x00}, /*"j",74*/ {0x10, 0x04, 0x1F, 0xFC, 0x00, 0x24, 0x00, 0x40, 0x01, 0xB4, 0x01, 0x0C, 0x01, 0x04, 0x00, 0x00}, /*"k",75*/ {0x00, 0x00, 0x10, 0x04, 0x10, 0x04, 0x1F, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"l",76*/ {0x01, 0x04, 0x01, 0xFC, 0x01, 0x04, 0x01, 0x00, 0x01, 0xFC, 0x01, 0x04, 0x01, 0x00, 0x00, 0xFC}, /*"m",77*/ {0x01, 0x04, 0x01, 0xFC, 0x00, 0x84, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x00, 0xFC, 0x00, 0x04}, /*"n",78*/ {0x00, 0x00, 0x00, 0xF8, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x00, 0xF8, 0x00, 0x00}, /*"o",79*/ {0x01, 0x01, 0x01, 0xFF, 0x00, 0x85, 0x01, 0x04, 0x01, 0x04, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"p",80*/ {0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x01, 0x05, 0x01, 0xFF, 0x00, 0x01}, /*"q",81*/ {0x01, 0x04, 0x01, 0x04, 0x01, 0xFC, 0x00, 0x84, 0x01, 0x04, 0x01, 0x00, 0x01, 0x80, 0x00, 0x00}, /*"r",82*/ {0x00, 0x00, 0x00, 0xCC, 0x01, 0x24, 0x01, 0x24, 0x01, 0x24, 0x01, 0x24, 0x01, 0x98, 0x00, 0x00}, /*"s",83*/ {0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x07, 0xF8, 0x01, 0x04, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"t",84*/ {0x01, 0x00, 0x01, 0xF8, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x01, 0x08, 0x01, 0xFC, 0x00, 0x04}, /*"u",85*/ {0x01, 0x00, 0x01, 0x80, 0x01, 0x70, 0x00, 0x0C, 0x00, 0x10, 0x01, 0x60, 0x01, 0x80, 0x01, 0x00}, /*"v",86*/ {0x01, 0xF0, 0x01, 0x0C, 0x00, 0x30, 0x01, 0xC0, 0x00, 0x30, 0x01, 0x0C, 0x01, 0xF0, 0x01, 0x00}, /*"w",87*/ {0x00, 0x00, 0x01, 0x04, 0x01, 0x8C, 0x00, 0x74, 0x01, 0x70, 0x01, 0x8C, 0x01, 0x04, 0x00, 0x00}, /*"x",88*/ {0x01, 0x01, 0x01, 0x81, 0x01, 0x71, 0x00, 0x0E, 0x00, 0x18, 0x01, 0x60, 0x01, 0x80, 0x01, 0x00}, /*"y",89*/ {0x00, 0x00, 0x01, 0x84, 0x01, 0x0C, 0x01, 0x34, 0x01, 0x44, 0x01, 0x84, 0x01, 0x0C, 0x00, 0x00}, /*"z",90*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3E, 0xFC, 0x40, 0x02, 0x40, 0x02}, /*"{",91*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"|",92*/ {0x00, 0x00, 0x40, 0x02, 0x40, 0x02, 0x3E, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}",93*/ {0x00, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00}, /*"~",94*/ }; static const unsigned char g_asc2_2412[95][36] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ",0*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x38, 0x0F, 0xFE, 0x38, 0x0F, 0x80, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!",1*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x31, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}, /*""",2*/ {0x00, 0x00, 0x00, 0x00, 0x61, 0x80, 0x00, 0x67, 0xF8, 0x07, 0xF9, 0x80, 0x00, 0x61, 0x80, 0x00, 0x61, 0x80, 0x00, 0x61, 0x80, 0x00, 0x61, 0x80, 0x00, 0x67, 0xF8, 0x07, 0xF9, 0x80, 0x00, 0x61, 0x80, 0x00, 0x00, 0x00}, /*"#",3*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0xE0, 0x03, 0xE0, 0xF0, 0x06, 0x30, 0x08, 0x04, 0x18, 0x08, 0x1F, 0xFF, 0xFE, 0x04, 0x0E, 0x08, 0x07, 0x87, 0xF0, 0x03, 0x81, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"$",4*/ {0x01, 0xF0, 0x00, 0x06, 0x0C, 0x00, 0x04, 0x04, 0x08, 0x06, 0x0C, 0x70, 0x01, 0xF9, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x3B, 0xE0, 0x00, 0xEC, 0x18, 0x07, 0x08, 0x08, 0x04, 0x0C, 0x18, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00}, /*"%",5*/ {0x00, 0x01, 0xE0, 0x00, 0x07, 0xF0, 0x03, 0xF8, 0x18, 0x04, 0x1C, 0x08, 0x04, 0x17, 0x08, 0x07, 0xE1, 0xD0, 0x03, 0xC0, 0xE0, 0x00, 0x23, 0xB0, 0x00, 0x3C, 0x08, 0x00, 0x20, 0x08, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"&",6*/ {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x31, 0x00, 0x00, 0x32, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'",7*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x01, 0xFF, 0xC0, 0x07, 0x80, 0xF0, 0x0C, 0x00, 0x18, 0x10, 0x00, 0x04, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00}, /*"(",8*/ {0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x10, 0x00, 0x04, 0x0C, 0x00, 0x18, 0x07, 0x80, 0xF0, 0x01, 0xFF, 0xC0, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*")",9*/ {0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x18, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x18, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x42, 0x00}, /*"*",10*/ {0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00}, /*"+",11*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x31, 0x00, 0x00, 0x32, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*",",12*/ {0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}, /*"-",13*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x38, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".",14*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x70, 0x00, 0x01, 0x80, 0x00, 0x0E, 0x00, 0x00, 0x38, 0x00, 0x00, 0xC0, 0x00, 0x07, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"/",15*/ {0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x03, 0x80, 0x70, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00}, /*"0",16*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00, 0x08, 0x01, 0x00, 0x08, 0x03, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"1",17*/ {0x00, 0x00, 0x00, 0x01, 0xC0, 0x38, 0x02, 0xC0, 0x58, 0x04, 0x00, 0x98, 0x04, 0x01, 0x18, 0x04, 0x02, 0x18, 0x04, 0x04, 0x18, 0x06, 0x1C, 0x18, 0x03, 0xF8, 0x18, 0x01, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"2",18*/ {0x00, 0x00, 0x00, 0x01, 0xC0, 0xE0, 0x03, 0xC0, 0xF0, 0x04, 0x00, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x06, 0x18, 0x08, 0x03, 0xF4, 0x18, 0x01, 0xE7, 0xF0, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"3",19*/ {0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x11, 0x00, 0x00, 0x61, 0x00, 0x00, 0x81, 0x08, 0x03, 0x01, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x01, 0x08, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00}, /*"4",20*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x07, 0xFC, 0xD0, 0x06, 0x08, 0x08, 0x06, 0x10, 0x08, 0x06, 0x10, 0x08, 0x06, 0x10, 0x08, 0x06, 0x18, 0x38, 0x06, 0x0F, 0xF0, 0x06, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"5",21*/ {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x84, 0x30, 0x02, 0x08, 0x18, 0x04, 0x10, 0x08, 0x04, 0x10, 0x08, 0x04, 0x10, 0x08, 0x07, 0x18, 0x10, 0x03, 0x0F, 0xF0, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00}, /*"6",22*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0xF8, 0x06, 0x07, 0xF8, 0x06, 0x18, 0x00, 0x06, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"7",23*/ {0x00, 0x00, 0x00, 0x01, 0xE1, 0xE0, 0x03, 0xF7, 0xF0, 0x06, 0x34, 0x10, 0x04, 0x18, 0x08, 0x04, 0x18, 0x08, 0x04, 0x0C, 0x08, 0x04, 0x0C, 0x08, 0x06, 0x16, 0x18, 0x03, 0xF3, 0xF0, 0x01, 0xC1, 0xE0, 0x00, 0x00, 0x00}, /*"8",24*/ {0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x03, 0xFC, 0x30, 0x03, 0x06, 0x38, 0x04, 0x02, 0x08, 0x04, 0x02, 0x08, 0x04, 0x02, 0x08, 0x04, 0x04, 0x10, 0x03, 0x08, 0xF0, 0x01, 0xFF, 0xC0, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00}, /*"9",25*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x38, 0x00, 0x70, 0x38, 0x00, 0x70, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":",26*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x1A, 0x00, 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";",27*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x14, 0x00, 0x00, 0x22, 0x00, 0x00, 0x41, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x40, 0x02, 0x00, 0x20, 0x04, 0x00, 0x10, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"<",28*/ {0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00}, /*"=",29*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x04, 0x00, 0x10, 0x02, 0x00, 0x20, 0x01, 0x00, 0x40, 0x00, 0x80, 0x80, 0x00, 0x41, 0x00, 0x00, 0x22, 0x00, 0x00, 0x14, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}, /*">",30*/ {0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x04, 0xC0, 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x38, 0x08, 0x0F, 0x38, 0x08, 0x08, 0x38, 0x08, 0x10, 0x00, 0x0C, 0x30, 0x00, 0x07, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00}, /*"?",31*/ {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x02, 0x0F, 0x10, 0x06, 0x70, 0x88, 0x04, 0xC0, 0x88, 0x04, 0x83, 0x08, 0x04, 0x7F, 0x88, 0x02, 0xC0, 0x90, 0x03, 0x01, 0x20, 0x00, 0xFE, 0x40}, /*"@",32*/ {0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x00, 0x01, 0xF8, 0x00, 0x3E, 0x08, 0x01, 0xC2, 0x00, 0x07, 0x02, 0x00, 0x07, 0xE2, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x1F, 0xC8, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08}, /*"A",33*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x06, 0x18, 0x08, 0x03, 0xF4, 0x18, 0x01, 0xE7, 0xF0, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00}, /*"B",34*/ {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x02, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x10, 0x06, 0x00, 0x20, 0x07, 0x80, 0xC0, 0x00, 0x00, 0x00}, /*"C",35*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x18, 0x02, 0x00, 0x10, 0x03, 0x80, 0x70, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00}, /*"D",36*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x3E, 0x08, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x01, 0x00, 0x60, 0x00, 0x00, 0x00}, /*"E",37*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x00, 0x04, 0x08, 0x00, 0x04, 0x08, 0x00, 0x04, 0x3E, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00}, /*"F",38*/ {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x02, 0x08, 0x04, 0x02, 0x08, 0x02, 0x03, 0xF0, 0x07, 0x83, 0xF0, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00}, /*"G",39*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x04, 0x08, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08}, /*"H",40*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"I",41*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x04, 0x00, 0x01, 0x04, 0x00, 0x01, 0x04, 0x00, 0x03, 0x07, 0xFF, 0xFE, 0x07, 0xFF, 0xFC, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"J",42*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x0C, 0x08, 0x00, 0x18, 0x00, 0x00, 0x3E, 0x00, 0x04, 0xC7, 0x80, 0x05, 0x03, 0xC8, 0x06, 0x00, 0xF8, 0x04, 0x00, 0x38, 0x04, 0x00, 0x18, 0x00, 0x00, 0x08}, /*"K",43*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00}, /*"L",44*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0x80, 0x08, 0x07, 0xFC, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x03, 0xF8, 0x00, 0x07, 0xC0, 0x00, 0x78, 0x00, 0x07, 0x80, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08}, /*"M",45*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0x00, 0x08, 0x03, 0xC0, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0xC0, 0x04, 0x00, 0xF0, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x00}, /*"N",46*/ {0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x03, 0x00, 0x30, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00}, /*"O",47*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x04, 0x08, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x06, 0x0C, 0x00, 0x03, 0xF8, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00}, /*"P",48*/ {0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x88, 0x04, 0x00, 0x88, 0x04, 0x00, 0xC8, 0x06, 0x00, 0x3C, 0x03, 0x00, 0x3E, 0x01, 0xFF, 0xE6, 0x00, 0x7F, 0x84, 0x00, 0x00, 0x00}, /*"Q",49*/ {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x00, 0x04, 0x0C, 0x00, 0x04, 0x0F, 0x00, 0x04, 0x0B, 0xC0, 0x06, 0x10, 0xF0, 0x03, 0xF0, 0x38, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x08}, /*"R",50*/ {0x00, 0x00, 0x00, 0x01, 0xE0, 0xF8, 0x03, 0xF0, 0x30, 0x06, 0x30, 0x10, 0x04, 0x18, 0x08, 0x04, 0x18, 0x08, 0x04, 0x0C, 0x08, 0x04, 0x0C, 0x08, 0x02, 0x06, 0x18, 0x02, 0x07, 0xF0, 0x07, 0x81, 0xE0, 0x00, 0x00, 0x00}, /*"S",51*/ {0x01, 0x80, 0x00, 0x06, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x80, 0x00}, /*"T",52*/ {0x04, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x07, 0xFF, 0xF0, 0x04, 0x00, 0x18, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x04, 0x00, 0x10, 0x07, 0xFF, 0xE0, 0x04, 0x00, 0x00}, /*"U",53*/ {0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xFE, 0x00, 0x04, 0x1F, 0xE0, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x38, 0x00, 0x01, 0xE0, 0x04, 0x3E, 0x00, 0x07, 0xC0, 0x00, 0x06, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"V",54*/ {0x04, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xFF, 0xC0, 0x04, 0x1F, 0xF8, 0x00, 0x07, 0xC0, 0x07, 0xF8, 0x00, 0x07, 0xFF, 0x80, 0x04, 0x3F, 0xF8, 0x00, 0x07, 0xC0, 0x04, 0xF8, 0x00, 0x07, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"W",55*/ {0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x07, 0xC0, 0x78, 0x05, 0xF1, 0xC8, 0x00, 0x3E, 0x00, 0x00, 0x1F, 0x80, 0x04, 0x63, 0xE8, 0x07, 0x80, 0xF8, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"X",56*/ {0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x80, 0x00, 0x07, 0xE0, 0x08, 0x04, 0x7C, 0x08, 0x00, 0x1F, 0xF8, 0x00, 0x07, 0xF8, 0x00, 0x18, 0x08, 0x04, 0xE0, 0x08, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"Y",57*/ {0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x06, 0x00, 0x38, 0x04, 0x00, 0xF8, 0x04, 0x03, 0xE8, 0x04, 0x0F, 0x08, 0x04, 0x7C, 0x08, 0x05, 0xF0, 0x08, 0x07, 0xC0, 0x08, 0x07, 0x00, 0x18, 0x04, 0x00, 0x60, 0x00, 0x00, 0x00}, /*"Z",58*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00}, /*"[",59*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x30, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}, /*"\",60*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"]",61*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^",62*/ {0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01}, /*"_",63*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`",64*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x19, 0xF8, 0x00, 0x1B, 0x18, 0x00, 0x22, 0x08, 0x00, 0x26, 0x08, 0x00, 0x24, 0x08, 0x00, 0x24, 0x10, 0x00, 0x3F, 0xF8, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18}, /*"a",65*/ {0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF0, 0x00, 0x18, 0x18, 0x00, 0x10, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x30, 0x18, 0x00, 0x1F, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00}, /*"b",66*/ {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x18, 0x30, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x3C, 0x08, 0x00, 0x1C, 0x10, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"c",67*/ {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x38, 0x18, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x04, 0x10, 0x10, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"d",68*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x12, 0x30, 0x00, 0x22, 0x18, 0x00, 0x22, 0x08, 0x00, 0x22, 0x08, 0x00, 0x32, 0x08, 0x00, 0x1E, 0x10, 0x00, 0x0E, 0x20, 0x00, 0x00, 0x00}, /*"e",69*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x01, 0xFF, 0xF8, 0x03, 0xFF, 0xF8, 0x06, 0x20, 0x08, 0x04, 0x20, 0x08, 0x04, 0x20, 0x08, 0x07, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"f",70*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x6E, 0x00, 0x1F, 0xF3, 0x00, 0x31, 0xB1, 0x00, 0x20, 0xB1, 0x00, 0x20, 0xB1, 0x00, 0x31, 0x91, 0x00, 0x1F, 0x13, 0x00, 0x2E, 0x1E, 0x00, 0x20, 0x0E, 0x00, 0x30, 0x00}, /*"g",71*/ {0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"h",72*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x06, 0x3F, 0xF8, 0x06, 0x3F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"i",73*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x20, 0x01, 0x00, 0x20, 0x01, 0x00, 0x20, 0x03, 0x06, 0x3F, 0xFE, 0x06, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"j",74*/ {0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x01, 0x88, 0x00, 0x03, 0x00, 0x00, 0x2F, 0xC0, 0x00, 0x38, 0xF8, 0x00, 0x20, 0x38, 0x00, 0x20, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"k",75*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"l",76*/ {0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x20, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x20, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x08}, /*"m",77*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"n",78*/ {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x0F, 0xF0, 0x00, 0x18, 0x30, 0x00, 0x30, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x30, 0x08, 0x00, 0x18, 0x30, 0x00, 0x0F, 0xF0, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00}, /*"o",79*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x3F, 0xFF, 0x00, 0x3F, 0xFF, 0x00, 0x10, 0x11, 0x00, 0x20, 0x09, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x30, 0x38, 0x00, 0x1F, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00}, /*"p",80*/ {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x38, 0x18, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x09, 0x00, 0x10, 0x11, 0x00, 0x1F, 0xFF, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}, /*"q",81*/ {0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x08, 0x08, 0x00, 0x10, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00}, /*"r",82*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x78, 0x00, 0x1E, 0x18, 0x00, 0x33, 0x08, 0x00, 0x23, 0x08, 0x00, 0x21, 0x08, 0x00, 0x21, 0x88, 0x00, 0x21, 0x98, 0x00, 0x30, 0xF0, 0x00, 0x38, 0x60, 0x00, 0x00, 0x00}, /*"s",83*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0xFF, 0xF0, 0x03, 0xFF, 0xF8, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"t",84*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x7F, 0xF8, 0x00, 0x00, 0x18, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x20, 0x10, 0x00, 0x3F, 0xF8, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"u",85*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x23, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x70, 0x00, 0x23, 0x80, 0x00, 0x3C, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00}, /*"v",86*/ {0x00, 0x20, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x23, 0xF8, 0x00, 0x00, 0xE0, 0x00, 0x27, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x21, 0xF8, 0x00, 0x01, 0xE0, 0x00, 0x3E, 0x00, 0x00, 0x20, 0x00}, /*"w",87*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x38, 0x38, 0x00, 0x3E, 0x68, 0x00, 0x27, 0x80, 0x00, 0x03, 0xC8, 0x00, 0x2C, 0xF8, 0x00, 0x38, 0x38, 0x00, 0x20, 0x18, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00}, /*"x",88*/ {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x03, 0x00, 0x3C, 0x01, 0x00, 0x3F, 0x83, 0x00, 0x23, 0xEC, 0x00, 0x00, 0x70, 0x00, 0x23, 0x80, 0x00, 0x3C, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00}, /*"y",89*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x08, 0x00, 0x20, 0x38, 0x00, 0x20, 0xF8, 0x00, 0x23, 0xE8, 0x00, 0x2F, 0x88, 0x00, 0x3E, 0x08, 0x00, 0x38, 0x08, 0x00, 0x20, 0x18, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00}, /*"z",90*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x14, 0x00, 0x1F, 0xF7, 0xFC, 0x30, 0x00, 0x06, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"{",91*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"|",92*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x30, 0x00, 0x06, 0x1F, 0xF7, 0xFC, 0x00, 0x14, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}",93*/ {0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x10, 0x00, 0x00}, /*"~",94*/ }; const unsigned char g_asc2_3636[95][90] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ",0*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x07, 0x00, 0x00, 0xFF, 0xFF, 0xC7, 0x00, 0x00, 0xFF, 0xFF, 0xC7, 0x00, 0x00, 0xFF, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!",1*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*""",2*/ {0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x43, 0x0F, 0x00, 0x00, 0x00, 0xC3, 0x7E, 0x00, 0x00, 0x00, 0xC3, 0xF0, 0x00, 0x00, 0x00, 0xCF, 0x80, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x03, 0xF3, 0x07, 0x00, 0x00, 0x1F, 0xC3, 0x3E, 0x00, 0x00, 0xFC, 0xC3, 0xF8, 0x00, 0x00, 0xE0, 0xCF, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x03, 0xF3, 0x00, 0x00, 0x00, 0x1F, 0xC3, 0x00, 0x00, 0x00, 0xFC, 0xC3, 0x00, 0x00, 0x00, 0xE0, 0xC2, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00}, /*"#",3*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x1F, 0xC0, 0x7C, 0x00, 0x00, 0x3F, 0xE0, 0x7E, 0x00, 0x00, 0x7F, 0xE0, 0x0F, 0x00, 0x00, 0x60, 0x70, 0x07, 0x00, 0x00, 0xE0, 0x70, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0xC0, 0x1C, 0x03, 0x00, 0x00, 0xE0, 0x1C, 0x03, 0x00, 0x00, 0x70, 0x0E, 0x07, 0x00, 0x00, 0x7C, 0x0F, 0x8E, 0x00, 0x00, 0x3C, 0x07, 0xFE, 0x00, 0x00, 0x0C, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"$",4*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x70, 0xF0, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x00, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x40, 0x30, 0x00, 0x00, 0x00, 0x60, 0x30, 0x03, 0x00, 0x00, 0x7F, 0xF0, 0x0F, 0x00, 0x00, 0x3F, 0xE0, 0x3C, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x60, 0x00}, /*"%",5*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x0F, 0xFE, 0x00, 0x00, 0x3F, 0x1E, 0x0F, 0x00, 0x00, 0x7F, 0x9C, 0x07, 0x00, 0x00, 0x73, 0xF8, 0x03, 0x00, 0x00, 0xE0, 0xF0, 0x03, 0x00, 0x00, 0xC0, 0x78, 0x03, 0x00, 0x00, 0xC0, 0xFE, 0x03, 0x00, 0x00, 0xE1, 0xCF, 0x03, 0x00, 0x00, 0x7F, 0xC7, 0x87, 0x00, 0x00, 0x7F, 0x83, 0xE7, 0x00, 0x00, 0x3E, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00}, /*"&",6*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'",7*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x03, 0xFF, 0xFE, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x80, 0x00, 0x1F, 0x00, 0x07, 0xC0, 0x00, 0x38, 0x00, 0x00, 0xF0, 0x00, 0x60, 0x00, 0x00, 0x30, 0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"(",8*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x70, 0x00, 0x00, 0x30, 0x00, 0x3C, 0x00, 0x00, 0xF0, 0x00, 0x1F, 0x80, 0x07, 0xC0, 0x00, 0x07, 0xFF, 0xFF, 0x80, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*")",9*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x00, 0x00, 0x00, 0x19, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x19, 0x80, 0x00, 0x00, 0x00, 0x18, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"*",10*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"+",11*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00, 0x00, 0x00, 0x07, 0x70, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*",",12*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"-",13*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".",14*/ {0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"/",15*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xF0, 0x00, 0x00, 0x1F, 0xFF, 0xFC, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x78, 0x00, 0x0E, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xE0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x78, 0x00, 0x1E, 0x00, 0x00, 0x7F, 0xFF, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"0",16*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"1",17*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x00, 0x70, 0x00, 0xE3, 0x00, 0x00, 0xE0, 0x01, 0xC3, 0x00, 0x00, 0xE0, 0x03, 0x83, 0x00, 0x00, 0xC0, 0x07, 0x83, 0x00, 0x00, 0xC0, 0x0F, 0x03, 0x00, 0x00, 0xE0, 0x0E, 0x03, 0x00, 0x00, 0xE0, 0x1C, 0x03, 0x00, 0x00, 0x78, 0x78, 0x03, 0x00, 0x00, 0x7F, 0xF0, 0x03, 0x00, 0x00, 0x3F, 0xE0, 0x03, 0x00, 0x00, 0x0F, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"2",18*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x1E, 0x00, 0x7C, 0x00, 0x00, 0x3E, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x1E, 0x00, 0x00, 0x70, 0x00, 0x07, 0x00, 0x00, 0xE0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xE0, 0x38, 0x03, 0x00, 0x00, 0x60, 0x7C, 0x07, 0x00, 0x00, 0x7F, 0xEE, 0x0E, 0x00, 0x00, 0x3F, 0xCF, 0xFE, 0x00, 0x00, 0x1F, 0x87, 0xFC, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"3",19*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x0E, 0xC0, 0x00, 0x00, 0x00, 0x3C, 0xC0, 0x00, 0x00, 0x00, 0x70, 0xC0, 0x00, 0x00, 0x01, 0xE0, 0xC0, 0x00, 0x00, 0x03, 0x80, 0xC0, 0x00, 0x00, 0x0F, 0x00, 0xC0, 0x00, 0x00, 0x3C, 0x00, 0xC0, 0x00, 0x00, 0x78, 0x00, 0xC0, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"4",20*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x00, 0x3F, 0xF8, 0x3E, 0x00, 0x00, 0xFF, 0xF8, 0x3E, 0x00, 0x00, 0xFC, 0x70, 0x07, 0x00, 0x00, 0xE0, 0x60, 0x03, 0x00, 0x00, 0xE0, 0xE0, 0x03, 0x00, 0x00, 0xE0, 0xE0, 0x03, 0x00, 0x00, 0xE0, 0xE0, 0x03, 0x00, 0x00, 0xE0, 0xE0, 0x03, 0x00, 0x00, 0xE0, 0x70, 0x07, 0x00, 0x00, 0xE0, 0x78, 0x1E, 0x00, 0x00, 0xE0, 0x3F, 0xFE, 0x00, 0x00, 0xE0, 0x1F, 0xFC, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"5",21*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xF0, 0x00, 0x00, 0x1F, 0xFF, 0xFC, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x78, 0x38, 0x0F, 0x00, 0x00, 0x70, 0x30, 0x07, 0x00, 0x00, 0xE0, 0x60, 0x03, 0x00, 0x00, 0xC0, 0x60, 0x03, 0x00, 0x00, 0xC0, 0x60, 0x03, 0x00, 0x00, 0xE0, 0x60, 0x03, 0x00, 0x00, 0xE0, 0x70, 0x07, 0x00, 0x00, 0x70, 0x78, 0x0F, 0x00, 0x00, 0x7C, 0x3F, 0xFE, 0x00, 0x00, 0x3C, 0x1F, 0xFC, 0x00, 0x00, 0x0C, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"6",22*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x3F, 0x00, 0x00, 0xE0, 0x01, 0xFF, 0x00, 0x00, 0xE0, 0x07, 0xFF, 0x00, 0x00, 0xE0, 0x1F, 0xC0, 0x00, 0x00, 0xE0, 0x7E, 0x00, 0x00, 0x00, 0xE1, 0xF0, 0x00, 0x00, 0x00, 0xE3, 0xC0, 0x00, 0x00, 0x00, 0xE7, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"7",23*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x1F, 0x87, 0xFC, 0x00, 0x00, 0x7F, 0xCF, 0xFE, 0x00, 0x00, 0x7F, 0xFC, 0x0F, 0x00, 0x00, 0xE0, 0x78, 0x07, 0x00, 0x00, 0xE0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x30, 0x03, 0x00, 0x00, 0xC0, 0x30, 0x03, 0x00, 0x00, 0xE0, 0x38, 0x03, 0x00, 0x00, 0xE0, 0x78, 0x07, 0x00, 0x00, 0x7D, 0xFC, 0x0F, 0x00, 0x00, 0x7F, 0xCF, 0xFE, 0x00, 0x00, 0x3F, 0x8F, 0xFC, 0x00, 0x00, 0x06, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"8",24*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x18, 0x00, 0x00, 0x3F, 0xFC, 0x1C, 0x00, 0x00, 0x7F, 0xFE, 0x1E, 0x00, 0x00, 0x70, 0x0E, 0x0F, 0x00, 0x00, 0xE0, 0x07, 0x03, 0x00, 0x00, 0xE0, 0x07, 0x03, 0x00, 0x00, 0xC0, 0x07, 0x03, 0x00, 0x00, 0xC0, 0x07, 0x03, 0x00, 0x00, 0xE0, 0x06, 0x03, 0x00, 0x00, 0xE0, 0x06, 0x07, 0x00, 0x00, 0x78, 0x1C, 0x1E, 0x00, 0x00, 0x7F, 0xFF, 0xFC, 0x00, 0x00, 0x3F, 0xFF, 0xF8, 0x00, 0x00, 0x0F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"9",25*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x07, 0x00, 0x00, 0x03, 0xC0, 0x07, 0x00, 0x00, 0x03, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":",26*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x07, 0x10, 0x00, 0x03, 0xC0, 0x07, 0x70, 0x00, 0x03, 0xC0, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";",27*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x06, 0xE0, 0x00, 0x00, 0x00, 0x0E, 0x60, 0x00, 0x00, 0x00, 0x0C, 0x70, 0x00, 0x00, 0x00, 0x1C, 0x30, 0x00, 0x00, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x38, 0x18, 0x00, 0x00, 0x00, 0x30, 0x1C, 0x00, 0x00, 0x00, 0x70, 0x0C, 0x00, 0x00, 0x00, 0x60, 0x0E, 0x00, 0x00, 0x00, 0xE0, 0x06, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x01, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"<",28*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"=",29*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0xE0, 0x06, 0x00, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x70, 0x0C, 0x00, 0x00, 0x00, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x38, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x1C, 0x30, 0x00, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x00, 0x0E, 0x60, 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*">",30*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x01, 0xE7, 0x00, 0x00, 0xC0, 0x07, 0xE7, 0x00, 0x00, 0xC0, 0x0F, 0xE7, 0x00, 0x00, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0xE0, 0x3C, 0x00, 0x00, 0x00, 0x70, 0x78, 0x00, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"?",31*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x03, 0xC1, 0xE0, 0x00, 0x00, 0x0E, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x00, 0x30, 0x1F, 0xC4, 0x00, 0x00, 0x20, 0x7F, 0xE6, 0x00, 0x00, 0x60, 0xF8, 0xE2, 0x00, 0x00, 0x61, 0xC0, 0x63, 0x00, 0x00, 0x43, 0x80, 0x23, 0x00, 0x00, 0xC3, 0x00, 0x21, 0x00, 0x00, 0xC6, 0x00, 0x61, 0x00, 0x00, 0xC6, 0x00, 0x61, 0x00, 0x00, 0xC6, 0x00, 0xC1, 0x00, 0x00, 0xC6, 0x03, 0xE1, 0x00, 0x00, 0xC7, 0x0F, 0xE1, 0x00}, /*"@",32*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x07, 0xFF, 0x80, 0x00, 0x00, 0x3F, 0xE1, 0x80, 0x00, 0x00, 0xFE, 0x01, 0x80, 0x00, 0x00, 0xF0, 0x01, 0x80, 0x00, 0x00, 0xF0, 0x01, 0x80, 0x00, 0x00, 0xFE, 0x01, 0x80, 0x00, 0x00, 0x7F, 0xE1, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0x80, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00}, /*"A",33*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xE0, 0x38, 0x03, 0x00, 0x00, 0xE0, 0x38, 0x07, 0x00, 0x00, 0xF0, 0x7C, 0x07, 0x00, 0x00, 0x7F, 0xFE, 0x0E, 0x00, 0x00, 0x7F, 0xCF, 0xFE, 0x00, 0x00, 0x1F, 0x87, 0xFC, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00}, /*"B",34*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x1F, 0xFF, 0xF8, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x7C, 0x00, 0x3E, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xF0, 0x00, 0x1E, 0x00, 0x00, 0x7E, 0x01, 0xFE, 0x00, 0x00, 0x3E, 0x01, 0xFC, 0x00, 0x00, 0x0E, 0x01, 0xF0, 0x00}, /*"C",35*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x70, 0x00, 0x0E, 0x00, 0x00, 0x78, 0x00, 0x1E, 0x00, 0x00, 0x3F, 0x80, 0xFC, 0x00, 0x00, 0x1F, 0xFF, 0xF8, 0x00}, /*"D",36*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"E",37*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"F",38*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x7C, 0x00, 0x3E, 0x00, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x0C, 0x03, 0x00, 0x00, 0xC0, 0x0C, 0x03, 0x00, 0x00, 0xC0, 0x0C, 0x03, 0x00, 0x00, 0xC0, 0x0C, 0x03, 0x00, 0x00, 0xE0, 0x0C, 0x06, 0x00, 0x00, 0x78, 0x0C, 0x1E, 0x00, 0x00, 0x7E, 0x0F, 0xF8, 0x00, 0x00, 0x3E, 0x0F, 0xFF, 0x00}, /*"G",39*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00}, /*"H",40*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"I",41*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"J",42*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x07, 0x9F, 0x80, 0x00, 0x00, 0x0F, 0x07, 0xC0, 0x00, 0x00, 0x1E, 0x03, 0xF0, 0x00, 0x00, 0x7C, 0x00, 0xFC, 0x00, 0x00, 0xF8, 0x00, 0x7E, 0x00, 0x00, 0xE0, 0x00, 0x1F, 0x00, 0x00, 0xC0, 0x00, 0x07, 0x00}, /*"K",43*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"L",44*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x07, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x7F, 0xC0, 0x00}, /*"M",45*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00}, /*"N",46*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x70, 0x00, 0x0E, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xF0, 0x00, 0x0E, 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00}, /*"O",47*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0x70, 0x38, 0x00, 0x00, 0x00, 0x78, 0xF8, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00}, /*"P",48*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0xF0, 0x00, 0x0E, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x03, 0x00, 0x00, 0xC0, 0x00, 0x33, 0x00, 0x00, 0xC0, 0x00, 0x3B, 0x00, 0x00, 0xE0, 0x00, 0x1F, 0x00, 0x00, 0x70, 0x00, 0x1E, 0x00, 0x00, 0x7F, 0x00, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0x00}, /*"Q",49*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0xE0, 0x3E, 0x00, 0x00, 0x00, 0x70, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0xE7, 0xFE, 0x00, 0x00, 0x3F, 0xC7, 0xFF, 0x00}, /*"R",50*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xF8, 0x00, 0x00, 0x3F, 0xC0, 0xFC, 0x00, 0x00, 0x7F, 0xE0, 0xFE, 0x00, 0x00, 0xF9, 0xF0, 0x0F, 0x00, 0x00, 0xE0, 0x70, 0x07, 0x00, 0x00, 0xC0, 0x70, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x38, 0x03, 0x00, 0x00, 0xC0, 0x1C, 0x03, 0x00, 0x00, 0xC0, 0x1C, 0x03, 0x00, 0x00, 0xE0, 0x1E, 0x07, 0x00, 0x00, 0x7C, 0x0F, 0x0E, 0x00, 0x00, 0x7C, 0x0F, 0xFE, 0x00, 0x00, 0x3C, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00}, /*"S",51*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"T",52*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0xFC, 0x00}, /*"U",53*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00}, /*"V",54*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x00, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00}, /*"W",55*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00, 0x00, 0xF0, 0x00, 0x1F, 0x00, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x00, 0x3E, 0x00, 0xFC, 0x00, 0x00, 0x0F, 0x83, 0xF0, 0x00, 0x00, 0x07, 0xC7, 0xC0, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x07, 0xE7, 0xC0, 0x00, 0x00, 0x0F, 0x83, 0xF0, 0x00, 0x00, 0x3E, 0x00, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x00, 0xF0, 0x00, 0x1F, 0x00, 0x00, 0xE0, 0x00, 0x07, 0x00}, /*"X",56*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00}, /*"Y",57*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x07, 0x00, 0x00, 0xC0, 0x00, 0x1F, 0x00, 0x00, 0xC0, 0x00, 0x3F, 0x00, 0x00, 0xC0, 0x00, 0xFB, 0x00, 0x00, 0xC0, 0x01, 0xE3, 0x00, 0x00, 0xC0, 0x07, 0xC3, 0x00, 0x00, 0xC0, 0x0F, 0x03, 0x00, 0x00, 0xC0, 0x3E, 0x03, 0x00, 0x00, 0xC0, 0x78, 0x03, 0x00, 0x00, 0xC1, 0xF0, 0x03, 0x00, 0x00, 0xC3, 0xC0, 0x03, 0x00, 0x00, 0xCF, 0x80, 0x03, 0x00, 0x00, 0xDE, 0x00, 0x03, 0x00, 0x00, 0xFC, 0x00, 0x03, 0x00, 0x00, 0xF0, 0x00, 0x03, 0x00, 0x00, 0xE0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"Z",58*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xF0, 0x00, 0x7F, 0xFF, 0xFF, 0xF0, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"[",59*/ {0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"\",60*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x10, 0x00, 0x7F, 0xFF, 0xFF, 0xF0, 0x00, 0x7F, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"]",61*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^",62*/ {0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30}, /*"_",63*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`",64*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x00, 0x00, 0x01, 0xE1, 0xFF, 0x00, 0x00, 0x03, 0x81, 0xC7, 0x00, 0x00, 0x03, 0x03, 0x83, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x03, 0x06, 0x03, 0x00, 0x00, 0x03, 0x06, 0x06, 0x00, 0x00, 0x03, 0xCF, 0xFC, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"a",65*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xF0, 0x1C, 0x00, 0x00, 0x01, 0x80, 0x06, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0x03, 0xC0, 0x0F, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"b",66*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x00, 0x01, 0xFC, 0xFE, 0x00, 0x00, 0x03, 0xC0, 0x07, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0x03, 0xC0, 0x0F, 0x00, 0x00, 0x01, 0xF0, 0x3E, 0x00, 0x00, 0x00, 0xF0, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"c",67*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x03, 0xC0, 0x07, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x01, 0xC0, 0x06, 0x00, 0x00, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"d",68*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x01, 0xFF, 0xBE, 0x00, 0x00, 0x03, 0x86, 0x07, 0x00, 0x00, 0x03, 0x06, 0x03, 0x00, 0x00, 0x03, 0x06, 0x03, 0x00, 0x00, 0x03, 0x06, 0x03, 0x00, 0x00, 0x03, 0x06, 0x03, 0x00, 0x00, 0x03, 0x86, 0x07, 0x00, 0x00, 0x01, 0xFE, 0x3E, 0x00, 0x00, 0x00, 0xFE, 0x3E, 0x00, 0x00, 0x00, 0x3E, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"e",69*/ {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xE3, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"f",70*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x80, 0x00, 0x00, 0xFF, 0xFC, 0xE0, 0x00, 0x01, 0xFF, 0xFE, 0xF0, 0x00, 0x03, 0xC0, 0x0F, 0x30, 0x00, 0x03, 0x00, 0x03, 0x30, 0x00, 0x03, 0x00, 0x03, 0x30, 0x00, 0x03, 0x00, 0x03, 0x30, 0x00, 0x03, 0x00, 0x03, 0x30, 0x00, 0x03, 0x00, 0x02, 0x30, 0x00, 0x01, 0x80, 0x0E, 0x70, 0x00, 0x00, 0xFC, 0x7F, 0xE0, 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"g",71*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"h",72*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0xFF, 0xFF, 0x00, 0x00, 0xE3, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"i",73*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0xE3, 0xFF, 0xFF, 0xF0, 0x00, 0xE3, 0xFF, 0xFF, 0xE0, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"j",74*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0xF1, 0xF0, 0x00, 0x00, 0x01, 0xE0, 0x7C, 0x00, 0x00, 0x03, 0xC0, 0x3F, 0x00, 0x00, 0x03, 0x80, 0x0F, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"k",75*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"l",76*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00}, /*"m",77*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"n",78*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x01, 0xC0, 0x0F, 0x00, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0x01, 0xC0, 0x0F, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"o",79*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF0, 0x00, 0x03, 0xFF, 0xFF, 0xF0, 0x00, 0x01, 0xF8, 0x7C, 0x00, 0x00, 0x03, 0x80, 0x06, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x03, 0xC0, 0x1E, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"p",80*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x03, 0xC0, 0x0E, 0x00, 0x00, 0x03, 0x80, 0x07, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x01, 0x80, 0x06, 0x00, 0x00, 0x00, 0xF8, 0x7C, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF0, 0x00, 0x03, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"q",81*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"r",82*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xFC, 0x1C, 0x00, 0x00, 0x01, 0xFE, 0x1E, 0x00, 0x00, 0x03, 0xFE, 0x07, 0x00, 0x00, 0x03, 0x0E, 0x03, 0x00, 0x00, 0x03, 0x07, 0x03, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x03, 0x03, 0x83, 0x00, 0x00, 0x03, 0x03, 0x83, 0x00, 0x00, 0x03, 0x81, 0xC3, 0x00, 0x00, 0x01, 0xE1, 0xFE, 0x00, 0x00, 0x01, 0xE0, 0xFE, 0x00, 0x00, 0x00, 0x60, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"s",83*/ {0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFE, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"t",84*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFE, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"u",85*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"v",86*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00}, /*"w",87*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x07, 0x00, 0x00, 0x03, 0xC0, 0x1F, 0x00, 0x00, 0x01, 0xF0, 0x3C, 0x00, 0x00, 0x00, 0x78, 0xF8, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x7C, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x3C, 0x00, 0x00, 0x03, 0xE0, 0x1F, 0x00, 0x00, 0x03, 0x80, 0x07, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"x",88*/ {0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x30, 0x00, 0x03, 0xF8, 0x00, 0x30, 0x00, 0x01, 0xFF, 0x00, 0x30, 0x00, 0x00, 0x3F, 0xE0, 0x30, 0x00, 0x00, 0x03, 0xFC, 0x70, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"y",89*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x3F, 0x00, 0x00, 0x03, 0x00, 0x7B, 0x00, 0x00, 0x03, 0x01, 0xE3, 0x00, 0x00, 0x03, 0x03, 0xC3, 0x00, 0x00, 0x03, 0x0F, 0x03, 0x00, 0x00, 0x03, 0x1E, 0x03, 0x00, 0x00, 0x03, 0x7C, 0x03, 0x00, 0x00, 0x03, 0xF0, 0x03, 0x00, 0x00, 0x03, 0xE0, 0x03, 0x00, 0x00, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"z",90*/ {0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x01, 0x00, 0x00, 0x7F, 0xFB, 0xFF, 0xC0, 0x00, 0x7F, 0xF1, 0xFF, 0xC0, 0x00, 0xC0, 0x00, 0x00, 0x60, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"{",91*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"|",92*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00, 0xE0, 0x40, 0x00, 0xC0, 0x00, 0x7F, 0xF1, 0xFF, 0xC0, 0x00, 0x3F, 0xFB, 0xFF, 0x80, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}",93*/ {0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"/",94*/ }; #ifdef __cplusplus } #endif #endif /*_MODULE__FONT_H*/
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/lcd/fontlib.h
C
apache-2.0
100,326
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "board_mgr.h" #include "be_inl.h" #include "fontlib.h" #define MOD_STR "LCD" typedef struct lcd_handle { uint32_t width; uint32_t height; } lcd_handle_t; static lcd_handle_t *lcd_handle = NULL; static int8_t lcd_init(uint32_t width, uint32_t height) { if (NULL != lcd_handle) { return -1; } lcd_handle_t *new_handle = aos_calloc(1, sizeof(*new_handle)); if (NULL == new_handle) { return -1; } amp_hal_lcd_init(NULL); new_handle->height = height; new_handle->width = width; lcd_handle = new_handle; return 0; } static int8_t lcd_deinit(void) { if (NULL != lcd_handle) { aos_free(lcd_handle); lcd_handle = NULL; } return 0; } static int8_t lcd_draw_char(uint16_t x, uint16_t y, uint8_t num, uint8_t size, uint32_t fcolor) { uint8_t i = 0; uint8_t j = 0; uint8_t temp = 0; uint16_t xtemp = x; uint16_t ytemp = y; uint8_t char_len = 0; uint8_t *pos = NULL; num = num - ' '; if (12 == size) { pos = (uint8_t *)&g_asc2_1206[num]; char_len = 12; } else if (16 == size) { pos = (uint8_t *)&g_asc2_1608[num]; char_len = 16; } else if (24 == size) { pos = (uint8_t *)&g_asc2_2412[num]; char_len = 36; } else if (36 == size) { pos = (uint8_t *)&g_asc2_3636[num]; char_len = 90; } else { return -1; } for (i = 0; i < char_len; ++i) { temp = *pos++; for (j = 0; j < 8; ++j) { if (temp & 0x80) { amp_hal_lcd_draw_point(xtemp, ytemp, fcolor); } temp <<= 1; ytemp += 1; if (size == (ytemp - y)) { ytemp = y; xtemp += 1; break; } } } return 0; } static int8_t lcd_draw_str(uint16_t x, uint16_t y, uint8_t *str, uint8_t size, uint32_t color, int8_t new_line) { uint16_t xstart = x; uint16_t ystart = y; uint16_t xres = 0; uint16_t yres = 0; if (NULL == lcd_handle) { return -1; } xres = lcd_handle->width; yres = lcd_handle->height; while ((*str <= '~') && (*str >= ' ')) { if (new_line) { if (xstart > xres) { xstart = x; ystart += size; } if (ystart > yres) { break; } } lcd_draw_char(xstart, ystart, *str, size, color); xstart += size / 2; str += 1; } return 0; } static void lcd_draw_rect(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color, uint8_t need_fill) { int32_t i = 0; if (need_fill) { for (i = y1; i <= y2; i++) amp_hal_lcd_draw_line(x1, i, color, x2 - x1 + 1); } else { for (i = x1; i <= x2; ++i) { amp_hal_lcd_draw_point(i, y1, color); amp_hal_lcd_draw_point(i, y2, color); } for (i = y1; i <= y2; ++i) { amp_hal_lcd_draw_point(x1, i, color); amp_hal_lcd_draw_point(x2, i, color); } } } static duk_ret_t native_lcd_open(duk_context *ctx) { int ret = -1; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object"); goto out; } duk_get_prop_string(ctx, 0, "height"); duk_get_prop_string(ctx, 0, "width"); /* [ parameter height width ] */ if (!duk_is_number(ctx, -1) || !duk_is_number(ctx, -2)) { amp_warn(MOD_STR, "parameter object must be `{height:number,width:number}`"); duk_pop_2(ctx); goto out; } uint32_t width = duk_get_int(ctx, -1); uint32_t height = duk_get_int(ctx, -2); duk_pop_2(ctx); ret = lcd_init(width, height); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_lcd_close(duk_context *ctx) { lcd_deinit(); duk_push_int(ctx, 0); return 1; } static duk_ret_t native_lcd_fill(duk_context *ctx) { int ret = -1; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object"); goto out; } /* [ parameter sx sy ex ey color fill ] */ duk_get_prop_string(ctx, 0, "sx"); duk_get_prop_string(ctx, 0, "sy"); duk_get_prop_string(ctx, 0, "ex"); duk_get_prop_string(ctx, 0, "ey"); duk_get_prop_string(ctx, 0, "color"); duk_get_prop_string(ctx, 0, "fill"); if (!duk_is_number(ctx, -6) /* sx */ || !duk_is_number(ctx, -5) /* sy */ || !duk_is_number(ctx, -4) /* ex */ || !duk_is_number(ctx, -3) /* ey */ || !duk_is_number(ctx, -2) /* color */ ) { amp_warn(MOD_STR, "parameter object must be " "`{sx:number,sy:number,ex:number,ey:number,color:number}`"); goto pop_out; } int sx = duk_get_int(ctx, -6); int sy = duk_get_int(ctx, -5); int ex = duk_get_int(ctx, -4); int ey = duk_get_int(ctx, -3); int color = duk_get_int(ctx, -2); int is_fill = duk_get_int_default(ctx, -1, 0); lcd_draw_rect(sx, sy, ex, ey, color, is_fill); ret = 0; pop_out: duk_pop_n(ctx, 6); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_lcd_show(duk_context *ctx) { int ret = -1; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object"); goto out; } /* [ parameter x y color newline str size ] */ duk_get_prop_string(ctx, 0, "x"); duk_get_prop_string(ctx, 0, "y"); duk_get_prop_string(ctx, 0, "color"); duk_get_prop_string(ctx, 0, "newline"); duk_get_prop_string(ctx, 0, "str"); duk_get_prop_string(ctx, 0, "size"); if (!duk_is_number(ctx, -6) /* x */ || !duk_is_number(ctx, -5) /* y */ || !duk_is_number(ctx, -4) /* color */ || !duk_is_number(ctx, -3) /* newline */ || !duk_is_string(ctx, -2) /* str */ || !duk_is_number(ctx, -1) /* size */ ) { amp_warn(MOD_STR, "parameter object must be " "`{x:number,y:number,color:number,newline:number,str:string,size:" "number}`"); goto pop_out; } int x_pos = duk_get_int(ctx, -6); int y_pos = duk_get_int(ctx, -5); int color = duk_get_int(ctx, -4); int is_newline = duk_get_int(ctx, -3); const char *str = duk_get_string(ctx, -2); int front_size = duk_get_int(ctx, -1); if ((16 != front_size) && (12 != front_size) && (24 != front_size) && (36 != front_size)) { ret = -1; goto pop_out; } lcd_draw_str(x_pos, y_pos, (uint8_t *)str, front_size, color, is_newline); ret = 0; pop_out: duk_pop_n(ctx, 6); out: duk_push_int(ctx, ret); return 1; } void module_lcd_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_lcd_open, 1); AMP_ADD_FUNCTION("close", native_lcd_close, 1); AMP_ADD_FUNCTION("show", native_lcd_show, 1); AMP_ADD_FUNCTION("fill", native_lcd_fill, 1); duk_put_prop_string(ctx, -2, "LCD"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/lcd/module_lcd.c
C
apache-2.0
7,375
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_gpio.h" #include "aos_system.h" #include "amp_task.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "ONEWIRE" /* 使用方法:yaml文件中添加JSE_HW_ADDON_ONEWIRE、JSE_HW_ADDON_GPIO、RHINO_CONFIG_HW_COUNT 参考如下: def_config: # 组件的可配置项 CONFIG_ENGINE_DUKTAPE: 1 #CONFIG_ENGINE_QUICKJS: 1 CONFIG_VERSION: '1.0' JSE_HW_ADDON_ONEWIRE: 1 JSE_HW_ADDON_GPIO: 1 RHINO_CONFIG_HW_COUNT: 1 */ static int A,B,C,D,E,F,G,H,I,J; static uint16_t gpio_init_flag = 0; #if (RHINO_CONFIG_HW_COUNT > 0) #define CONFIG_FAST_SYSTICK_HZ (hal_cmu_get_crystal_freq() / 4) #define FAST_TICKS_TO_US(tick) ((uint32_t)(tick) * 10 / (CONFIG_FAST_SYSTICK_HZ / 1000 / 100)) #define RHINO_CPU_INTRPT_DISABLE() do{ cpsr = cpu_intrpt_save(); }while(0) #define RHINO_CPU_INTRPT_ENABLE() do{ cpu_intrpt_restore(cpsr); }while(0) void oneWireUdelay(unsigned long x) { unsigned long now,t; int cpsr; RHINO_CPU_INTRPT_DISABLE(); t = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); now = t; while ((now - t) < x) { now = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); } RHINO_CPU_INTRPT_ENABLE(); } #endif static void oneWireGpioSet(gpio_dev_t *gpio_device, unsigned char leve) { int ret = 0; if(leve == 1) { ret = aos_hal_gpio_output_high(gpio_device); } else if(leve == 0) { ret = aos_hal_gpio_output_low(gpio_device); } //amp_warn(MOD_STR, "GPIO:%d, output config:0x%x, leve: %d, ret:%d", gpio_device->port, gpio_device->config, leve, ret); } static uint32_t oneWireGpioGet(gpio_dev_t *gpio_device) { int ret = 0; unsigned int value = 0; ret = aos_hal_gpio_input_get(gpio_device, &value); //amp_warn(MOD_STR, "GPIO:%d, input config:0x%x, ret: %d, value:%d\r\n", gpio_device->port, gpio_device->config, ret, value); return (ret == 0)? value: ret; } //----------------------------------------------------------------------------- // Generate a 1-Wire reset, return 1 if no presence detect was found, // return 0 otherwise. // (NOTE: Does not handle alarm presence from DS2404/DS1994) // int oneWireTouchReset(gpio_dev_t *gpio_device) { int result1; int result2; oneWireUdelay(G); oneWireGpioSet(gpio_device, 0x00); // Drives DQ low oneWireUdelay(H); oneWireGpioSet(gpio_device, 0x01); // Releases the bus oneWireUdelay(I); result1 = oneWireGpioGet(gpio_device) ^ 0x01; // Sample for presence pulse from slave oneWireUdelay(J); // Complete the reset sequence recovery result2 = oneWireGpioGet(gpio_device) ^ 0x01; // Sample for presence pulse from slave amp_warn(MOD_STR, "oneWireTouchReset[%d] result1 = %d, result2 = %d", __LINE__, result1, result2); return !((result1 == 1) && (result2 == 0)); // Return sample presence pulse result } //----------------------------------------------------------------------------- // Send a 1-Wire write bit. Provide 10us recovery time. // void OneWireWriteBit(gpio_dev_t *gpio_device, int bit) { //amp_warn(MOD_STR, "OneWireWriteBit[%d] bit = %d", __LINE__, bit); if (bit) { // Write '1' bit oneWireGpioSet(gpio_device, 0x00); // Drives DQ low oneWireUdelay(1); oneWireGpioSet(gpio_device, 0x01); // Releases the bus oneWireUdelay(30); // Complete the time slot and 10us recovery } else { // Write '0' bit oneWireGpioSet(gpio_device, 0x00); // Drives DQ low oneWireUdelay(30); oneWireGpioSet(gpio_device, 0x01); // Releases the bus oneWireUdelay(1); } } //----------------------------------------------------------------------------- // Read a bit from the 1-Wire bus and return it. Provide 10us recovery time. // int OneWireReadBit(gpio_dev_t *gpio_device) { int result; oneWireGpioSet(gpio_device, 0x00); // Drives DQ low oneWireUdelay(1); oneWireGpioSet(gpio_device, 0x01); // Releases the bus oneWireUdelay(2); result = oneWireGpioGet(gpio_device) & 0x01; // Sample the bit value from the slave oneWireUdelay(40); // Complete the time slot and 10us recovery //amp_warn(MOD_STR, "OneWireReadBit[%d] result = %d", __LINE__, result); return result; } //----------------------------------------------------------------------------- // Write 1-Wire data byte // void OneWireWriteByte(gpio_dev_t *gpio_device, int data) { int loop; // Loop to write each bit in the byte, LS-bit first for (loop = 0; loop < 8; loop++) { OneWireWriteBit(gpio_device, data & 0x01); // shift the data byte for the next bit data >>= 1; } } //----------------------------------------------------------------------------- // Read 1-Wire data byte and return it // int OneWireReadByte(gpio_dev_t *gpio_device) { int loop, result=0; for (loop = 0; loop < 8; loop++) { // shift the result to get it ready for the next bit result >>= 1; // if result is one, then set MS bit if (OneWireReadBit(gpio_device)) { result |= 0x80; } } //amp_warn(MOD_STR, "OneWireReadByte[%d] data = 0x%x", __LINE__, result); return result; } void delayus(unsigned int z) { while(z--); } //----------------------------------------------------------------------------- // Set the 1-Wire timing to 'standard' (standard=1) or 'overdrive' (standard=0). // void oneWireSetSpeed(int standard) { unsigned long now,t; // Adjust tick values depending on speed if (standard) { // Standard Speed // A = 6 * 4; // B = 64 * 4; // C = 60 * 4; // D = 10 * 4; // E = 9 * 4; // F = 55 * 4; // G = 0; // H = 480 * 4; // I = 70 * 4; // J = 410 * 4; A = 6; B = 64; C = 60; D = 10; E = 9; F = 55; G = 0; H = 480; I = 70; J = 410; } else { // Overdrive Speed A = 1.5 * 4; B = 7.5 * 4; C = 7.5 * 4; D = 2.5 * 4; E = 0.75 * 4; F = 7 * 4; G = 2.5 * 4; H = 70 * 4; I = 8.5 * 4; J = 40 * 4; } now = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); oneWireUdelay(A); t = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); amp_warn(MOD_STR, "[%d]hal_cmu_get_crystal_freq[%d] delta = %d", A, hal_cmu_get_crystal_freq(), (t-now)); now = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); oneWireUdelay(B); t = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); amp_warn(MOD_STR, "[%d]hal_cmu_get_crystal_freq[%d] delta = %d", B, hal_cmu_get_crystal_freq(), (t-now)); now = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); oneWireUdelay(C); t = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); amp_warn(MOD_STR, "[%d]hal_cmu_get_crystal_freq[%d] delta = %d", C, hal_cmu_get_crystal_freq(), (t-now)); now = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); oneWireUdelay(D); t = FAST_TICKS_TO_US(hal_fast_sys_timer_get()); amp_warn(MOD_STR, "[%d]hal_cmu_get_crystal_freq[%d] delta = %d", D, hal_cmu_get_crystal_freq(), (t-now)); } //----------------------------------------------------------------------------- // Set the 1-Wire timing to 'standard' (standard=1) or 'overdrive' (standard=0). // static duk_ret_t native_onewire_gpio_setspeed(duk_context *ctx) { int standard = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } standard = duk_get_int(ctx, 1); oneWireSetSpeed(standard); out: duk_push_int(ctx, 0); return 1; } static duk_ret_t native_onewire_gpio_open(duk_context *ctx) { int8_t ret = -1; item_handle_t gpio_handle; gpio_handle.handle = NULL; gpio_dev_t *gpio_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_GPIO, id, &gpio_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!, id %s", id); goto out; } amp_debug(MOD_STR, "gpio handle:%p\n", gpio_handle.handle); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_gpio_init(gpio_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_gpio_init fail!"); goto out; } // gpio_device->priv = NULL; gpio_init_flag |= (1 << gpio_device->port); amp_error(MOD_STR, "aos_hal_gpio_init ret = %d!", ret); out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_GPIO, &gpio_handle); } else { duk_push_pointer(ctx, (void *)gpio_handle.handle); } return 1; } static duk_ret_t native_onewire_gpio_close(duk_context *ctx) { int32_t ret = -1; item_handle_t gpio_handle; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_gpio_finalize(gpio_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_gpio_finalize fail!"); goto out; } board_disattach_item(MODULE_GPIO, &gpio_handle); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_onewire_gpio_reset(duk_context *ctx) { item_handle_t gpio_handle; int result; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } result = oneWireTouchReset(gpio_device); out: duk_push_int(ctx, result); return 1; } static duk_ret_t native_onewire_gpio_readbyte(duk_context *ctx) { item_handle_t gpio_handle; int result; gpio_dev_t *gpio_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } result = OneWireReadByte(gpio_device); //amp_warn(MOD_STR, "native_onewire_gpio_readbyte[%d] data = 0x%x", __LINE__, result); out: duk_push_int(ctx, result); return 1; } static duk_ret_t native_onewire_gpio_writebyte(duk_context *ctx) { item_handle_t gpio_handle; int result = 0; gpio_dev_t *gpio_device = NULL; int32_t level = 0; if (!duk_is_pointer(ctx, 0) || !duk_get_int(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } gpio_handle.handle = duk_get_pointer(ctx, 0); gpio_device = board_get_node_by_handle(MODULE_GPIO, &gpio_handle); if (NULL == gpio_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } level = duk_get_int(ctx, 1); //amp_warn(MOD_STR, "native_onewire_gpio_writebyte[%d] data = 0x%x", __LINE__, level); OneWireWriteByte(gpio_device, level); result = 1; out: duk_push_int(ctx, result); return 1; } void module_onewire_register(void) { amp_debug(MOD_STR, "module_onewire_register"); duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_onewire_gpio_open, 1); AMP_ADD_FUNCTION("setspeed", native_onewire_gpio_setspeed, 2); AMP_ADD_FUNCTION("reset", native_onewire_gpio_reset, 1); AMP_ADD_FUNCTION("readByte", native_onewire_gpio_readbyte, 1); AMP_ADD_FUNCTION("writeByte", native_onewire_gpio_writebyte, 2); AMP_ADD_FUNCTION("close", native_onewire_gpio_close, 1); duk_put_prop_string(ctx, -2, "ONEWIRE"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/onewire/module_onewire.c
C
apache-2.0
12,993
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ /* #define LOG_NDEBUG 0 */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_pwm.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "PWM" typedef struct sim_info { int freq; int duty; } pwm_module_t; static duk_ret_t native_pwm_open(duk_context *ctx) { int8_t ret = -1; int8_t result = -1; item_handle_t pwm_handle; pwm_handle.handle = NULL; pwm_dev_t *pwm_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_PWM, id, &pwm_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!\n"); goto out; } amp_debug(MOD_STR, "gpio handle:%u\n", pwm_handle.handle); pwm_device = board_get_node_by_handle(MODULE_PWM, &pwm_handle); if (NULL == pwm_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } amp_debug(MOD_STR, "%s:%d:%d:%f\n", id, pwm_device->port, pwm_device->config.freq, pwm_device->config.duty_cycle); ret = aos_hal_pwm_init(pwm_device); out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_PWM, &pwm_handle); } else { duk_push_pointer(ctx, (void *)pwm_handle.handle); } return 1; } static duk_ret_t native_pwm_close(duk_context *ctx) { int8_t ret = -1; item_handle_t pwm_handle; pwm_dev_t *pwm_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } pwm_handle.handle = duk_get_pointer(ctx, 0); pwm_device = board_get_node_by_handle(MODULE_PWM, &pwm_handle); if (NULL == pwm_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } ret = aos_hal_pwm_stop(pwm_device); ret |= aos_hal_pwm_finalize(pwm_device); board_disattach_item(MODULE_PWM, &pwm_handle); amp_debug(MOD_STR, "aos_hal_pwm_finalize ret: %d\n", ret); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pwm_getConfig(duk_context *ctx) { int32_t ret = -1; item_handle_t pwm_handle; pwm_module_t pwm_config; pwm_dev_t *pwm_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } pwm_handle.handle = duk_get_pointer(ctx, 0); pwm_device = board_get_node_by_handle(MODULE_PWM, &pwm_handle); if (NULL == pwm_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } pwm_config.duty = (int)(pwm_device->config.duty_cycle * 100); pwm_config.freq = (int)(pwm_device->config.freq); duk_push_object(ctx); duk_push_int(ctx, pwm_config.freq); duk_put_prop_string(ctx, -2, "freq"); duk_push_int(ctx, pwm_config.duty); duk_put_prop_string(ctx, -2, "duty"); return 1; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pwm_setConfig(duk_context *ctx) { int8_t ret = -1; int32_t freq; int duty = 0; item_handle_t pwm_handle; pwm_dev_t *pwm_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } pwm_handle.handle = duk_get_pointer(ctx, 0); pwm_device = board_get_node_by_handle(MODULE_PWM, &pwm_handle); if (NULL == pwm_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!\n"); goto out; } duk_get_prop_string(ctx, 1, "freq"); duk_get_prop_string(ctx, 1, "duty"); freq = duk_get_number(ctx, -2); duty = duk_get_number(ctx, -1); pwm_device->config.duty_cycle = (float)duty / 100.0; pwm_device->config.freq = freq; ret = aos_hal_pwm_stop(pwm_device); if (ret != 0) { amp_warn(MOD_STR, "amp hal pwm stop failed\n"); goto out; } ret = aos_hal_pwm_init(pwm_device); if (ret != 0) { amp_warn(MOD_STR, "amp hal pwm init failed\n"); goto out; } ret = aos_hal_pwm_start(pwm_device); out: duk_push_int(ctx, ret); return 1; } void module_pwm_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_pwm_open, 1); AMP_ADD_FUNCTION("close", native_pwm_close, 1); AMP_ADD_FUNCTION("getConfig", native_pwm_getConfig, 1); AMP_ADD_FUNCTION("setConfig", native_pwm_setConfig, 2); duk_put_prop_string(ctx, -2, "PWM"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/pwm/module_pwm.c
C
apache-2.0
4,719
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #define LOG_NDEBUG 0 #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_rtc.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "RTC" #define RTC_YEAR "year" #define RTC_MONTH "month" #define RTC_DAY "day" #define RTC_HOUR "hour" #define RTC_MINUTE "minute" #define RTC_SECOND "second" #define RTC_TIME_FORMAT \ "{\"year\":\"%d\",\"month\":\"%d\",\"day\":\"%d\",\"hour\":\"%d\"," \ "\"minute\":\"%d\",\"second\":\"%d\"}" static rtc_dev_t rtc_dev; static duk_ret_t native_rtc_open(duk_context *ctx) { int ret = aos_hal_rtc_init(&rtc_dev); amp_debug(MOD_STR, "port: %d, format: %d\n", rtc_dev.port, rtc_dev.config.format); if (0 != ret) { amp_error(MOD_STR, "aos_hal_rtc_init fail!\n"); } duk_push_int(ctx, ret); return 1; } static duk_ret_t native_rtc_close(duk_context *ctx) { int ret = aos_hal_rtc_finalize(&rtc_dev); if (0 != ret) { amp_error(MOD_STR, "aos_hal_rtc_finalize fail!\n"); } duk_push_int(ctx, ret); return 1; } static duk_ret_t native_rtc_get_time(duk_context *ctx) { int8_t ret = -1; rtc_time_t rtcTime; ret = aos_hal_rtc_get_time(&rtc_dev, &rtcTime); if (0 != ret) { amp_error(MOD_STR, "aos_hal_rtc_get_time fail!\n"); duk_push_null(ctx); } else { char buf[128] = {0x00}; aos_snprintf(buf, sizeof(buf), RTC_TIME_FORMAT, (uint32_t)rtcTime.year, rtcTime.month, rtcTime.date, rtcTime.hr, rtcTime.min, rtcTime.sec); duk_push_string(ctx, buf); amp_debug(MOD_STR, "year: %d, month: %d, day: %d, hour: %d, minute: %d, second: %d\n", rtcTime.year, rtcTime.month, rtcTime.date, rtcTime.hr, rtcTime.min, rtcTime.sec); duk_json_decode(ctx, -1); } return 1; } static duk_ret_t native_rtc_set_time(duk_context *ctx) { int8_t ret = -1; rtc_time_t rtcTime; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object"); goto out; } ret = aos_hal_rtc_get_time(&rtc_dev, &rtcTime); if (ret < 0) { amp_error(MOD_STR, "aos_hal_rtc_get_time fail!\n"); goto out; } duk_get_prop_string(ctx, 0, RTC_YEAR); if (duk_is_number(ctx, -1)) rtcTime.year = (uint8_t)(duk_get_int(ctx, -1)); duk_pop(ctx); duk_get_prop_string(ctx, 0, RTC_MONTH); if (duk_is_number(ctx, -1)) rtcTime.month = duk_get_int(ctx, -1); duk_pop(ctx); duk_get_prop_string(ctx, 0, RTC_DAY); if (duk_is_number(ctx, -1)) rtcTime.date = duk_get_int(ctx, -1); duk_pop(ctx); duk_get_prop_string(ctx, 0, RTC_HOUR); if (duk_is_number(ctx, -1)) rtcTime.hr = duk_get_int(ctx, -1); duk_pop(ctx); duk_get_prop_string(ctx, 0, RTC_MINUTE); if (duk_is_number(ctx, -1)) rtcTime.min = duk_get_int(ctx, -1); duk_pop(ctx); duk_get_prop_string(ctx, 0, RTC_SECOND); if (duk_is_number(ctx, -1)) rtcTime.sec = duk_get_int(ctx, -1); duk_pop(ctx); amp_debug(MOD_STR, "year: %d, month: %d, day: %d, hour: %d, minute: %d, second: %d\n", rtcTime.year, rtcTime.month, rtcTime.date, rtcTime.hr, rtcTime.min, rtcTime.sec); ret = aos_hal_rtc_set_time(&rtc_dev, &rtcTime); out: duk_push_int(ctx, ret); return 1; } void module_rtc_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_rtc_open, 0); AMP_ADD_FUNCTION("close", native_rtc_close, 0); AMP_ADD_FUNCTION("getTime", native_rtc_get_time, 0); AMP_ADD_FUNCTION("setTime", native_rtc_set_time, 1); duk_put_prop_string(ctx, -2, "RTC"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/rtc/module_rtc.c
C
apache-2.0
3,775
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_spi.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "SPI" #define SPI_TIMEOUT (0xFFFFFF) static duk_ret_t native_spi_open(duk_context *ctx) { int8_t ret = -1; item_handle_t spi_handle; spi_handle.handle = NULL; spi_dev_t *spi_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_SPI, id, &spi_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!"); goto out; } amp_debug(MOD_STR, "spi handle:%u", spi_handle.handle); spi_device = board_get_node_by_handle(MODULE_SPI, &spi_handle); if (NULL == spi_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_spi_init(spi_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_spi_init fail!"); goto out; } out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_SPI, &spi_handle); } else { duk_push_pointer(ctx, (void *)spi_handle.handle); } return 1; } static duk_ret_t native_spi_close(duk_context *ctx) { int8_t ret = -1; item_handle_t spi_handle; spi_dev_t *spi_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } spi_handle.handle = duk_get_pointer(ctx, 0); spi_device = board_get_node_by_handle(MODULE_SPI, &spi_handle); if (NULL == spi_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_spi_finalize(spi_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_spi_finalize fail!"); goto out; } board_disattach_item(MODULE_SPI, &spi_handle); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_spi_write(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t spi_handle; spi_dev_t *spi_device = NULL; int arr_idx; int err = -1; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and array"); goto out; } spi_handle.handle = duk_get_pointer(ctx, 0); spi_device = board_get_node_by_handle(MODULE_SPI, &spi_handle); if (NULL == spi_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } arr_idx = duk_normalize_index(ctx, 1); len = duk_get_length(ctx, arr_idx); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "data is not number, index: %d", i); duk_pop(ctx); goto out; } data[i] = (uint8_t)duk_get_int(ctx, -1); duk_pop(ctx); } ret = aos_hal_spi_send(spi_device, data, len, SPI_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "amp_hal_spi_master_send fail!"); goto out; } err = 0; out: aos_free(data); duk_push_int(ctx, err); return 1; } static duk_ret_t native_spi_read(duk_context *ctx) { int8_t ret = -1; uint8_t *data = NULL; uint32_t len = 0; uint32_t i = 0; item_handle_t spi_handle; spi_dev_t *spi_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and number"); goto out; } spi_handle.handle = duk_get_pointer(ctx, 0); spi_device = board_get_node_by_handle(MODULE_SPI, &spi_handle); if (NULL == spi_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } len = duk_get_int(ctx, 1); data = (uint8_t *)aos_malloc(sizeof(uint8_t) * len); if (NULL == data) { amp_error(MOD_STR, "allocate memory failed"); goto out; } ret = aos_hal_spi_recv(spi_device, data, len, SPI_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "amp_hal_spi_master_recv fail!"); } out: if (!ret) { duk_idx_t arr_idx = duk_push_array(ctx); for (i = 0; i < len; i++) { duk_push_int(ctx, data[i]); duk_put_prop_index(ctx, arr_idx, i); } } else { duk_push_null(ctx); } aos_free(data); return 1; } static duk_ret_t native_spi_send_receive(duk_context *ctx) { int8_t ret = -1; uint8_t *send_data = NULL; uint8_t *receive_data = NULL; uint32_t send_len = 0; uint32_t receive_len = 0; uint32_t i = 0; int arr_idx; item_handle_t spi_handle; spi_dev_t *spi_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1) || !duk_is_number(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle array and number"); goto out; } spi_handle.handle = duk_get_pointer(ctx, 0); spi_device = board_get_node_by_handle(MODULE_SPI, &spi_handle); if (NULL == spi_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } arr_idx = duk_normalize_index(ctx, 1); send_len = duk_get_length(ctx, arr_idx); send_data = (uint8_t *)aos_malloc(sizeof(uint8_t) * send_len); if (NULL == send_data) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < send_len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "data is not number, index: %d", i); duk_pop(ctx); goto out; } send_data[i] = (uint8_t)duk_get_int(ctx, -1); duk_pop(ctx); } receive_len = duk_get_int(ctx, 2); receive_data = (uint8_t *)aos_malloc(sizeof(uint8_t) * receive_len); if (NULL == receive_data) { amp_error(MOD_STR, "allocate memory failed"); goto out; } ret = aos_hal_spi_send_recv(spi_device, send_data, receive_data, receive_len, SPI_TIMEOUT); if (-1 == ret) { amp_error(MOD_STR, "amp_hal_spi_master_recv fail!"); } out: if (!ret) { duk_idx_t arr_idx = duk_push_array(ctx); for (i = 0; i < receive_len; i++) { duk_push_int(ctx, receive_data[i]); duk_put_prop_index(ctx, arr_idx, i); } } else { duk_push_null(ctx); } if (send_data) { aos_free(send_data); } if (receive_data) { aos_free(receive_data); } return 1; } void module_spi_register(void) { amp_debug(MOD_STR, "module_spi_register"); duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_spi_open, 1); AMP_ADD_FUNCTION("read", native_spi_read, 2); AMP_ADD_FUNCTION("write", native_spi_write, 2); AMP_ADD_FUNCTION("sendRecv", native_spi_send_receive, 3); AMP_ADD_FUNCTION("close", native_spi_close, 1); duk_put_prop_string(ctx, -2, "SPI"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/spi/module_spi.c
C
apache-2.0
7,420
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "amp_task.h" #include "board_mgr.h" #include "be_inl.h" #include "amp_task.h" #include "aos_hal_timer.h" #include "amp_list.h" #define MOD_STR "HW_TIMER" typedef struct { timer_dev_t *dev; dlist_t node; } timer_info_t; static dlist_t g_timer_list = AMP_DLIST_HEAD_INIT(g_timer_list); static void hw_timer_delete(timer_dev_t *dev) { timer_info_t *timer_info; if (!dev) return; dlist_for_each_entry(&g_timer_list, timer_info, timer_info_t, node) { if (timer_info->dev == dev) { aos_hal_timer_stop(timer_info->dev); aos_hal_timer_finalize(timer_info->dev); dlist_del(&timer_info->node); aos_free(timer_info); break; } } } static duk_ret_t native_timer_open(duk_context *ctx) { int32_t ret = -1; item_handle_t timer_handle; timer_handle.handle = NULL; timer_dev_t *timer_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_TIMER, id, &timer_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!"); goto out; } amp_debug(MOD_STR, "timer handle:%u", timer_handle.handle); timer_device = board_get_node_by_handle(MODULE_TIMER, &timer_handle); if (NULL == timer_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_timer_init(timer_device); if (0 != ret) { amp_error(MOD_STR, "aos_hal_timer_init fail!"); goto out; } out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_TIMER, &timer_handle); } else { duk_push_pointer(ctx, (void *)timer_handle.handle); } return 1; } static void native_timer_timeout_handler(void *args) { int js_cb_ref = (int)args; duk_context *ctx = be_get_context(); be_push_ref(ctx, js_cb_ref); if (duk_pcall(ctx, 0) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void native_timer_timeout_cb(void *args) { amp_task_schedule_call(native_timer_timeout_handler, args); } static duk_ret_t native_timer_setTimeout(duk_context *ctx) { int32_t ret = -1; uint32_t timeout = 0; item_handle_t timer_handle; timer_dev_t *timer_device = NULL; int js_cb_ref; timer_info_t *timer_info; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1) || !duk_is_number(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle function and number"); goto out; } timer_info = aos_malloc(sizeof(timer_info_t)); if (!timer_info) { amp_error(MOD_STR, "alloc timer info fail!"); goto out; } timer_handle.handle = duk_get_pointer(ctx, 0); timer_device = board_get_node_by_handle(MODULE_TIMER, &timer_handle); if (NULL == timer_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); aos_free(timer_info); goto out; } duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); timeout = duk_get_number(ctx, 2); timer_device->config.reload_mode = TIMER_RELOAD_MANU; timer_device->config.period = timeout; timer_device->config.cb = native_timer_timeout_cb; timer_device->config.arg = js_cb_ref; aos_hal_timer_stop(timer_device); ret = aos_hal_timer_start(timer_device); if (ret != 0) { amp_error(MOD_STR, "amp_hal_set_timeout fail!"); aos_free(timer_info); goto out; } timer_info->dev = timer_device; dlist_add_tail(&timer_info->node, &g_timer_list); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_timer_clearTimeout(duk_context *ctx) { int32_t ret = -1; uint32_t timeout = 0; item_handle_t timer_handle; timer_dev_t *timer_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } timer_handle.handle = duk_get_pointer(ctx, 0); timer_device = board_get_node_by_handle(MODULE_TIMER, &timer_handle); if (NULL == timer_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } timer_device->config.reload_mode = TIMER_RELOAD_MANU; aos_hal_timer_stop(timer_device); ret = 0; out: duk_push_int(ctx, ret); return 1; } static void native_timer_interval_handler(void *arg) { int js_cb_ref = (int *)arg; duk_context *ctx = be_get_context(); be_push_ref(ctx, js_cb_ref); if (duk_pcall(ctx, 0) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void native_timer_interval_cb(void *args) { amp_task_schedule_call(native_timer_interval_handler, args); } static duk_ret_t native_timer_setInterval(duk_context *ctx) { int32_t ret = -1; uint32_t timeout = 0; item_handle_t timer_handle; timer_dev_t *timer_device = NULL; int js_cb_ref; timer_info_t *timer_info; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1) || !duk_is_number(ctx, 2)) { amp_warn(MOD_STR, "parameter must be handle function and number"); goto out; } timer_info = aos_malloc(sizeof(timer_info_t)); if (!timer_info) { amp_error(MOD_STR, "alloc timer info fail!"); goto out; } timer_handle.handle = duk_get_pointer(ctx, 0); timer_device = board_get_node_by_handle(MODULE_TIMER, &timer_handle); if (NULL == timer_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); aos_free(timer_info); goto out; } duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); timeout = duk_get_number(ctx, 2); timer_device->config.reload_mode = TIMER_RELOAD_AUTO; timer_device->config.period = timeout; timer_device->config.cb = native_timer_interval_cb; timer_device->config.arg = js_cb_ref; ret = aos_hal_timer_start(timer_device); if (ret != 0) { amp_error(MOD_STR, "aos_hal_timer_start fail!"); aos_free(timer_info); goto out; } timer_info->dev = timer_device; dlist_add_tail(&timer_info->node, &g_timer_list); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_timer_clearInterval(duk_context *ctx) { int32_t ret = -1; uint32_t timeout = 0; item_handle_t timer_handle; timer_dev_t *timer_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } timer_handle.handle = duk_get_pointer(ctx, 0); timer_device = board_get_node_by_handle(MODULE_TIMER, &timer_handle); if (NULL == timer_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } timer_device->config.reload_mode = TIMER_RELOAD_AUTO; aos_hal_timer_stop(timer_device); ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_timer_close(duk_context *ctx) { int32_t ret = -1; uint32_t timeout = 0; item_handle_t timer_handle; timer_dev_t *timer_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } timer_handle.handle = duk_get_pointer(ctx, 0); timer_device = board_get_node_by_handle(MODULE_TIMER, &timer_handle); if (NULL == timer_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } hw_timer_delete(timer_device); out: duk_push_int(ctx, ret); return 1; } static void native_timer_source_free(void) { dlist_t *temp; timer_info_t *timer_node; dlist_for_each_entry_safe(&g_timer_list, temp, timer_node, timer_info_t, node) { aos_hal_timer_stop(timer_node->dev); aos_hal_timer_finalize(timer_node->dev); dlist_del(&timer_node->node); aos_free(timer_node); } } void module_timer_register(void) { duk_context *ctx = be_get_context(); amp_module_free_register(native_timer_source_free); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_timer_open, 1); AMP_ADD_FUNCTION("setTimeout", native_timer_setTimeout, 3); AMP_ADD_FUNCTION("clearTimeout", native_timer_clearTimeout, 1); AMP_ADD_FUNCTION("setInterval", native_timer_setInterval, 3); AMP_ADD_FUNCTION("clearInterval", native_timer_clearInterval, 1); AMP_ADD_FUNCTION("close", native_timer_close, 1); duk_put_prop_string(ctx, -2, "TIMER"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/timer/module_timer.c
C
apache-2.0
8,891
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ /* #define LOG_NDEBUG 0 */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "amp_task.h" #include "aos_hal_uart.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "MODULE_UART" #define UART_BUFF_SIZE 1024 #define MAX_UART_PORT 6 typedef struct uart_module { uart_dev_t *uart; uint32_t item_handle; uint32_t recv_index; uint8_t recv_buff[UART_BUFF_SIZE]; int js_cb_ref; } uart_module_t; typedef struct { uint8_t recv_buff[UART_BUFF_SIZE]; int recv_len; int js_cb_ref; } uart_notify_t; /* * open -- item_handle * on -- uart_module_t -- item_handle */ static uart_module_t *g_uart_modules[MAX_UART_PORT]; static uart_dev_t *g_uart_devices[MAX_UART_PORT]; static int uart_module_is_on(uint32_t item_handle) { int i; for (i = 0; i < MAX_UART_PORT; i++) { uart_module_t *m = g_uart_modules[i]; if (m && m->item_handle == item_handle) return 1; } return 0; } static void uart_recv_notify(void *pdata) { int i = 0; uart_notify_t *notify = (uart_notify_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, notify->js_cb_ref); int arr_idx = duk_push_array(ctx); for (i = 0; i < notify->recv_len; i++) { duk_push_int(ctx, notify->recv_buff[i]); duk_put_prop_index(ctx, arr_idx, i); } if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); // be_unref(ctx, p->js_cb_ref); // g_uart_modules[p->uart->port] = NULL; aos_free(notify); } void uart_recv_callback(int port, void *data, uint16_t len, void *arg) { uart_module_t *module = g_uart_modules[port]; uint32_t recvsize = 0; uart_dev_t *dev = (uart_dev_t *)module->uart; uart_notify_t *notify; if (!module) return; notify = aos_malloc(sizeof(uart_notify_t)); if (!notify) { amp_error(MOD_STR, "alloc uart notify fail"); return; } if (data != NULL) { recvsize = len <= UART_BUFF_SIZE ? len : UART_BUFF_SIZE; memcpy(notify->recv_buff, data, recvsize); } else { aos_hal_uart_recv_II(dev, notify->recv_buff, UART_BUFF_SIZE, &recvsize, 0); if (recvsize <= 0) { aos_free(notify); return; } } notify->recv_len = recvsize; notify->js_cb_ref = module->js_cb_ref; amp_task_schedule_call(uart_recv_notify, notify); } static int uart_add_recv(uart_dev_t *uart, uint32_t item_handle, int js_cb_ref) { uart_module_t *module = aos_calloc(1, sizeof(uart_module_t)); if (!module) { amp_error(MOD_STR, "uart_start_recv fail!"); return -1; } module->js_cb_ref = js_cb_ref; module->item_handle = item_handle; module->recv_index = 0; module->uart = uart; if (aos_hal_uart_callback(uart, uart_recv_callback, module) != 0) { duk_context *ctx = be_get_context(); be_unref(ctx, module->js_cb_ref); aos_free(module); return -1; } g_uart_modules[uart->port] = module; return 0; } static void uart_del_recv(uint32_t item_handle) { int i; for (i = 0; i < MAX_UART_PORT; i++) { uart_module_t *m = g_uart_modules[i]; if (m && m->item_handle == item_handle) { duk_context *ctx = be_get_context(); be_unref(ctx, m->js_cb_ref); aos_free(m); g_uart_modules[i] = NULL; break; } } } static uint16_t uart_init_flag = 0; static duk_ret_t native_uart_open(duk_context *ctx) { amp_warn(MOD_STR, "native uart open"); int8_t ret = -1; item_handle_t uart_handle; uart_handle.handle = NULL; uart_dev_t *uart_device = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string"); goto out; } const char *id = duk_get_string(ctx, 0); ret = board_attach_item(MODULE_UART, id, &uart_handle); if (0 != ret) { amp_error(MOD_STR, "board_attach_item fail!"); goto out; } amp_debug(MOD_STR, "uart handle:%u\n", uart_handle.handle); uart_device = board_get_node_by_handle(MODULE_UART, &uart_handle); if (NULL == uart_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } if (uart_init_flag & (1 << uart_device->port)) { amp_debug(MOD_STR, "uart port [%d] is already inited\n", uart_device->port); goto out; } ret = aos_hal_uart_init(uart_device); if (0 != ret) { amp_error(MOD_STR, "native_uart_open fail!"); } uart_init_flag |= (1 << uart_device->port); g_uart_devices[uart_device->port] = uart_device; out: if (0 != ret) { duk_push_pointer(ctx, NULL); board_disattach_item(MODULE_UART, &uart_handle); } else { duk_push_pointer(ctx, (void *)uart_handle.handle); } return 1; } static duk_ret_t native_uart_close(duk_context *ctx) { int8_t ret = -1; item_handle_t uart_handle; uart_dev_t *uart_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } uart_handle.handle = duk_get_pointer(ctx, 0); uart_device = board_get_node_by_handle(MODULE_UART, &uart_handle); if (NULL == uart_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_uart_finalize(uart_device); if (0 != ret) { amp_error(MOD_STR, "native_uart_close fail!"); goto out; } uart_init_flag -= (1 << uart_device->port); g_uart_devices[uart_device->port] = NULL; board_disattach_item(MODULE_UART, &uart_handle); uart_del_recv(uart_handle.handle); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_uart_write(duk_context *ctx) { int ret = -1; int i; char *msg = NULL; uint32_t msg_len = 0; item_handle_t uart_handle; uart_dev_t *uart_device = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_array(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle and array"); goto out; } uart_handle.handle = duk_get_pointer(ctx, 0); uart_device = board_get_node_by_handle(MODULE_UART, &uart_handle); if (NULL == uart_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } msg_len = duk_get_length(ctx, 1); msg = (char *)aos_malloc(msg_len + 1); if (!msg) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < msg_len; i++) { duk_get_prop_index(ctx, 1, i); msg[i] = duk_get_int(ctx, -1); duk_pop(ctx); } msg[msg_len] = 0; ret = aos_hal_uart_send(uart_device, msg, msg_len, osWaitForever); if (-1 == ret) { amp_error(MOD_STR, "native_uart_write fail!"); } aos_free(msg); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_uart_read(duk_context *ctx) { int ret = -1; const char *data = NULL; uint32_t max_len; uint32_t recvsize = 0; item_handle_t uart_handle; uart_dev_t *uart_device = NULL; if (!duk_is_pointer(ctx, 0)) { amp_warn(MOD_STR, "parameter must be handle"); goto out; } uart_handle.handle = duk_get_pointer(ctx, 0); uart_device = board_get_node_by_handle(MODULE_UART, &uart_handle); if (NULL == uart_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } ret = aos_hal_uart_recv_II(uart_device, data, max_len, &recvsize, 0); if (recvsize <= 0) { amp_error(MOD_STR, "native_uart_read error!"); goto out; } out: if (ret != 0) { duk_push_string(ctx, data); } else { duk_push_null(ctx); } aos_free(data); return 1; } static duk_ret_t native_uart_on(duk_context *ctx) { int ret = -1; item_handle_t uart_handle; uart_handle.handle = NULL; uart_dev_t *uart_device = NULL; uint8_t *start = NULL; uint8_t *end = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be handle, function"); goto out; } uart_handle.handle = duk_get_pointer(ctx, 0); uart_device = board_get_node_by_handle(MODULE_UART, &uart_handle); if (NULL == uart_device) { amp_error(MOD_STR, "board_get_node_by_handle fail!"); goto out; } if (uart_module_is_on(uart_handle.handle)) { amp_error(MOD_STR, "The uart module has set the listener"); goto out; } duk_dup(ctx, 1); int js_cb_ref = be_ref(ctx); ret = uart_add_recv(uart_device, uart_handle.handle, js_cb_ref); if (ret < 0) { amp_error(MOD_STR, "uart_add_recv fail!"); } out: duk_push_int(ctx, ret); return 1; } static void native_uart_clean(void) { duk_context *ctx = be_get_context(); uart_module_t *mod; uart_dev_t *dev; int i, ret; for (i = 0; i < MAX_UART_PORT; i++) { mod = g_uart_modules[i]; if (mod) { be_unref(ctx, mod->js_cb_ref); aos_free(mod); g_uart_modules[i] = NULL; } dev = g_uart_devices[i]; if (dev) { ret = aos_hal_uart_finalize(dev); if (ret) { amp_error(MOD_STR, "finalize uart %d fail %d", i, ret); continue; } uart_init_flag -= (1 << dev->port); g_uart_devices[i] = NULL; } } } void module_uart_register(void) { amp_debug(MOD_STR, "module_uart_register\r"); duk_context *ctx = be_get_context(); amp_module_free_register(native_uart_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("open", native_uart_open, 1); AMP_ADD_FUNCTION("read", native_uart_read, 1); AMP_ADD_FUNCTION("write", native_uart_write, 2); AMP_ADD_FUNCTION("on", native_uart_on, 2); AMP_ADD_FUNCTION("close", native_uart_close, 1); duk_put_prop_string(ctx, -2, "UART"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/uart/module_uart.c
C
apache-2.0
10,225
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ /* #define LOG_NDEBUG 0 */ #include <stdint.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_hal_wdg.h" #include "board_mgr.h" #include "be_inl.h" #define MOD_STR "WDG" static wdg_dev_t wdg_dev; static duk_ret_t native_wdg_start(duk_context *ctx) { int ret = -1; int32_t timeout = 0; wdg_dev_t *handle = (wdg_dev_t *)&wdg_dev; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number\n"); goto out; } timeout = duk_get_int(ctx, 0); if (timeout < 0) { amp_error(MOD_STR, "invalid timeout: %d\n", timeout); goto out; } handle->config.timeout = timeout; ret = aos_hal_wdg_init(handle); handle->config.timeout = (ret == 0) ? timeout : 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_wdg_feed(duk_context *ctx) { wdg_dev_t *handle = (wdg_dev_t *)&wdg_dev; aos_hal_wdg_reload(handle); return 0; } static duk_ret_t native_wdg_stop(duk_context *ctx) { wdg_dev_t *handle = (wdg_dev_t *)&wdg_dev; aos_hal_wdg_finalize(handle); handle->config.timeout = 0; return 0; } void module_wdg_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("start", native_wdg_start, 1); AMP_ADD_FUNCTION("stop", native_wdg_stop, 0); AMP_ADD_FUNCTION("feed", native_wdg_feed, 0); duk_put_prop_string(ctx, -2, "WDG"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/hardware/wdg/module_wdg.c
C
apache-2.0
1,528
/* * Copyright (C) 2015-2020 Alibaba Group Holding Limited */ #ifndef __LIBJS_H #define __LIBJS_H #include <stdio.h> #include <string.h> #ifdef JSE_HIGHLEVEL_JSAPI typedef struct { char *name; char *content; }libjs_entry_t; extern libjs_entry_t LIBJS_ENTRIES[]; extern int libjs_num; #endif /* JSE_HIGHLEVEL_JSAPI */ #endif /* __LIBJS_H */
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/libjs.h
C
apache-2.0
352
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "aos_network.h" #include "be_inl.h" #define MOD_STR "CELLULAR" typedef struct { int status; int js_cb_ref; } network_status_notify_param_t; static int g_js_cb_ref = 0; /************************************************************************************* * Function: native_aiot_close * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ static duk_ret_t native_cellular_get_simInfo(duk_context *ctx) { int ret = -1; aos_sim_info_t sim_info; memset(&sim_info, 0, sizeof(sim_info)); ret = aos_get_sim_info(&sim_info); if (ret != 0) { amp_debug(MOD_STR, "get sim card info failed"); goto out; } duk_push_object(ctx); AMP_ADD_STRING("imsi", sim_info.imsi); AMP_ADD_STRING("imei", sim_info.imei); AMP_ADD_STRING("iccid", sim_info.iccid); return 1; out: duk_push_int(ctx, ret); return 1; } /************************************************************************************* * Function: native_aiot_close * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ static duk_ret_t native_cellular_get_locatorInfo(duk_context *ctx) { int ret = -1; aos_locator_info_t locator_info; memset(&locator_info, 0, sizeof(locator_info)); ret = aos_get_locator_info(&locator_info); if (ret != 0) { amp_debug(MOD_STR, "get locator card info failed"); goto out; } duk_push_object(ctx); AMP_ADD_INT("cellid", locator_info.cellid); AMP_ADD_INT("lac", locator_info.lac); AMP_ADD_STRING("mcc", locator_info.mcc); AMP_ADD_STRING("mnc", locator_info.mnc); AMP_ADD_INT("signal", locator_info.signal); return 1; out: duk_push_int(ctx, ret); return 1; } /************************************************************************************* * Function: native_aiot_close * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ void cellInfo_receive_callback(aos_locator_info_t *locator_info, int cell_num) { int ret = -1; int i; duk_context *ctx = be_get_context(); be_push_ref(ctx, g_js_cb_ref); int arr_idx = duk_push_array(ctx); for (i = 0; i < cell_num; i++) { duk_push_object(ctx); AMP_ADD_INT("cellid", locator_info[i].cellid); AMP_ADD_INT("lac", locator_info[i].lac); AMP_ADD_STRING("mcc", locator_info[i].mcc); AMP_ADD_STRING("mnc", locator_info[i].mnc); duk_put_prop_index(ctx, arr_idx, i); } if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); } static duk_ret_t native_cellular_neighborCellInfo(duk_context *ctx) { int ret = -1; // int i,cellnum = 0; // if (!duk_is_function(ctx, 0)) { // amp_warn(MOD_STR, "parameter must be function"); // goto out; // } // duk_dup(ctx, 1); // g_js_cb_ref = be_ref(ctx); ret = aos_get_neighbor_locator_info(cellInfo_receive_callback); if (ret != 0) { amp_debug(MOD_STR, "get locator card info failed"); goto out; } return 1; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_cellular_getStatus(duk_context *ctx) { int ret = -1; ret = aos_get_network_status(); if (ret != 1) { amp_debug(MOD_STR, "network status disconnect %d", ret); goto out; } out: duk_push_int(ctx, ret); return 1; } static void network_status_notify(void *pdata) { int i = 0; network_status_notify_param_t *p = (network_status_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_int(ctx, p->status); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } aos_free(p); duk_pop(ctx); duk_gc(ctx, 0); } static void network_status_callback(int status, void *args) { int js_cb_ref = (int)args; network_status_notify_param_t *p = aos_calloc(1, sizeof(network_status_notify_param_t)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); duk_context *ctx = be_get_context(); be_unref(ctx, js_cb_ref); return; } p->status = status; p->js_cb_ref = js_cb_ref; amp_task_schedule_call(network_status_notify, p); } static duk_ret_t native_cellular_onconnect(duk_context *ctx) { int ret = -1; int js_cb_ref; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be function"); goto out; } duk_dup(ctx, 0); js_cb_ref = be_ref(ctx); ret = aos_network_status_registercb(network_status_callback, js_cb_ref); if (ret != 0) { duk_context *ctx = be_get_context(); be_unref(ctx, js_cb_ref); return -1; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_get_netshare_mode(duk_context *ctx) { int ret = -1; ret = aos_get_netsharemode(); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_set_netshare_mode(duk_context *ctx) { int ret = -1; int share_mode = 0; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number"); goto out; } share_mode = duk_get_number(ctx, 0); amp_error(MOD_STR, "native set net share mode = %d", share_mode); ret = aos_set_netsharemode(share_mode); if (ret != 0) { return -1; } amp_error(MOD_STR, "native set net share mode success"); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_get_netshare_config(duk_context *ctx) { int ret = -1; aos_sharemode_info_t *share_mode_info; share_mode_info = aos_malloc(sizeof(aos_sharemode_info_t)); if (share_mode_info == NULL) { amp_debug(MOD_STR, "get net share config failed"); goto out; } memset(share_mode_info, 0, sizeof(aos_sharemode_info_t)); ret = aos_get_netshareconfig(share_mode_info); if (ret != 0) { amp_debug(MOD_STR, "get net share config failed"); goto out; } duk_push_object(ctx); AMP_ADD_INT("action", share_mode_info->action); AMP_ADD_INT("auto_connect", share_mode_info->auto_connect); AMP_ADD_STRING("apn", share_mode_info->apn); AMP_ADD_STRING("username", share_mode_info->username); AMP_ADD_STRING("password", share_mode_info->password); AMP_ADD_INT("ip_type", share_mode_info->ip_type); AMP_ADD_INT("share_mode", share_mode_info->share_mode); aos_free(share_mode_info); return 1; out: if (share_mode_info) { aos_free(share_mode_info); } duk_push_int(ctx, ret); return 1; } static duk_ret_t native_set_netshare_config(duk_context *ctx) { int ret = -1; aos_sharemode_info_t *share_mode_info; /* check paramters */ if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object\n"); goto out; } /* get device certificate */ duk_get_prop_string(ctx, 0, "ucid"); duk_get_prop_string(ctx, 0, "action"); duk_get_prop_string(ctx, 0, "autoConnect"); duk_get_prop_string(ctx, 0, "apn"); duk_get_prop_string(ctx, 0, "username"); duk_get_prop_string(ctx, 0, "password"); duk_get_prop_string(ctx, 0, "authType"); duk_get_prop_string(ctx, 0, "ipType"); // if (!duk_is_number(ctx, -8) || !duk_is_number(ctx, -7) || // !duk_is_number(ctx, -6) || !duk_is_string(ctx, -5) || // !duk_is_string(ctx, -4) || !duk_is_string(ctx, -3) || // !duk_is_number(ctx, -2) || !duk_is_number(ctx, -1)) // { // amp_warn(MOD_STR, // "Parameter 1 must be an object like {host: string, " // "port: uint, client_id: string, username: string, " // "password: string, keepalive_interval: uint} %d %d %d %d %d %d %d %d %d", duk_is_number(ctx, -8), duk_is_number(ctx, -7), // duk_is_number(ctx, -6), duk_is_string(ctx, -5), duk_is_string(ctx, -4), duk_is_string(ctx, -3), duk_is_string(ctx, -2), // duk_is_boolean(ctx, -2), duk_is_number(ctx, -1)); // // duk_pop_n(ctx, 8); // // goto out; // } const uint16_t ipType = duk_get_number(ctx, -1); const uint16_t authType = duk_get_number(ctx, -2); const char *password = duk_get_string(ctx, -3); const char *username = duk_get_string(ctx, -4); const char *apn = duk_get_string(ctx, -5); const uint16_t autoConnect = duk_get_number(ctx, -6); const uint16_t action = duk_get_number(ctx, -7); const uint16_t ucid = duk_get_number(ctx, -8); share_mode_info = aos_malloc(sizeof(aos_sharemode_info_t)); if (share_mode_info == NULL) { amp_debug(MOD_STR, "set net share config failed"); goto out; } memset(share_mode_info, 0, sizeof(aos_sharemode_info_t)); share_mode_info->action = action; share_mode_info->auto_connect = autoConnect; memcpy(share_mode_info->apn, apn, strlen(apn)); memcpy(share_mode_info->username, username, strlen(username)); memcpy(share_mode_info->password, password, strlen(password)); share_mode_info->ip_type = ipType; ret = aos_set_netshareconfig(ucid, authType, share_mode_info); if (ret != 0) { amp_warn(MOD_STR, "amp set net share config failed!"); aos_free(share_mode_info); return -1; } out: if (share_mode_info) { aos_free(share_mode_info); } duk_push_int(ctx, ret); return 1; } void module_cellular_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("getSimInfo", native_cellular_get_simInfo, 0); AMP_ADD_FUNCTION("getLocatorInfo", native_cellular_get_locatorInfo, 0); AMP_ADD_FUNCTION("getStatus", native_cellular_getStatus, 0); AMP_ADD_FUNCTION("onConnect", native_cellular_onconnect, 1); AMP_ADD_FUNCTION("getNeighborCellInfo", native_cellular_neighborCellInfo, 0); AMP_ADD_FUNCTION("getNetSharemode", native_get_netshare_mode, 0); AMP_ADD_FUNCTION("setNetSharemode", native_set_netshare_mode, 1); AMP_ADD_FUNCTION("getNetShareconfig", native_get_netshare_config, 0); AMP_ADD_FUNCTION("setNetShareconfig", native_set_netshare_config, 1); duk_put_prop_string(ctx, -2, "CELLULAR"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/cellular/module_cellular.c
C
apache-2.0
11,349
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "amp_platform.h" #include "aos_system.h" #include "aos_network.h" #include "amp_defines.h" #include "aos_network.h" #include "aos_socket.h" #include "aos_httpc.h" #include "httpclient.h" #include "aos_tcp.h" #include "amp_task.h" #include "be_inl.h" // #include "http.h" #include "cJSON.h" #include "amp_list.h" #define MOD_STR "HTTP" #define HTTP_BUFF_SIZE 2048 #define HTTP_HEADER_SIZE 1024 #define HTTP_HEADER_COUNT 8 #define HTTP_REQUEST_PARAMS_LEN_MAX 2048 #define HTTP_SEND_RECV_TIMEOUT 10000 #define HTTP_REQUEST_TIMEOUT 30000 #define HTTP_DEFAULT_HEADER_NAME "content-type" #define HTTP_DEFAULT_HEADER_DATA "application/json" #define HTTP_CRLF "\r\n" static int http_header_index = 0; typedef struct { char *name; char *data; } http_header_t; typedef struct { char *url; char *filepath; int method; http_header_t http_header[HTTP_HEADER_COUNT]; uint32_t timeout; char *params; char *buffer; int params_len; int js_cb_ref; } http_param_t; static char *strncasestr(const char *str, const char *key) { int len; if (!str || !key) return NULL; len = strlen(key); if (len == 0) return NULL; while (*str) { if (!strncasecmp(str, key, len)) return str; ++str; } return NULL; } static void parse_url(const char *url, char *uri) { char url_dup[1024] = {0}; if (url == NULL) { amp_warn(MOD_STR, "url is null"); return; } memcpy(url_dup, url, strlen(url)); char *start = NULL; char *p_slash = NULL; #if 1 const char *protocol = "https"; #else const char *protocol = "http"; #endif if (strncmp(url_dup, protocol, strlen(protocol)) == 0) { start = url_dup + strlen(protocol) + 3; p_slash = strchr(start, '/'); if (p_slash != NULL) { memcpy(uri, p_slash, strlen(p_slash)); *p_slash = '\0'; } else { memcpy(uri, '/', 1); } } } int32_t httpc_construct_header(char *buf, uint16_t buf_size, const char *name, const char *data) { uint32_t hdr_len; uint32_t hdr_data_len; int32_t hdr_length; if (buf == NULL || buf_size == 0 || name == NULL || data == NULL) { return HTTP_EARG; } hdr_len = strlen(name); hdr_data_len = strlen(data); hdr_length = hdr_len + hdr_data_len + 4; if (hdr_length < 0 || hdr_length > buf_size) { return HTTP_ENOBUFS; } memcpy(buf, name, hdr_len); buf += hdr_len; memcpy(buf, ": ", 2); buf += 2; memcpy(buf, data, hdr_data_len); buf += hdr_data_len; memcpy(buf, HTTP_CRLF, 2); return hdr_length; } static void http_request_notify(void *pdata) { http_param_t *msg = (http_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, msg->js_cb_ref); duk_push_string(ctx, msg->buffer); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, msg->js_cb_ref); aos_free(msg->buffer); if (msg->params) aos_free(msg->params); aos_free(msg); duk_gc(ctx, 0); } char customer_header[HTTP_HEADER_SIZE] = {0}; char rsp_buf[HTTP_BUFF_SIZE]; char req_buf[HTTP_BUFF_SIZE]; /* create task for http download */ static void task_http_download_func(void *arg) { httpclient_t client = {0}; httpclient_data_t client_data = {0}; http_param_t *param = (http_param_t *)arg; int num=0; int ret; // 字符串偶现丢失,不知原因,暂时写死,by梓同 // char * req_url = param->url; // int fd = aos_open(param->filepath, O_CREAT | O_RDWR | O_APPEND); char * req_url = "http://wangguan-498.oss-cn-beijing.aliyuncs.com/SHOPAD/public/mould5.png"; int fd = aos_open("/data/http_text.png", O_CREAT | O_RDWR | O_APPEND); memset(rsp_buf, 0, sizeof(rsp_buf)); client_data.response_buf = rsp_buf; client_data.response_buf_len = sizeof(rsp_buf); ret = httpclient_conn(&client, req_url); if (!ret) { ret = httpclient_send(&client, req_url, HTTP_GET, &client_data); do{ ret = httpclient_recv(&client, &client_data); printf("response_content_len=%d, retrieve_len=%d,content_block_len=%d\n", client_data.response_content_len,client_data.retrieve_len,client_data.content_block_len); printf("ismore=%d \n", client_data.is_more); num = aos_write(fd, client_data.response_buf, client_data.content_block_len); if(num > 0){ printf("aos_write num=%d\n", num); } }while(client_data.is_more); } ret = aos_sync(fd); param->buffer = "http download success"; httpclient_clse(&client); amp_task_schedule_call(http_request_notify, param); aos_task_exit(0); } /* create task for http request */ static void task_http_request_func(void *arg) { char *url = NULL; uint32_t timeout = 0; int http_method = 0; int i = 0; int ret = 0; httpclient_t client = {0}; httpclient_data_t client_data = {0}; http_param_t *param = (http_param_t *)arg; url = param->url; timeout = param->timeout; http_method = param->method; amp_debug(MOD_STR, "task_http_request_func url: %s", url); amp_debug(MOD_STR, "task_http_request_func method: %d", http_method); amp_debug(MOD_STR, "task_http_request_func timeout: %d", timeout); memset(rsp_buf, 0, HTTP_BUFF_SIZE); client_data.response_buf = rsp_buf; client_data.response_buf_len = sizeof(rsp_buf); aos_msleep(50); /* need do things after state changed in main task */ for (i = 0; i < http_header_index; i++) { httpc_construct_header(customer_header, HTTP_HEADER_SIZE, param->http_header[i].name, param->http_header[i].data); } http_header_index = 0; httpclient_set_custom_header(&client, customer_header); if(http_method == HTTP_GET){ amp_info(MOD_STR,"http GET request=%s,timeout=%d\r\n", url, timeout); ret = httpclient_get(&client, url, &client_data); if( ret >= 0 ) { amp_info(MOD_STR,"GET Data received: %s, len=%d \r\n", client_data.response_buf, client_data.response_buf_len); strcpy(param->buffer,client_data.response_buf); } }else if(http_method == HTTP_POST){ amp_info(MOD_STR,"http POST request=%s,post_buf=%s,timeout=%d\r\n", url,param->params,timeout); memset(req_buf, 0, sizeof(req_buf)); strcpy(req_buf, "tab_index=0&count=3&group_id=6914830518563373582&item_id=6914830518563373581&aid=1768"); client_data.post_buf = req_buf; client_data.post_buf_len = sizeof(req_buf); client_data.post_content_type="application/x-www-form-urlencoded"; ret = httpclient_post(&client, "https://www.ixigua.com/tlb/comment/article/v5/tab_comments/", &client_data); if( ret >= 0 ) { amp_info(MOD_STR,"POST Data received: %s, len=%d \r\n", client_data.response_buf, client_data.response_buf_len); strcpy(param->buffer,client_data.response_buf); } }else if(http_method == HTTP_PUT){ amp_info(MOD_STR,"http PUT request=%s,data=%s,timeout=%d\r\n", url,param->params,timeout); client_data.post_buf = param->params; client_data.post_buf_len = param->params_len; ret = httpclient_put(&client, url, &client_data); if( ret >= 0 ) { amp_info(MOD_STR,"Data received: %s, len=%d \r\n", client_data.response_buf, client_data.response_buf_len); strcpy(param->buffer,client_data.response_buf); } }else{ ret = httpclient_get(&client, url, &client_data); if( ret >= 0 ) { amp_info(MOD_STR,"Data received: %s, len=%d \r\n", client_data.response_buf, client_data.response_buf_len); strcpy(param->buffer,client_data.response_buf); } } amp_task_schedule_call(http_request_notify, param); aos_task_exit(0); return; } static duk_ret_t native_http_download(duk_context *ctx) { http_param_t *http_param = NULL; char *http_buffer = NULL; aos_task_t http_task; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto done; } http_param = (http_param_t *)aos_malloc(sizeof(http_param_t)); if (!http_param) { amp_warn(MOD_STR, "allocate memory failed\n"); goto done; } memset(http_param, 0, sizeof(http_param_t)); http_param->buffer = http_buffer; /* get http request url */ duk_get_prop_string(ctx, 0, "url"); if (!duk_is_string(ctx, -1)) { amp_debug(MOD_STR, "request url is invalid"); goto done; } http_param->url = duk_get_string(ctx, 1); duk_pop(ctx); amp_debug(MOD_STR, "url: %s", http_param->url); /* get http download filepath */ duk_get_prop_string(ctx, 0, "filepath"); if (!duk_is_string(ctx, -1)) { amp_debug(MOD_STR, "filepath is invalid"); goto done; } http_param->filepath = duk_get_string(ctx, 1); duk_pop(ctx); amp_debug(MOD_STR, "filepath: %s", http_param->filepath); /* callback */ if (duk_get_prop_string(ctx, 0, "success")) { duk_dup(ctx, -1); http_param->js_cb_ref = be_ref(ctx); } else { http_param->js_cb_ref = -1; } aos_task_new_ext(&http_task, "amp http download task", task_http_download_func, http_param, 1024 * 8, ADDON_TSK_PRIORRITY); duk_push_int(ctx, 0); return 1; done: if (http_buffer) aos_free(http_buffer); if (http_param && http_param->params) cJSON_free(http_param->params); if (http_param) aos_free(http_param); duk_push_int(ctx, -1); return 1; } static duk_ret_t native_http_request(duk_context *ctx) { http_param_t *http_param = NULL; char *http_buffer = NULL; const char *method = NULL; cJSON *param_root; int http_method = 0; int timeout = 0; char localip[32]; int i; aos_task_t http_task; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto done; } // amp_system.c中netmgr_wifi_get_ip方法没有实现,暂时注释掉这部分 by梓同 // if (amp_get_ip(localip) != 0) // { // amp_warn(MOD_STR, "network not ready\r\n"); // goto done; // } http_param = (http_param_t *)aos_malloc(sizeof(http_param_t)); if (!http_param) { amp_warn(MOD_STR, "allocate memory failed\n"); goto done; } memset(http_param, 0, sizeof(http_param_t)); http_buffer = aos_malloc(HTTP_BUFF_SIZE + 1); if (!http_buffer) { amp_warn(MOD_STR, "allocate memory failed\n"); goto done; } memset(http_buffer, 0, HTTP_BUFF_SIZE + 1); http_param->buffer = http_buffer; /* get http request url */ duk_get_prop_string(ctx, 0, "url"); if (!duk_is_string(ctx, -1)) { amp_debug(MOD_STR, "request url is invalid"); goto done; } http_param->url = duk_get_string(ctx, 1); duk_pop(ctx); /* get http request method */ if (duk_get_prop_string(ctx, 0, "method")) { if (duk_is_string(ctx, -1)) { method = duk_get_string(ctx, -1); if(strcmp(method, "GET") == 0) { http_method = HTTP_GET; /* GET */ } else if(strcmp(method, "POST") == 0) { http_method = HTTP_POST; /* POST */ } else if(strcmp(method, "PUT") == 0) { http_method = HTTP_PUT; /* PUT */ } else { http_method = HTTP_GET; } http_param->method = http_method; } } else { http_param->method = HTTP_GET; } duk_pop(ctx); /* get http request timeout */ if (duk_get_prop_string(ctx, 0, "timeout")) { if (duk_is_number(ctx, -1)) { timeout = duk_get_number(ctx, -1); http_param->timeout = timeout; } else { http_param->timeout = HTTP_REQUEST_TIMEOUT; } } else { http_param->timeout = HTTP_REQUEST_TIMEOUT; } if (http_param->timeout <= 0) { http_param->timeout = HTTP_REQUEST_TIMEOUT; } duk_pop(ctx); /* get http request headers */ if (duk_get_prop_string(ctx, 0, "headers")) { duk_enum(ctx, -1, DUK_ENUM_OWN_PROPERTIES_ONLY); while (duk_next(ctx, -1, 1)) { // amp_debug(MOD_STR, "key=%s, value=%s ", duk_to_string(ctx, -2), duk_to_string(ctx, -1)); if (!duk_is_string(ctx, -2) || !duk_is_string(ctx, -1)) { amp_debug(MOD_STR, "get header failed, index is: %d", http_header_index); break; } http_param->http_header[http_header_index].name = duk_to_string(ctx, -2); http_param->http_header[http_header_index].data = duk_to_string(ctx, -1); http_header_index++; duk_pop_2(ctx); } } else { http_param->http_header[0].name = HTTP_DEFAULT_HEADER_NAME; http_param->http_header[0].data = HTTP_DEFAULT_HEADER_DATA; http_header_index++; } /* get http request params */ if (duk_get_prop_string(ctx, 0, "params")) { // duk_enum(ctx, -1, DUK_ENUM_OWN_PROPERTIES_ONLY); // param_root = cJSON_CreateObject(); // if (!param_root) { // amp_error(MOD_STR, "alloc param json object fail"); // goto done; // } // while (duk_next(ctx, -1, 1)) { // if (!duk_is_string(ctx, -2) || !duk_is_string(ctx, -1)) { // amp_error(MOD_STR, "get params fail"); // break; // } // cJSON_AddStringToObject(param_root, duk_to_string(ctx, -2), duk_to_string(ctx, -1)); // duk_pop_2(ctx); // } // http_param->params = cJSON_PrintUnformatted(param_root); // http_param->params_len = strlen(http_param->params); // amp_error(MOD_STR, "params: %s, len %d", http_param->params, http_param->params_len); // cJSON_Delete(param_root); if (duk_is_string(ctx, -1)) { http_param->params = duk_get_string(ctx, -1); http_param->params_len = strlen(http_param->params); amp_debug(MOD_STR, "params: %s, len %d", http_param->params, http_param->params_len); } } else { amp_debug(MOD_STR, "%s: params not contained", __func__); } amp_debug(MOD_STR, "url: %s", http_param->url); amp_debug(MOD_STR, "method: %d", http_param->method); amp_debug(MOD_STR, "timeout: %d", http_param->timeout); for (i = 0; i < http_header_index; i++) { amp_debug(MOD_STR, "headers: %s:%s", http_param->http_header[i].name, http_param->http_header[i].data); } /* callback */ if (duk_get_prop_string(ctx, 0, "success")) { duk_dup(ctx, -1); http_param->js_cb_ref = be_ref(ctx); } else { http_param->js_cb_ref = -1; } aos_task_new_ext(&http_task, "amp http task", task_http_request_func, http_param, 1024 * 8, ADDON_TSK_PRIORRITY); duk_push_int(ctx, 0); return 1; done: if (http_buffer) aos_free(http_buffer); if (http_param && http_param->params) cJSON_free(http_param->params); if (http_param) aos_free(http_param); duk_push_int(ctx, -1); return 1; } void module_http_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); /* request */ AMP_ADD_FUNCTION("request", native_http_request, 1); AMP_ADD_FUNCTION("download", native_http_download, 1); // AMP_ADD_FUNCTION("upload", native_http_upload, 1); duk_put_prop_string(ctx, -2, "HTTP"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/http/module_http.c
C
apache-2.0
16,104
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "be_inl.h" #include "module_mqtt.h" #include "aiot_state_api.h" #define MOD_STR "MQTT" #define MQTT_TASK_YIELD_TIMEOUT 200 static char g_mqtt_close_flag = 0; static aos_sem_t g_mqtt_close_sem = NULL; static void mqtt_handle_notify(void *pdata) { int res; amp_mqtt_handle_t *amp_mqtt_handle = (amp_mqtt_handle_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_START_CLIENT_REF]); duk_push_int(ctx, amp_mqtt_handle->res); duk_push_pointer(ctx, amp_mqtt_handle); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); /* free when mqtt connect failed */ if(amp_mqtt_handle->res < 0){ be_unref(ctx, amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_START_CLIENT_REF]); aos_free(amp_mqtt_handle); } duk_gc(ctx, 0); } static void mqtt_connect_task(void *pdata) { int ret; amp_mqtt_handle_t *amp_mqtt_handle = NULL; amp_mqtt_params_t *amp_mqtt_params = (amp_mqtt_params_t *)pdata; amp_mqtt_handle = aos_malloc(sizeof(amp_mqtt_handle_t)); if (amp_mqtt_handle == NULL) { amp_debug(MOD_STR, "amp mqtt handle malloc failed"); aos_free(amp_mqtt_params); return; } amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_START_CLIENT_REF] = amp_mqtt_params->js_cb_ref[MQTT_JSCALLBACK_START_CLIENT_REF]; ret = mqtt_client_start(&amp_mqtt_handle->mqtt_handle, amp_mqtt_params); if (ret < 0) { amp_debug(MOD_STR, "mqtt client init failed"); aos_free(amp_mqtt_params); aos_free(amp_mqtt_handle); return; } amp_mqtt_handle->res = ret; /* return aiot_device_handle */ amp_task_schedule_call(mqtt_handle_notify, amp_mqtt_handle); while(!g_mqtt_close_flag) { aos_msleep(1000); } aos_free(amp_mqtt_params); aos_free(amp_mqtt_handle); aos_sem_signal(&g_mqtt_close_sem); aos_task_exit(0); } static duk_ret_t native_mqtt_start(duk_context *ctx) { int ret; amp_mqtt_params_t *mqtt_params = NULL; aos_task_t mqtt_task; /* check paramters */ if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be object and function\n"); ret = -1; goto out; } /* get device certificate */ duk_get_prop_string(ctx, 0, "host"); duk_get_prop_string(ctx, 0, "port"); duk_get_prop_string(ctx, 0, "client_id"); duk_get_prop_string(ctx, 0, "username"); duk_get_prop_string(ctx, 0, "password"); duk_get_prop_string(ctx, 0, "keepaliveSec"); if (!duk_is_string(ctx, -6) || !duk_is_number(ctx, -5) || !duk_is_string(ctx, -4) || !duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "Parameter 1 must be an object like {host: string, " "port: uint, client_id: string, username: string, " "password: string, keepalive_interval: uint}\n"); ret = -2; duk_pop_n(ctx, 6); goto out; } mqtt_params = (amp_mqtt_params_t *)aos_malloc(sizeof(amp_mqtt_params_t)); if (!mqtt_params) { amp_error(MOD_STR, "allocate memory failed\n"); goto out; } mqtt_params->host = duk_get_string(ctx, -6); mqtt_params->port = duk_get_number(ctx, -5); mqtt_params->clientid = duk_get_string(ctx, -4); mqtt_params->username = duk_get_string(ctx, -3); mqtt_params->password = duk_get_string(ctx, -2); mqtt_params->keepaliveSec = duk_get_number(ctx, -1); amp_debug(MOD_STR, "host: %s, port: %d\n", mqtt_params->host, mqtt_params->port); amp_debug(MOD_STR, "client_id: %s, username: %s, password: %s\n", mqtt_params->clientid, mqtt_params->username, mqtt_params->password); duk_dup(ctx, 1); // init_params->js_cb_ref = be_ref(ctx); mqtt_params->js_cb_ref[MQTT_JSCALLBACK_START_CLIENT_REF] = be_ref(ctx); /* create task to IOT_MQTT_Yield() */ ret = aos_task_new_ext(&mqtt_task, "amp mqtt task", mqtt_connect_task, mqtt_params, 1024 * 4, MQTT_TSK_PRIORITY); if (ret < 0) { amp_warn(MOD_STR, "jse_osal_create_task failed\n"); be_unref(ctx, mqtt_params->js_cb_ref[MQTT_JSCALLBACK_START_CLIENT_REF]); aos_free(mqtt_params); ret = -4; } out: duk_push_int(ctx, ret); return 1; } /* subscribe */ static duk_ret_t native_mqtt_subscribe(duk_context *ctx) { int res = -1; amp_mqtt_handle_t *amp_mqtt_handle = NULL; const char *topic = NULL; uint8_t qos = 0; int js_cb_ref = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object)"); goto out; } amp_mqtt_handle = duk_get_pointer(ctx, 0); if (amp_mqtt_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } duk_get_prop_string(ctx, 1, "topic"); duk_get_prop_string(ctx, 1, "qos"); if (!duk_is_number(ctx, -1) || !duk_is_string(ctx, -2)) { amp_warn(MOD_STR, "invalid params"); duk_pop_n(ctx, 2); goto out; } qos = duk_get_number(ctx, -1); topic = (char *)duk_get_string(ctx, -2); duk_dup(ctx, 2); js_cb_ref = be_ref(ctx); amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_SCRIBE_TOPIC_REF] = js_cb_ref; res = aiot_mqtt_sub(amp_mqtt_handle->mqtt_handle, topic, NULL, qos, NULL); if (res < 0) { amp_error(MOD_STR, "aiot app mqtt subscribe failed\n"); } out: duk_push_int(ctx, res); return 1; } /* unsubscribe */ static duk_ret_t native_mqtt_unsubscribe(duk_context *ctx) { int res = -1; amp_mqtt_handle_t *amp_mqtt_handle = NULL; const char *topic; uint8_t qos = 0; int js_cb_ref = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, string, function)"); goto out; } amp_mqtt_handle = duk_get_pointer(ctx, 0); if (amp_mqtt_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } topic = (char *)duk_get_string(ctx, 1); duk_dup(ctx, 2); js_cb_ref = be_ref(ctx); amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_UNSCRIBE_TOPIC_REF] = js_cb_ref; amp_debug(MOD_STR, "unsubscribe topic: %s", topic); res = aiot_mqtt_unsub(amp_mqtt_handle->mqtt_handle, topic); if (res < 0) { amp_error(MOD_STR, "aiot app mqtt unsubscribe failed\n"); } out: duk_push_int(ctx, res); return 1; } /* publish */ static duk_ret_t native_mqtt_publish(duk_context *ctx) { int res = -1; amp_mqtt_handle_t *amp_mqtt_handle = NULL; const char *topic; const char *payload; uint16_t payload_len = 0; uint8_t qos = 0; int js_cb_ref = 0; if (!duk_is_pointer(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (pointer, object, function)"); goto out; } amp_mqtt_handle = duk_get_pointer(ctx, 0); if (amp_mqtt_handle == NULL) { amp_warn(MOD_STR, "mqtt handle is null"); goto out; } duk_get_prop_string(ctx, 1, "topic"); duk_get_prop_string(ctx, 1, "payload"); duk_get_prop_string(ctx, 1, "qos"); if (!duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "invalid params"); duk_pop_n(ctx, 3); goto out; } qos = duk_get_number(ctx, -1); payload = (char *)duk_get_string(ctx, -2); topic = (char *)duk_get_string(ctx, -3); payload_len = strlen(payload); duk_dup(ctx, 2); js_cb_ref = be_ref(ctx); amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_PUBLISH_REF] = js_cb_ref; amp_debug(MOD_STR, "publish topic: %s, payload: %s, qos is: %d", topic, payload, qos); res = aiot_mqtt_pub(amp_mqtt_handle->mqtt_handle, topic, payload, payload_len, qos); if (res < 0) { amp_error(MOD_STR, "aiot app mqtt publish failed"); } out: duk_push_int(ctx, res); return 1; } static duk_ret_t native_mqtt_close(duk_context *ctx) { int res = -1; int js_cb_ref = 0; amp_mqtt_handle_t *amp_mqtt_handle = NULL; if (!duk_is_pointer(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be pointer function"); goto out; } amp_mqtt_handle = duk_get_pointer(ctx, 0); if (amp_mqtt_handle == NULL) { amp_warn(MOD_STR, "mqtt client is null"); goto out; } duk_dup(ctx, 1); js_cb_ref = be_ref(ctx); amp_mqtt_handle->js_cb_ref[MQTT_JSCALLBACK_CLIENT_STOP_REF] = js_cb_ref; res = mqtt_client_stop(&amp_mqtt_handle->mqtt_handle); if (res < 0) { amp_debug(MOD_STR, "mqtt client stop failed"); } out: /* release mqtt in mqtt_yield_task() */ g_mqtt_close_flag = 1; aos_sem_wait(&g_mqtt_close_sem, MQTT_TASK_YIELD_TIMEOUT + 50); g_mqtt_close_flag = 0; return 1; } static void module_mqtt_source_clean(void) { if (g_mqtt_close_flag) { aos_sem_wait(&g_mqtt_close_sem, MQTT_TASK_YIELD_TIMEOUT + 50); g_mqtt_close_flag = 0; } } void module_mqtt_register(void) { duk_context *ctx = be_get_context(); if (!g_mqtt_close_sem) { if (aos_sem_new(&g_mqtt_close_sem, 0) != 0) { amp_error(MOD_STR, "create mqtt sem fail"); return; } } amp_module_free_register(module_mqtt_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("start", native_mqtt_start, 2); AMP_ADD_FUNCTION("subscribe", native_mqtt_subscribe, 3); AMP_ADD_FUNCTION("unsubscribe", native_mqtt_unsubscribe, 3); AMP_ADD_FUNCTION("publish", native_mqtt_publish, 5); AMP_ADD_FUNCTION("close", native_mqtt_close, 2); duk_put_prop_string(ctx, -2, "MQTT"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/mqtt/module_mqtt.c
C
apache-2.0
10,125
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "stdint.h" /** * @brief subdev模块内部发生值得用户关注的状态变化时, 通知用户的事件类型 */ typedef enum { /** * @brief 非法的应答报文 */ MQTT_JSCALLBACK_INVALID_REF, /** * @brief 应答报文的id字段非法 */ MQTT_JSCALLBACK_START_CLIENT_REF, /** * @brief 应答报文的id字段非法 */ MQTT_JSCALLBACK_SCRIBE_TOPIC_REF, /** * @brief 应答报文的id字段非法 */ MQTT_JSCALLBACK_UNSCRIBE_TOPIC_REF, /** * @brief 应答报文的id字段非法 */ MQTT_JSCALLBACK_PUBLISH_REF, /** * @brief 应答报文的id字段非法 */ MQTT_JSCALLBACK_CLIENT_STOP_REF, /** * @brief 应答报文的code字段非法 */ MQTT_JSCALLBACK_INVALID_CODE } amp_mqtt_jscallback_type_t; typedef struct amp_mqtt_params{ char *host; uint16_t port; char *clientid; char *username; char *password; uint8_t keepaliveSec; int js_cb_ref[MQTT_JSCALLBACK_INVALID_CODE]; int res; }amp_mqtt_params_t; typedef struct amp_mqtt_handle{ void *mqtt_handle; int js_cb_ref[MQTT_JSCALLBACK_INVALID_CODE]; int res; }amp_mqtt_handle_t; /* create mqtt client */ int32_t mqtt_client_start(void **handle, amp_mqtt_params_t *mqtt_params); /* destroy mqtt client */ int32_t mqtt_client_stop(void **handle);
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/mqtt/module_mqtt.h
C
apache-2.0
1,446
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "aos/kv.h" #include "aiot_state_api.h" #include "aiot_sysdep_api.h" #include "aiot_mqtt_api.h" #include "be_inl.h" #include "module_mqtt.h" #define MOD_STR "MQTT" /* 位于portfiles/aiot_port文件夹下的系统适配函数集合 */ extern aiot_sysdep_portfile_t g_aiot_sysdep_portfile; /* 位于external/ali_ca_cert.c中的服务器证书 */ extern const char *ali_ca_cert; uint8_t mqtt_process_thread_running = 0; uint8_t mqtt_recv_thread_running = 0; /* 执行aiot_mqtt_process的线程, 包含心跳发送和QoS1消息重发 */ void mqtt_process_thread(void *args) { int32_t res = STATE_SUCCESS; while (mqtt_process_thread_running) { res = aiot_mqtt_process(args); if (res == STATE_USER_INPUT_EXEC_DISABLED) { break; } aos_msleep(1000); } aos_task_exit(0); return; } /* 执行aiot_mqtt_recv的线程, 包含网络自动重连和从服务器收取MQTT消息 */ void mqtt_recv_thread(void *args) { int32_t res = STATE_SUCCESS; while (mqtt_recv_thread_running) { res = aiot_mqtt_recv(args); if (res < STATE_SUCCESS) { if (res == STATE_USER_INPUT_EXEC_DISABLED) { break; } aos_msleep(1000); } } aos_task_exit(0); return; } /* MQTT默认消息处理回调, 当SDK从服务器收到MQTT消息时, 且无对应用户回调处理时被调用 */ void mqtt_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata) { switch (packet->type) { case AIOT_MQTTRECV_HEARTBEAT_RESPONSE: { // amp_debug(MOD_STR, "heartbeat response"); /* TODO: 处理服务器对心跳的回应, 一般不处理 */ } break; case AIOT_MQTTRECV_SUB_ACK: { amp_debug(MOD_STR, "suback, res: -0x%04X, packet id: %d, max qos: %d", -packet->data.sub_ack.res, packet->data.sub_ack.packet_id, packet->data.sub_ack.max_qos); /* TODO: 处理服务器对订阅请求的回应, 一般不处理 */ } break; case AIOT_MQTTRECV_PUB: { amp_debug(MOD_STR, "pub, qos: %d, topic: %.*s", packet->data.pub.qos, packet->data.pub.topic_len, packet->data.pub.topic); amp_debug(MOD_STR, "pub, payload: %.*s", packet->data.pub.payload_len, packet->data.pub.payload); /* TODO: 处理服务器下发的业务报文 */ } break; case AIOT_MQTTRECV_PUB_ACK: { amp_debug(MOD_STR, "puback, packet id: %d", packet->data.pub_ack.packet_id); /* TODO: 处理服务器对QoS1上报消息的回应, 一般不处理 */ } break; default: { } } } /* MQTT事件回调函数, 当网络连接/重连/断开时被触发, 事件定义见core/aiot_mqtt_api.h */ void mqtt_event_handler(void *handle, const aiot_mqtt_event_t *event, void *userdata) { switch (event->type) { /* SDK因为用户调用了aiot_mqtt_connect()接口, 与mqtt服务器建立连接已成功 */ case AIOT_MQTTEVT_CONNECT: { amp_debug(MOD_STR, "AIOT_MQTTEVT_CONNECT"); /* TODO: 处理SDK建连成功, 不可以在这里调用耗时较长的阻塞函数 */ int js_cb_ref = (int *)userdata; amp_debug(MOD_STR, "js cb ref is: %d", js_cb_ref); duk_context *ctx = be_get_context(); be_push_ref(ctx, js_cb_ref); duk_push_int(ctx, 9); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } break; /* SDK因为网络状况被动断连后, 自动发起重连已成功 */ case AIOT_MQTTEVT_RECONNECT: { amp_debug(MOD_STR, "AIOT_MQTTEVT_RECONNECT"); /* TODO: 处理SDK重连成功, 不可以在这里调用耗时较长的阻塞函数 */ } break; /* SDK因为网络的状况而被动断开了连接, network是底层读写失败, heartbeat是没有按预期得到服务端心跳应答 */ case AIOT_MQTTEVT_DISCONNECT: { char *cause = (event->data.disconnect == AIOT_MQTTDISCONNEVT_NETWORK_DISCONNECT) ? ("network disconnect") : ("heartbeat disconnect"); amp_debug(MOD_STR, "AIOT_MQTTEVT_DISCONNECT: %s", cause); /* TODO: 处理SDK被动断连, 不可以在这里调用耗时较长的阻塞函数 */ } break; default: { } } } int32_t mqtt_client_start(void **handle, amp_mqtt_params_t *mqtt_params) { int32_t res = STATE_SUCCESS; void *mqtt_handle = NULL; char *host = mqtt_params->host; uint16_t port = mqtt_params->port; char *clientid = mqtt_params->clientid; char *username = mqtt_params->username; char *password = mqtt_params->password; uint16_t keepaliveSec = mqtt_params->keepaliveSec; int js_cb_ref = mqtt_params->js_cb_ref; aiot_sysdep_network_cred_t cred; /* 配置SDK的底层依赖 */ aiot_sysdep_set_portfile(&g_aiot_sysdep_portfile); /* 配置SDK的日志输出 */ // aiot_state_set_logcb(demo_state_logcb); /* 创建SDK的安全凭据, 用于建立TLS连接 */ memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t)); cred.option = AIOT_SYSDEP_NETWORK_CRED_SVRCERT_CA; /* 使用RSA证书校验MQTT服务端 */ cred.max_tls_fragment = 16384; /* 最大的分片长度为16K, 其它可选值还有4K, 2K, 1K, 0.5K */ cred.sni_enabled = 1; /* TLS建连时, 支持Server Name Indicator */ cred.x509_server_cert = ali_ca_cert; /* 用来验证MQTT服务端的RSA根证书 */ cred.x509_server_cert_len = strlen(ali_ca_cert); /* 用来验证MQTT服务端的RSA根证书长度 */ /* 创建1个MQTT客户端实例并内部初始化默认参数 */ mqtt_handle = aiot_mqtt_init(); if (mqtt_handle == NULL) { amp_debug(MOD_STR, "aiot_mqtt_init failed"); aos_free(mqtt_handle); return NULL; } /* TODO: 如果以下代码不被注释, 则例程会用TCP而不是TLS连接云平台 */ { memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t)); cred.option = AIOT_SYSDEP_NETWORK_CRED_NONE; } /* 配置MQTT服务器地址 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_HOST, (void *)host); /* 配置MQTT服务器端口 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PORT, (void *)&port); /* 配置设备productKey */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_CLIENTID, (void *)clientid); /* 配置设备deviceName */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_USERNAME, (void *)username); /* 配置设备deviceSecret */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PASSWORD, (void *)password); /* 配置网络连接的安全凭据, 上面已经创建好了 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_NETWORK_CRED, (void *)&cred); /* 配置MQTT心跳间隔 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_KEEPALIVE_SEC, (void *)&keepaliveSec); /* 配置回调参数 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_USERDATA, js_cb_ref); /* 配置MQTT默认消息接收回调函数 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_RECV_HANDLER, (void *)mqtt_recv_handler); /* 配置MQTT事件回调函数 */ aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_EVENT_HANDLER, (void *)mqtt_event_handler); /* 与服务器建立MQTT连接 */ res = aiot_mqtt_connect(mqtt_handle); if (res < STATE_SUCCESS) { /* 尝试建立连接失败, 销毁MQTT实例, 回收资源 */ aiot_mqtt_deinit(&mqtt_handle); amp_debug(MOD_STR, "aiot_mqtt_connect failed: -0x%04X", -res); aos_task_exit(0); return NULL; } /* 创建一个单独的线程, 专用于执行aiot_mqtt_process, 它会自动发送心跳保活, 以及重发QoS1的未应答报文 */ mqtt_process_thread_running = 1; aos_task_t mqtt_process_task; if (aos_task_new_ext(&mqtt_process_task, "mqtt_process", mqtt_process_thread, mqtt_handle, 1024 * 4, AOS_DEFAULT_APP_PRI) != 0) { amp_debug(MOD_STR, "management mqtt process task create failed!"); aiot_mqtt_deinit(&mqtt_handle); aos_task_exit(0); return NULL; } amp_debug(MOD_STR, "app mqtt process start"); /* 创建一个单独的线程用于执行aiot_mqtt_recv, 它会循环收取服务器下发的MQTT消息, 并在断线时自动重连 */ mqtt_recv_thread_running = 1; aos_task_t mqtt_rec_task; if (aos_task_new_ext(&mqtt_rec_task, "mqtt_rec", mqtt_recv_thread, mqtt_handle, 1024 * 4, AOS_DEFAULT_APP_PRI) != 0) { amp_debug(MOD_STR, "management mqtt rec task create failed!"); aiot_mqtt_deinit(&mqtt_handle); aos_task_exit(0); return NULL; } amp_debug(MOD_STR, "app mqtt rec start"); *handle = mqtt_handle; return res; } /* mqtt stop */ int32_t mqtt_client_stop(void **handle) { int32_t res = STATE_SUCCESS; void *mqtt_handle = NULL; mqtt_handle = *handle; mqtt_process_thread_running = 0; mqtt_recv_thread_running = 0; /* 断开MQTT连接 */ res = aiot_mqtt_disconnect(mqtt_handle); if (res < STATE_SUCCESS) { aiot_mqtt_deinit(&mqtt_handle); amp_debug(MOD_STR, "aiot_mqtt_disconnect failed: -0x%04X", -res); return -1; } /* 销毁MQTT实例 */ res = aiot_mqtt_deinit(&mqtt_handle); if (res < STATE_SUCCESS) { amp_debug(MOD_STR, "aiot_mqtt_deinit failed: -0x%04X", -res); return -1; } return res; }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/mqtt/module_mqtt_client.c
C
apache-2.0
9,954
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "aos_network.h" #include "netmgr_wifi.h" #include "amp_task.h" #include "be_inl.h" #include "aos/list.h" #define MOD_STR "module_netmgr" #define CONNECT_WAIT_TIME_MS (10 * 1000) #define CHECKIP_INTERVAL_MS 200 typedef int js_cb_ref; typedef struct msg_cb_info { slist_t next; js_cb_ref cb_ref; } msg_cb_info_t; typedef struct wifi_connect_task_params { js_cb_ref cb_ref; netmgr_hdl_t hdl; } wifi_connect_task_params_t; static slist_t g_msg_cb_list_head; static void js_cb_conn_status(void *pdata) { int ret = -1; wifi_connect_task_params_t* params; netmgr_ifconfig_info_t info; netmgr_hdl_t hdl; int cb_ref; if(pdata == NULL) { amp_debug(MOD_STR, "pdata is null"); return ; } params = (wifi_connect_task_params_t*) pdata; hdl = params->hdl; ret = netmgr_get_ifconfig(hdl, &info); if (ret != 0) { amp_debug(MOD_STR, "get ifconfig info failed"); } duk_context *ctx = be_get_context(); cb_ref = params->cb_ref; be_push_ref(ctx, cb_ref); if (strcmp(info.ip_addr, "0.0.0.0") != 0) duk_push_string(ctx, "CONNECTED"); else duk_push_string(ctx, "DISCONNECT"); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, cb_ref); duk_gc(ctx, 0); } static void check_ip_task(void *arg) { int ret = -1; int count = 0; netmgr_ifconfig_info_t info; wifi_connect_task_params_t* params; netmgr_hdl_t hdl; if(arg == NULL) { amp_debug(MOD_STR, "check ip task arg is null"); return ; } params = (wifi_connect_task_params_t*) arg; hdl = params->hdl; while (1) { ret = netmgr_get_ifconfig(hdl, &info); if (ret != 0) { amp_debug(MOD_STR, "get ifconfig info failed"); } if ((strcmp(info.ip_addr, "0.0.0.0") != 0) || (count > CONNECT_WAIT_TIME_MS / CHECKIP_INTERVAL_MS)) { amp_task_schedule_call(js_cb_conn_status, arg); break; } aos_msleep(CHECKIP_INTERVAL_MS); count++; } return; } static duk_ret_t native_netmgr_service_init(duk_context *ctx) { int ret; ret = event_service_init(NULL); if (ret != 0) { amp_debug(MOD_STR, "netmgr service init failed"); goto out; } ret = netmgr_service_init(NULL); if (ret != 0) { amp_debug(MOD_STR, "netmgr service init failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_service_deinit(duk_context *ctx) { netmgr_hdl_t hdl; int ret = -1; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number\n"); goto out; } hdl = duk_get_number(ctx, 0); netmgr_service_deinit(hdl); ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_add_dev(duk_context *ctx) { char* name; int ret = -1; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string\n"); goto out; } name = duk_get_string(ctx, 0); ret = netmgr_add_dev(name); if (ret != 0) { amp_debug(MOD_STR, "netmgr add dev failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_get_dev(duk_context *ctx) { char* name; int ret = -1; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "parameter must be string\n"); goto out; } name = duk_get_string(ctx, 0); ret = netmgr_get_dev(name); if (ret != 0) { amp_debug(MOD_STR, "netmgr get dev failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_set_auto_reconnect(duk_context *ctx) { int ret = -1; netmgr_hdl_t hdl; int enable; if (!duk_is_number(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be number and number\n"); goto out; } hdl = duk_get_int(ctx, 0); enable = duk_get_int(ctx, 1); if(enable == 1) { netmgr_set_auto_reconnect(hdl, true); ret = 0; } else if(enable == 0) { netmgr_set_auto_reconnect(hdl, false); ret = 0; } out: duk_push_int(ctx, ret); return 1; } static wifi_connect_task_params_t connect_task_params; static duk_ret_t native_netmgr_connect(duk_context *ctx) { int ret = -1; aos_task_t netmgr_connect_task; netmgr_hdl_t hdl; netmgr_connect_params_t params; char* ssid; char* password; char* bssid; int timeout_ms; if (!duk_is_number(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be number, object and function\n"); goto out; } hdl = duk_get_int(ctx, 0); duk_get_prop_string(ctx, 1, "ssid"); duk_get_prop_string(ctx, 1, "password"); duk_get_prop_string(ctx, 1, "bssid"); duk_get_prop_string(ctx, 1, "timeout_ms"); if(!duk_is_string(ctx, -4) || !duk_is_string(ctx, -3) || !duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "invalid params\n"); ret = -2; goto out; } ssid = duk_get_string(ctx, -4); password = duk_get_string(ctx, -3); bssid = duk_get_string(ctx, -2); timeout_ms = duk_get_number(ctx, -1); memset(&params, 0, sizeof(netmgr_connect_params_t)); params.type = NETMGR_TYPE_WIFI; strncpy(params.params.wifi_params.ssid, ssid, sizeof(params.params.wifi_params.ssid) - 1); strncpy(params.params.wifi_params.pwd, password, sizeof(params.params.wifi_params.pwd) - 1); params.params.wifi_params.timeout = timeout_ms; ret = netmgr_connect(hdl, &params); if (ret != 0) { amp_warn(MOD_STR, "netmgr connect failed\n"); goto out; } duk_dup(ctx, 2); int cb_ref = be_ref(ctx); memset(&connect_task_params, 0, sizeof(connect_task_params)); connect_task_params.cb_ref = cb_ref; connect_task_params.hdl = hdl; ret = aos_task_new_ext(&netmgr_connect_task, "netmgr connect task", check_ip_task, (void *)&connect_task_params, 1024 * 2, ADDON_TSK_PRIORRITY); if (ret != 0) { amp_warn(MOD_STR, "jse_osal_create_task failed\n"); be_unref(ctx, cb_ref); } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_netmgr_disconnect * Description: js native addon for WIFI.getssid() * Called by: js api * Input: no input * Output: return a string object to js api what the mac is *****************************************************************************/ static duk_ret_t native_netmgr_disconnect(duk_context *ctx) { int ret = -1; netmgr_hdl_t hdl; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number\n"); goto out; } hdl = duk_get_number(ctx, 0); ret = netmgr_disconnect(hdl); if (ret != 0) { amp_debug(MOD_STR, "netmgr disconnect failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_netmgr_get_state * Description: js native addon for NETMGR.getState() * Called by: js api * Input: no input * Output: return a string object to js api what the mac is *****************************************************************************/ static duk_ret_t native_netmgr_get_state(duk_context *ctx) { int ret = -1; netmgr_hdl_t hdl; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number\n"); goto out; } hdl = duk_get_number(ctx, 0); ret = netmgr_get_state(hdl); out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_save_config(duk_context *ctx) { int ret = -1; netmgr_hdl_t hdl; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number\n"); goto out; } hdl = duk_get_number(ctx, 0); ret = netmgr_save_config(hdl); if (ret != 0) { amp_debug(MOD_STR, "netmgr get state failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_get_config(duk_context *ctx) { int ret = -1; //TODO out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_del_config(duk_context *ctx) { int ret = -1; //TODO out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_netmgr_set_ifconfig * Description: js native addon for NETMGR.setIconfig() * Called by: js api * Input: no input * Output: return a string object to js api,if it is NULL means can't get *ip *****************************************************************************/ static duk_ret_t native_netmgr_set_ifconfig(duk_context *ctx) { int ret = -1; netmgr_hdl_t hdl; netmgr_ifconfig_info_t info; if (!duk_is_number(ctx, 0) || !duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number and object\n"); goto out; } hdl = duk_get_number(ctx, 0); /* get device certificate */ duk_get_prop_string(ctx, 1, "dhcp_en"); duk_get_prop_string(ctx, 1, "ip_addr"); duk_get_prop_string(ctx, 1, "mask"); duk_get_prop_string(ctx, 1, "gw"); duk_get_prop_string(ctx, 1, "dns_server"); duk_get_prop_string(ctx, 1, "mac"); info.dhcp_en = duk_get_boolean(ctx, -6); memcpy(info.ip_addr, duk_get_string(ctx, -5), strlen(duk_get_string(ctx, -5))); memcpy(info.mask, duk_get_string(ctx, -4), strlen(duk_get_string(ctx, -4))); memcpy(info.gw, duk_get_string(ctx, -3), strlen(duk_get_string(ctx, -3))); memcpy(info.dns_server, duk_get_string(ctx, -2), strlen(duk_get_string(ctx, -2))); memcpy(info.mac, duk_get_string(ctx, -1), strlen(duk_get_string(ctx, -1))); ret = netmgr_set_ifconfig(hdl, &info); if (ret != 0) { amp_debug(MOD_STR, "set ifconfig failed"); } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_netmgr_get_ifconfig * Description: js native addon for NETMGR.getIfconfig() * Called by: js api * Input: no input * Output: return a string object to js api,if it is NULL means can't get *ip *****************************************************************************/ static duk_ret_t native_netmgr_get_ifconfig(duk_context *ctx) { int ret = -1; netmgr_hdl_t hdl; netmgr_ifconfig_info_t info; if (!duk_is_number(ctx, 0) || !duk_is_object(ctx, 1)) { amp_warn(MOD_STR, "parameter must be number and object\n"); goto out; } hdl = duk_get_number(ctx, 0); ret = netmgr_get_ifconfig(hdl, &info); if (ret != 0) { amp_debug(MOD_STR, "get ifconfig failed"); goto out; } const bool dhcp_en = info.dhcp_en; const char *ip_addr = info.ip_addr; const char *mask = info.mask; const char *gw = info.gw; const char *dns_server = info.dns_server; const char *mac = info.mac; const int rssi = info.rssi; duk_push_object(ctx); duk_push_boolean(ctx, dhcp_en); duk_put_prop_string(ctx, 1, "dhcp_en"); duk_push_string(ctx, ip_addr); duk_put_prop_string(ctx, 1, "ip_addr"); duk_push_string(ctx, mask); duk_put_prop_string(ctx, 1, "mask"); duk_push_string(ctx, gw); duk_put_prop_string(ctx, 1, "gw"); duk_push_string(ctx, dns_server); duk_put_prop_string(ctx, 1, "dns_server"); duk_push_string(ctx, mac); duk_put_prop_string(ctx, 1, "mac"); duk_push_int(ctx, rssi); duk_put_prop_string(ctx, 1, "rssi"); out: duk_push_int(ctx, ret); return 1; } static int set_msg_cb(netmgr_msg_t* msg) { msg_cb_info_t* info; duk_context *ctx = be_get_context(); slist_for_each_entry(&g_msg_cb_list_head, info, msg_cb_info_t, next) { be_push_ref(ctx, info->cb_ref); switch(msg->id) { case NETMGR_MSGID_WIFI_STATUS: duk_push_object(ctx); duk_push_int(ctx, msg->id); duk_put_prop_string(ctx, 0, "msgid"); duk_push_string(ctx, msg->data.network_status_change); duk_put_prop_string(ctx, 0, "data"); break; case NETMGR_MSGID_WIFI_STATUS_FROM_IMPL: duk_push_object(ctx); duk_push_int(ctx, msg->id); duk_put_prop_string(ctx, 0, "msgid"); duk_push_string(ctx, msg->data.status); duk_put_prop_string(ctx, 0, "data"); break; case NETMGR_MSGID_WIFI_TRACE_FROM_IMPL: case NETMGR_MSGID_NETWORK_STATUS: case NETMGR_MSGID_ETH_STATUS_FROM_IMPL: default: return -1; } if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } } return 0; } static duk_ret_t native_netmgr_set_msg_cb(duk_context *ctx) { netmgr_hdl_t hdl; int ret = -1; int msg_cb_ref; msg_cb_info_t *info; if (!duk_is_number(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be number and function\n"); goto out; } hdl = duk_get_number(ctx, 0); duk_dup(ctx, 1); msg_cb_ref = be_ref(ctx); info = (msg_cb_info_t*)malloc(sizeof(msg_cb_info_t)); if(info != NULL) { if(slist_empty(&g_msg_cb_list_head)) { ret = netmgr_set_msg_cb(hdl, set_msg_cb); } memset(info, 0, sizeof(msg_cb_info_t)); info->cb_ref = msg_cb_ref; slist_add(info, &g_msg_cb_list_head); ret = 0; } out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_netmgr_del_msg_cb(duk_context *ctx) { netmgr_hdl_t hdl; msg_cb_info_t *info; int msg_cb_ref; int ret = -1; if (!duk_is_number(ctx, 0) || !duk_is_object(ctx, 1)) { amp_warn(MOD_STR, "parameter must be number and object\n"); goto out; } hdl = duk_get_number(ctx, 0); duk_dup(ctx, 1); msg_cb_ref = be_ref(ctx); slist_for_each_entry(&g_msg_cb_list_head, info, msg_cb_info_t, next) { if(msg_cb_ref == info->cb_ref) { slist_del(&(info->next), &g_msg_cb_list_head); ret = 0; break; } } if(slist_empty(&g_msg_cb_list_head)) { ret = netmgr_del_msg_cb(hdl, set_msg_cb); } out: duk_push_int(ctx, ret); return 1; } void module_netmgr_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("serviceInit", native_netmgr_service_init, 0); AMP_ADD_FUNCTION("serviceDeinit", native_netmgr_service_deinit, 1); AMP_ADD_FUNCTION("addDev", native_netmgr_add_dev, 1); AMP_ADD_FUNCTION("getDev", native_netmgr_get_dev, 1); AMP_ADD_FUNCTION("setAutoReconnect", native_netmgr_set_auto_reconnect, 2); AMP_ADD_FUNCTION("connect", native_netmgr_connect, 3); AMP_ADD_FUNCTION("disconnect", native_netmgr_disconnect, 1); AMP_ADD_FUNCTION("getState", native_netmgr_get_state, 1); AMP_ADD_FUNCTION("saveConfig", native_netmgr_save_config, 1); AMP_ADD_FUNCTION("getConfig", native_netmgr_get_config, 2); AMP_ADD_FUNCTION("delConfig", native_netmgr_del_config, 2); AMP_ADD_FUNCTION("setIfConfig", native_netmgr_set_ifconfig, 2); AMP_ADD_FUNCTION("getIfConfig", native_netmgr_get_ifconfig, 2); AMP_ADD_FUNCTION("setMsgCb", native_netmgr_set_msg_cb, 2); AMP_ADD_FUNCTION("delMsgCb", native_netmgr_del_msg_cb, 2); duk_put_prop_string(ctx, -2, "NETMGR"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/netmgr/module_netmgr.c
C
apache-2.0
16,138
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_config.h" #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "aos_tcp.h" #include "be_inl.h" #define MOD_STR "TCP" #define MAX_TCP_RECV_LEN 256 #define MAX_TCP_RECV_TIMEOUT 200 typedef struct { int sock_id; char *msg; int msg_len; int js_cb_ref; } tcp_send_param_t; typedef struct { int ret; int js_cb_ref; } tcp_send_notify_param_t; typedef struct { int sock_id; int js_cb_ref; } tcp_recv_param_t; typedef struct { char *host; int port; int js_cb_ref; } tcp_create_param_t; typedef struct { int ret; int js_cb_ref; } tcp_create_notify_param_t; typedef struct { char buf[MAX_TCP_RECV_LEN]; int recv_len; int js_cb_ref; } tcp_recv_notify_param_t; static char g_tcp_close_flag = 0; static char g_tcp_recv_flag = 0; static aos_sem_t g_tcp_close_sem = NULL; static void tcp_create_notify(void *pdata) { tcp_create_notify_param_t *p = (tcp_create_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_int(ctx, p->ret); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, p->js_cb_ref); aos_free(p); duk_gc(ctx, 0); } static int tcp_create_routine(tcp_create_param_t *create_param) { int ret = -1; tcp_create_notify_param_t *p; duk_context *ctx = be_get_context(); p = aos_calloc(1, sizeof(tcp_create_notify_param_t)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); be_unref(ctx, create_param->js_cb_ref); goto out; } ret = aos_tcp_establish(create_param->host, create_param->port); if (ret < 0) { amp_warn(MOD_STR, "tcp establish failed"); } amp_debug(MOD_STR, "sock_id = %d", ret); p->js_cb_ref = create_param->js_cb_ref; p->ret = ret; amp_task_schedule_call(tcp_create_notify, p); out: return ret; } /************************************************************************************* * Function: native_udp_create_socket * Description: js native addon for UDP.createSocket(); * Called by: js api * Input: none * Output: return socket fd when create socket success, * return error number when create socket fail **************************************************************************************/ static duk_ret_t native_tcp_create_socket(duk_context *ctx) { int err; int ret = -1; int port = 0; const char *host; tcp_create_param_t *create_param = NULL; if (!duk_is_object(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (object, function)"); goto out; } /* get device certificate */ duk_get_prop_string(ctx, 0, "host"); duk_get_prop_string(ctx, 0, "port"); if (!duk_is_string(ctx, -2) || !duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "Parameter 1 must be an object like {host: string, " "port: uint}"); err = -2; goto out; } host = duk_get_string(ctx, -2); port = duk_get_number(ctx, -1); amp_debug(MOD_STR, "host: %s, port: %d", host, port); create_param = (tcp_create_param_t *)aos_malloc(sizeof(*create_param)); if (!create_param) { amp_error(MOD_STR, "allocate memory failed"); goto out; } duk_dup(ctx, 1); create_param->host = host; create_param->port = port; create_param->js_cb_ref = be_ref(ctx); ret = tcp_create_routine(create_param); if (ret < 0) { amp_warn(MOD_STR, "tcp create socket failed"); goto out; } out: if(create_param) { aos_free(create_param); } duk_push_int(ctx, ret); return 1; } static void tcp_send_notify(void *pdata) { tcp_send_notify_param_t *p = (tcp_send_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_int(ctx, p->ret); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, p->js_cb_ref); aos_free(p); duk_gc(ctx, 0); } /************************************************************************************* * Function: udp_send_routin * Description: create a task for blocking sendto call * Called by: **************************************************************************************/ static int tcp_send_routine(tcp_send_param_t *send_param) { int ret = -1; tcp_send_notify_param_t *p; int sock_id; duk_context *ctx = be_get_context(); sock_id = send_param->sock_id; ret = aos_tcp_write(sock_id, send_param->msg, send_param->msg_len, 0); p = aos_calloc(1, sizeof(tcp_send_notify_param_t)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); be_unref(ctx, send_param->js_cb_ref); goto out; } p->js_cb_ref = send_param->js_cb_ref; p->ret = ret; amp_task_schedule_call(tcp_send_notify, p); ret = 0; out: aos_free(send_param->msg); aos_free(send_param); return ret; } /************************************************************************************* * Function: native_udp_sendto * Description: js native addon for *UDP.send(sock_id,option,buffer_array,function(ret){}) Called by: js api * Input: sock_id: interger * options: is a object include options.ip and options.port * buffer_array: is a array which include message to send * function(ret): is the callback function which has a ret input *param Output: return send msg length when send success return error *number when send fail **************************************************************************************/ static duk_ret_t native_tcp_send(duk_context *ctx) { int ret = -1; int sock_id; int i; int msg_len; char *msg; if (!duk_is_number(ctx, 0) || !duk_is_array(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (number, string, function)"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id <= 0) { amp_warn(MOD_STR, "socket id[%d] is invalid", sock_id); goto out; } msg_len = duk_get_length(ctx, 1); msg = (char *)aos_malloc(msg_len + 1); if (!msg) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < msg_len; i++) { duk_get_prop_index(ctx, 1, i); msg[i] = duk_get_int(ctx, -1); duk_pop(ctx); } msg[msg_len] = 0; // const char *send_buf = duk_get_string(ctx, 1); // msg_len = strlen(send_buf); // msg = (char *)aos_malloc(msg_len); // if (msg == NULL) { // amp_warn(MOD_STR, "allocate memory failed"); // goto out; // } // strncpy(msg, send_buf, msg_len); amp_debug(MOD_STR, "msg is:%s, length is: %d", msg, msg_len); tcp_send_param_t *send_param = (tcp_send_param_t *)aos_malloc(sizeof(*send_param)); if (!send_param) { amp_error(MOD_STR, "allocate memory failed"); aos_free(msg); goto out; } send_param->sock_id = sock_id; send_param->msg = msg; send_param->msg_len = msg_len; duk_dup(ctx, 2); send_param->js_cb_ref = be_ref(ctx); tcp_send_routine(send_param); out: duk_push_int(ctx, ret); return 1; } static void tcp_recv_notify(void *pdata) { int i = 0; tcp_recv_notify_param_t *p = (tcp_recv_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_int(ctx, p->recv_len); int arr_idx = duk_push_array(ctx); if(p->recv_len > 0) { for (i = 0; i < p->recv_len; i++) { duk_push_int(ctx, p->buf[i]); duk_put_prop_index(ctx, arr_idx, i); } } if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); if(p->recv_len < 0) { be_unref(ctx, p->js_cb_ref); aos_free(p); } } /************************************************************************************* * Function: udp_recv_routine * Description: create a task for blocking recvfrom call * Called by: **************************************************************************************/ static void tcp_recv_routine(void *arg) { tcp_recv_param_t *recv_param = (tcp_recv_param_t *)arg; int sock_id; g_tcp_recv_flag = 1; sock_id = recv_param->sock_id; tcp_recv_notify_param_t *p = aos_calloc(1, sizeof(*p)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); duk_context *ctx = be_get_context(); be_unref(ctx, recv_param->js_cb_ref); goto out; } while(1) { p->recv_len = aos_tcp_read(sock_id, p->buf, sizeof(p->buf), MAX_TCP_RECV_TIMEOUT); p->js_cb_ref = recv_param->js_cb_ref; if(p->recv_len != 0) { amp_task_schedule_call(tcp_recv_notify, p); } if(p->recv_len < 0) { // connection closed amp_error(MOD_STR, "connection closed:%d", p->recv_len); break; } if (g_tcp_close_flag) { duk_context *ctx = be_get_context(); be_unref(ctx, recv_param->js_cb_ref); aos_free(p); break; } } aos_tcp_destroy(sock_id); out: aos_free(recv_param); g_tcp_recv_flag = 0; aos_sem_signal(&g_tcp_close_sem); aos_task_exit(0); return; } /************************************************************************************* * Function: native_udp_recvfrom * Description: js native addon for * UDP.recv(sock_id,function(length, buffer_array, src_ip, *src_port){}) Called by: js api Input: sock_id: interger * function(length, buffer_array, src_ip, src_port): the callback *function length: the recv msg length buffer_array: the recv msg buffer src_ip: *the peer ip string src_port: the peer port which is a interger * * Output: return 0 when UDP.recv call ok * return error number UDP.recv call fail **************************************************************************************/ static duk_ret_t native_tcp_receive(duk_context *ctx) { int ret = -1; int sock_id = 0; aos_task_t tcp_recv_task; tcp_recv_param_t *recv_param; if (!duk_is_number(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be number and function"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id < 0) { amp_warn(MOD_STR, "socket id[%d] is invalid", sock_id); goto out; } amp_debug(MOD_STR, "sock_id: %d", sock_id); recv_param = (tcp_recv_param_t *)aos_calloc(1, sizeof(*recv_param)); if (!recv_param) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } recv_param->sock_id = sock_id; duk_dup(ctx, 1); recv_param->js_cb_ref = be_ref(ctx); ret = aos_task_new_ext(&tcp_recv_task, "amp tcp recv task", tcp_recv_routine, recv_param, 1024 * 4, ADDON_TSK_PRIORRITY); if (ret != 0) { amp_warn(MOD_STR, "tcp recv task error"); goto out; } out: duk_push_int(ctx, ret); return 1; } /************************************************************************************* * Function: native_tcp_close * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ static duk_ret_t native_tcp_close(duk_context *ctx) { int ret = -1; int sock_id = 0; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id <= 0) { amp_warn(MOD_STR, "socket id[%d] is invalid", sock_id); goto out; } g_tcp_close_flag = 1; aos_sem_wait(&g_tcp_close_sem, MAX_TCP_RECV_TIMEOUT + 50); g_tcp_close_flag = 0; ret = 0; out: duk_push_int(ctx, ret); return 1; } static void module_tcp_source_clean(void) { if (g_tcp_recv_flag) { g_tcp_close_flag = 1; aos_sem_wait(&g_tcp_close_sem, MAX_TCP_RECV_TIMEOUT + 50); g_tcp_close_flag = 0; } } void module_tcp_register(void) { duk_context *ctx = be_get_context(); if (!g_tcp_close_sem) { if (aos_sem_new(&g_tcp_close_sem, 0) != 0) { amp_error(MOD_STR, "create tcp sem fail"); return; } } amp_module_free_register(module_tcp_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("createSocket", native_tcp_create_socket, 2); AMP_ADD_FUNCTION("send", native_tcp_send, 3); AMP_ADD_FUNCTION("recv", native_tcp_receive, 2); AMP_ADD_FUNCTION("close", native_tcp_close, 1); duk_put_prop_string(ctx, -2, "TCP"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/tcp/module_tcp.c
C
apache-2.0
13,435
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_config.h" #include "amp_platform.h" #include "aos_system.h" #include "amp_utils.h" #include "amp_task.h" #include "amp_defines.h" #include "aos_udp.h" #include "be_inl.h" #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif #define MOD_STR "UDP" #define MAX_UDP_RECV_LEN 256 #define MAX_UDP_RECV_TIMEOUT 200 typedef struct { char ip[INET_ADDRSTRLEN]; int port; char *msg; } udp_options_t; typedef struct { int sock_id; char *msg; int msg_len; udp_options_t options; int js_cb_ref; } udp_send_param_t; typedef struct { int ret; int js_cb_ref; } udp_send_notify_param_t; typedef struct { int sock_id; udp_options_t options; int js_cb_ref; } udp_recv_param_t; typedef struct { char buf[MAX_UDP_RECV_LEN]; int recv_len; char src_ip[INET_ADDRSTRLEN]; unsigned short src_port; int js_cb_ref; } udp_recv_notify_param_t; static char g_udp_close_flag = 0; static char g_udp_recv_flag = 0; static aos_sem_t g_udp_close_sem = NULL; /************************************************************************************* * Function: native_udp_create_socket * Description: js native addon for UDP.createSocket(); * Called by: js api * Input: none * Output: return socket fd when create socket success, * return error number when create socket fail **************************************************************************************/ static duk_ret_t native_udp_create_socket(duk_context *ctx) { int sock_id = 0; sock_id = aos_udp_socket_create(); if (sock_id < 0) { amp_warn(MOD_STR, "create socket error!"); goto out; } amp_debug(MOD_STR, "sock_id = %d", sock_id); duk_push_int(ctx, sock_id); return 1; out: duk_push_string(ctx, "create socket error!"); return duk_throw(ctx); } /************************************************************************************* * Function: native_udp_bind * Description: js native addon for UDP.bind(sock_id,"ip",port) * Called by: js api * Input: UDP.bind(sock_id,"ip",port): * sock_id: is a iterger * ip: is a ip stirng like "192.168.1.1" * port: is a iterger port * Output: return 0 when bind successed * return error number when bind fail **************************************************************************************/ static duk_ret_t native_udp_bind(duk_context *ctx) { int ret = -1; int port = 0; int sock_id; if (!duk_is_number(ctx, 0) || !duk_is_number(ctx, 1)) { amp_warn(MOD_STR, "parameter must be (number, number)"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id < 0) { amp_error(MOD_STR, "socket id[%d] error", sock_id); goto out; } port = duk_get_int(ctx, 1); if (port < 0) { amp_error(MOD_STR, "port[%d] error", port); goto out; } amp_debug(MOD_STR, "udp bind socket id=%d, port=%d", sock_id, port); ret = aos_udp_socket_bind(sock_id, port); if (ret < 0) { amp_error(MOD_STR, "udp bind error"); goto out; } // return ret; out: duk_push_int(ctx, ret); return 1; } static void udp_send_notify(void *pdata) { udp_send_notify_param_t *p = (udp_send_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); duk_push_int(ctx, p->ret); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, p->js_cb_ref); aos_free(p); duk_gc(ctx, 0); } /************************************************************************************* * Function: udp_send_routin * Description: create a task for blocking sendto call * Called by: **************************************************************************************/ static int udp_send_routine(udp_send_param_t *send_param) { int ret = -1; int sock_id; udp_options_t udp_options; udp_send_notify_param_t *p; duk_context *ctx = be_get_context(); sock_id = send_param->sock_id; memcpy(&udp_options, &(send_param->options), sizeof(udp_options_t)); ret = aos_udp_sendto(sock_id, &udp_options, send_param->msg, send_param->msg_len, 0); p = aos_calloc(1, sizeof(udp_send_notify_param_t)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); be_unref(ctx, send_param->js_cb_ref); goto out; } p->js_cb_ref = send_param->js_cb_ref; p->ret = ret; amp_task_schedule_call(udp_send_notify, p); ret = 0; out: aos_free(send_param->msg); aos_free(send_param); return ret; } /************************************************************************************* * Function: native_udp_sendto * Description: js native addon for *UDP.send(sock_id,option,buffer_array,function(ret){}) Called by: js api * Input: sock_id: interger * options: is a object include options.ip and options.port * buffer_array: is a array which include message to send * function(ret): is the callback function which has a ret input *param Output: return send msg length when send success return error *number when send fail **************************************************************************************/ static duk_ret_t native_udp_sendto(duk_context *ctx) { int ret = -1; udp_options_t options; int sock_id; int i; int msg_len; char *msg; if (!duk_is_number(ctx, 0) || !duk_is_object(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be (number, object, array, function)"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id <= 0) { amp_warn(MOD_STR, "socket id[%d] is invalid", sock_id); goto out; } memset(&options, 0, sizeof(udp_options_t)); /* options.port */ duk_get_prop_string(ctx, 1, "port"); if (!duk_is_number(ctx, -1)) { amp_warn(MOD_STR, "port not specify"); duk_pop(ctx); goto out; } options.port = duk_get_int(ctx, -1); duk_pop(ctx); /* options.address */ duk_get_prop_string(ctx, 1, "address"); if (!duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "ip not specify"); duk_pop(ctx); goto out; } strncpy(options.ip, duk_get_string(ctx, -1), sizeof(options.ip) - 1); duk_pop(ctx); /* options.message */ duk_get_prop_string(ctx, 1, "message"); if (!duk_is_array(ctx, -1)) { amp_warn(MOD_STR, "message not specify"); duk_pop(ctx); goto out; } msg_len = duk_get_length(ctx, -1); msg = (char *)aos_calloc(1, msg_len + 1); if (!msg) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } for (i = 0; i < msg_len; i++) { duk_get_prop_index(ctx, -1, i); msg[i] = duk_get_int(ctx, -1); duk_pop(ctx); } msg[msg_len] = 0; // options.msg = (char *)duk_get_string(ctx, -1); // msg_len = strlen(options.msg); // duk_pop(ctx); // msg = (char *)aos_calloc(1, msg_len + 1); // if (!msg) { // amp_warn(MOD_STR, "allocate memory failed"); // goto out; // } // strncpy(msg, options.msg, msg_len); amp_debug(MOD_STR, "msg is:%s, length is: %d", msg, msg_len); udp_send_param_t *send_param = (udp_send_param_t *)aos_malloc(sizeof(*send_param)); if (!send_param) { amp_error(MOD_STR, "allocate memory failed"); aos_free(msg); goto out; } send_param->sock_id = sock_id; duk_dup(ctx, 2); send_param->js_cb_ref = be_ref(ctx); send_param->msg = msg; send_param->msg_len = msg_len; memcpy(&(send_param->options), &options, sizeof(udp_options_t)); amp_debug(MOD_STR, "sockid:%d ip:%s port:%d msg:%s msg_len:%d", sock_id, options.ip, options.port, msg, msg_len); udp_send_routine(send_param); out: duk_push_int(ctx, ret); return 1; } static void udp_recv_notify(void *pdata) { int i = 0; udp_recv_notify_param_t *p = (udp_recv_notify_param_t *)pdata; duk_context *ctx = be_get_context(); be_push_ref(ctx, p->js_cb_ref); int arr_idx = duk_push_array(ctx); if(p->recv_len > 0) { for (i = 0; i < p->recv_len; i++) { duk_push_int(ctx, p->buf[i]); duk_put_prop_index(ctx, arr_idx, i); } } duk_push_object(ctx); duk_push_string(ctx, p->src_ip); duk_put_prop_string(ctx, -2, "host"); duk_push_uint(ctx, p->src_port); duk_put_prop_string(ctx, -2, "port"); duk_push_int(ctx, p->recv_len); if (duk_pcall(ctx, 3) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); if(p->recv_len < 0) { be_unref(ctx, p->js_cb_ref); aos_free(p); } } /************************************************************************************* * Function: udp_recv_routine * Description: create a task for blocking recvfrom call * Called by: **************************************************************************************/ static void udp_recv_routine(void *arg) { udp_recv_param_t *recv_param = (udp_recv_param_t *)arg; int sock_id; udp_options_t udp_options; aos_networkAddr addr_info; udp_recv_notify_param_t *p; duk_context *ctx = be_get_context(); sock_id = recv_param->sock_id; memcpy(&udp_options, &(recv_param->options), sizeof(udp_options_t)); p = aos_calloc(1, sizeof(udp_recv_notify_param_t)); if (!p) { amp_warn(MOD_STR, "allocate memory failed"); duk_context *ctx = be_get_context(); be_unref(ctx, recv_param->js_cb_ref); goto out; } g_udp_recv_flag = 1; while(1) { p->recv_len = aos_udp_recvfrom(sock_id, &addr_info, p->buf, sizeof(p->buf), MAX_UDP_RECV_TIMEOUT); strcpy(p->src_ip, addr_info.addr); p->src_port = addr_info.port; p->js_cb_ref = recv_param->js_cb_ref; if (p->recv_len > 0) { amp_task_schedule_call(udp_recv_notify, p); } if (p->recv_len < 0) { // connection closed amp_error(MOD_STR, "connection closed:%d", p->recv_len); break; } if (g_udp_close_flag) { duk_context *ctx = be_get_context(); be_unref(ctx, recv_param->js_cb_ref); if (p) { aos_free(p); } break; } } aos_udp_close_without_connect(sock_id); out: aos_free(recv_param); g_udp_recv_flag = 0; aos_sem_signal(&g_udp_close_sem); aos_task_exit(0); return; } /************************************************************************************* * Function: native_udp_recvfrom * Description: js native addon for * UDP.recv(sock_id,function(length, buffer_array, src_ip, *src_port){}) Called by: js api Input: sock_id: interger * function(length, buffer_array, src_ip, src_port): the callback *function length: the recv msg length buffer_array: the recv msg buffer src_ip: *the peer ip string src_port: the peer port which is a interger * * Output: return 0 when UDP.recv call ok * return error number UDP.recv call fail **************************************************************************************/ static duk_ret_t native_udp_recvfrom(duk_context *ctx) { int ret = -1; int sock_id = 0; aos_task_t udp_recv_task; udp_recv_param_t *recv_param; if (!duk_is_number(ctx, 0) || !duk_is_function(ctx, 1)) { amp_warn(MOD_STR, "parameter must be number and function"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id < 0) { amp_warn(MOD_STR, "socket id[%d] is invalid", sock_id); goto out; } amp_debug(MOD_STR, "sock_id: %d", sock_id); recv_param = (udp_recv_param_t *)aos_calloc(1, sizeof(*recv_param)); if (!recv_param) { amp_warn(MOD_STR, "allocate memory failed"); goto out; } recv_param->sock_id = sock_id; duk_dup(ctx, 1); recv_param->js_cb_ref = be_ref(ctx); ret = aos_task_new_ext(&udp_recv_task, "amp udp recv task", udp_recv_routine, recv_param, 1024 * 4, ADDON_TSK_PRIORRITY); if (ret != 0) { amp_debug(MOD_STR, "udp recv task create faild"); goto out; } out: duk_push_int(ctx, ret); return 1; } /************************************************************************************* * Function: native_udp_close_socket * Description: js native addon for * UDP.close(sock_id) * Called by: js api * Input: sock_id: interger * * Output: return 0 when UDP.close call ok * return error number UDP.close call fail **************************************************************************************/ static duk_ret_t native_udp_close_socket(duk_context *ctx) { int ret = -1; int sock_id = 0; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be number"); goto out; } sock_id = duk_get_int(ctx, 0); if (sock_id <= 0) { amp_warn(MOD_STR, "socket id[%d] is invalid", sock_id); goto out; } g_udp_close_flag = 1; aos_sem_wait(&g_udp_close_sem, MAX_UDP_RECV_TIMEOUT + 50); g_udp_close_flag = 0; ret = 0; out: duk_push_int(ctx, ret); return 1; } static void module_udp_source_clean(void) { if (g_udp_recv_flag) { g_udp_close_flag = 1; aos_sem_wait(&g_udp_close_sem, MAX_UDP_RECV_TIMEOUT + 50); g_udp_close_flag = 0; } } void module_udp_register(void) { duk_context *ctx = be_get_context(); if (!g_udp_close_sem) { if (aos_sem_new(&g_udp_close_sem, 0) != 0) { amp_error(MOD_STR, "create udp sem fail"); return; } } amp_module_free_register(module_udp_source_clean); duk_push_object(ctx); AMP_ADD_FUNCTION("createSocket", native_udp_create_socket, 0); AMP_ADD_FUNCTION("bind", native_udp_bind, 2); AMP_ADD_FUNCTION("sendto", native_udp_sendto, 3); AMP_ADD_FUNCTION("recvfrom", native_udp_recvfrom, 2); AMP_ADD_FUNCTION("close", native_udp_close_socket, 1); duk_put_prop_string(ctx, -2, "UDP"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/udp/module_udp.c
C
apache-2.0
14,595
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "aos_network.h" #include "netmgr_wifi.h" #include "amp_task.h" #include "be_inl.h" #define MOD_STR "WIFI" #define WIFI_CONNECT_WAIT_TIME_MS (10 * 1000) #define WIFI_CHECKIP_INTERVAL_MS 200 static void js_cb_wifi_conn_status(void *pdata) { int ret = -1; int js_cb_ref = (int)pdata; aos_wifi_info_t wifi_info; ret = aos_get_wifi_info(&wifi_info); if (ret != 0) { amp_debug(MOD_STR, "get wifi info failed"); } duk_context *ctx = be_get_context(); be_push_ref(ctx, js_cb_ref); if (strcmp(wifi_info.ip, "0,0,0,0") != 0) duk_push_string(ctx, "CONNECTED"); else duk_push_string(ctx, "DISCONNECT"); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); be_unref(ctx, js_cb_ref); duk_gc(ctx, 0); } static void wifi_check_ip_task(void *arg) { int ret = -1; int count = 0; aos_wifi_info_t wifi_info; ret = aos_get_wifi_info(&wifi_info); if (ret != 0) { amp_debug(MOD_STR, "get wifi info failed"); } while (1) { if ((strcmp(wifi_info.ip, "0,0,0,0") != 0) || (count > WIFI_CONNECT_WAIT_TIME_MS / WIFI_CHECKIP_INTERVAL_MS)) { amp_task_schedule_call(js_cb_wifi_conn_status, arg); break; } aos_msleep(WIFI_CHECKIP_INTERVAL_MS); count++; } return; } static duk_ret_t native_wifi_connect(duk_context *ctx) { int ret = -1; aos_task_t wifi_connect_task; if (!duk_is_string(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_function(ctx, 2)) { amp_warn(MOD_STR, "parameter must be string, string and function\n"); goto out; } const char *ssid = duk_get_string(ctx, 0); const char *passwd = duk_get_string(ctx, 1); ret = aos_wifi_connect(ssid, passwd); if (ret != 0) { amp_warn(MOD_STR, "wifi connect failed\n"); goto out; } duk_dup(ctx, 2); int js_cb_ref = be_ref(ctx); ret = aos_task_new_ext(&wifi_connect_task, "wifi connect task", wifi_check_ip_task, (void *)js_cb_ref, 1024 * 2, ADDON_TSK_PRIORRITY); if (ret != 0) { amp_warn(MOD_STR, "jse_osal_create_task failed\n"); be_unref(ctx, js_cb_ref); } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_wifi_getip * Description: js native addon for WIFI.getip() * Called by: js api * Input: no input * Output: return a string object to js api,if it is NULL means can't get *ip *****************************************************************************/ static duk_ret_t native_wifi_set_ifconfig(duk_context *ctx) { int ret = -1; netmgr_ifconfig_info_t info; if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "parameter must be object\n"); goto out; } /* get device certificate */ duk_get_prop_string(ctx, 0, "dhcp_en"); duk_get_prop_string(ctx, 0, "ip_addr"); duk_get_prop_string(ctx, 0, "mask"); duk_get_prop_string(ctx, 0, "gw"); duk_get_prop_string(ctx, 0, "dns_server"); duk_get_prop_string(ctx, 0, "mac"); memcpy(info.ip_addr, duk_get_string(ctx, -5), strlen(duk_get_string(ctx, -5))); memcpy(info.mask, duk_get_string(ctx, -4), strlen(duk_get_string(ctx, -4))); memcpy(info.gw, duk_get_string(ctx, -3), strlen(duk_get_string(ctx, -3))); memcpy(info.dns_server, duk_get_string(ctx, -2), strlen(duk_get_string(ctx, -2))); memcpy(info.mac, duk_get_string(ctx, -1), strlen(duk_get_string(ctx, -1))); ret = aos_wifi_set_ifconfig(&info); if (ret != 0) { amp_debug(MOD_STR, "get wifi info failed"); } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_wifi_getip * Description: js native addon for WIFI.getip() * Called by: js api * Input: no input * Output: return a string object to js api,if it is NULL means can't get *ip *****************************************************************************/ static duk_ret_t native_wifi_get_ifconfig(duk_context *ctx) { int ret = -1; aos_wifi_info_t wifi_info; ret = aos_get_wifi_info(&wifi_info); if (ret != 0) { amp_debug(MOD_STR, "get wifi info failed"); goto out; } const char *ssid = wifi_info.ssid; const char *ip = wifi_info.ip; const char *mac = wifi_info.mac; int rssi = wifi_info.rssi; duk_push_object(ctx); duk_push_string(ctx, ssid); duk_put_prop_string(ctx, -2, "ssid"); duk_push_string(ctx, ip); duk_put_prop_string(ctx, -2, "ip"); duk_push_string(ctx, mac); duk_put_prop_string(ctx, -2, "mac"); duk_push_int(ctx, rssi); duk_put_prop_string(ctx, -2, "rssi"); return 1; out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_wifi_getssid * Description: js native addon for WIFI.getssid() * Called by: js api * Input: no input * Output: return a string object to js api what the mac is *****************************************************************************/ static duk_ret_t native_wifi_disconnect(duk_context *ctx) { int ret = -1; ret = aos_wifi_disconnect(); if (ret != 0) { amp_debug(MOD_STR, "wifi disconnect failed"); goto out; } return 1; out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_wifi_getssid * Description: js native addon for WIFI.getssid() * Called by: js api * Input: no input * Output: return a string object to js api what the mac is *****************************************************************************/ static duk_ret_t native_wifi_get_type(duk_context *ctx) { int ret = -1; ret = aos_get_network_type(); out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_wifi_getssid * Description: js native addon for WIFI.getssid() * Called by: js api * Input: no input * Output: return a string object to js api what the mac is *****************************************************************************/ static duk_ret_t native_wifi_get_state(duk_context *ctx) { int ret = -1; ret = aos_wifi_disconnect(); if (ret != 0) { amp_debug(MOD_STR, "wifi disconnect failed"); goto out; } return 1; out: duk_push_int(ctx, ret); return 1; } void module_wifi_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("getType", native_wifi_get_type, 0); AMP_ADD_FUNCTION("setIfConfig", native_wifi_set_ifconfig, 1); AMP_ADD_FUNCTION("getIfConfig", native_wifi_get_ifconfig, 0); AMP_ADD_FUNCTION("connect", native_wifi_connect, 3); AMP_ADD_FUNCTION("disconnect", native_wifi_disconnect, 0); AMP_ADD_FUNCTION("getState", native_wifi_get_state, 0); duk_put_prop_string(ctx, -2, "WIFI"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/network/wifi/module_wifi.c
C
apache-2.0
7,452
/* * Copyright (C) 2015-2021 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "board_mgr.h" #include "be_inl.h" #include "amp_task.h" #define MOD_STR "AT" #define MAX_LINE_SIZE 1024 typedef struct { int js_cb_ref; char *buf; int buflen; aos_sem_new sem; } at_notify_param_t; static duk_ret_t native_atRead(duk_context *ctx) { char *outbuf = NULL; int readsize = 0; int size = 0; int received = 0; int timeout = 0; uint64_t now = 0; if (!(duk_is_number(ctx, 0) && duk_is_number(ctx, 1))) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "native_atReadLine parameters must be number"); return duk_throw(ctx); } readsize = duk_is_number(ctx, 0); timeout = duk_get_number(ctx, 1); now = aos_now_ms(); amp_debug(MOD_STR, "native_atRead readsize %d, timeout %d", readsize, timeout); outbuf = (char *)aos_malloc(readsize + 1); memset(outbuf, 0, readsize + 1); while (received < readsize) { if (aos_now_ms() - now > (unsigned long)timeout) { received = 0; break; } size = amp_at_read(&outbuf[received], 1); if(size == 1) { received ++; } else { aos_msleep(1); } } amp_debug(MOD_STR, "native_atRead received %d", received); if(received > 0) { duk_push_string(ctx, outbuf); } else { duk_push_undefined(ctx); } aos_free(outbuf); return 1; } static duk_ret_t native_atReadLine(duk_context *ctx) { char *outbuf = NULL; int readsize = 0; int size = 0; int received = 0; int timeout = 0; uint64_t now = 0; if (!(duk_is_number(ctx, 0))) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "native_atReadLine parameters must be number"); return duk_throw(ctx); } readsize = MAX_LINE_SIZE; timeout = duk_get_number(ctx, 0); now = aos_now_ms(); outbuf = (char *)aos_malloc(readsize + 1); memset(outbuf, 0, readsize + 1); while (received < readsize) { if (aos_now_ms() - now > (unsigned long)timeout) { received = 0; break; } size = amp_at_read(&outbuf[received], 1); if(size == 1) { if(outbuf[received] == '\n') { outbuf[received + 1] = '\0'; break; } else { received ++; } } else { aos_msleep(1); } } if(received > 0) { duk_push_string(ctx, outbuf); } else { duk_push_undefined(ctx); } aos_free(outbuf); return 1; } static duk_ret_t native_atSendNoReply(duk_context *ctx) { int ret = 0; const char *data = NULL; bool delimiter = false; if (!(duk_is_string(ctx, 0) && duk_is_number(ctx, 1) )) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "atSendNoReply parameters must be string and function"); return duk_throw(ctx); } data = duk_get_string(ctx, 0); delimiter = duk_get_number(ctx, 1); ret = amp_at_send_no_reply(data, strlen(data), (delimiter != 0) ? true : false); duk_push_int(ctx, ret); amp_debug(MOD_STR, "native_atSendNoReply"); return 0; } static void at_notify(void *arg) { at_notify_param_t *param = (at_notify_param_t *)arg; duk_context *ctx = be_get_context(); be_push_ref(ctx, param->js_cb_ref); duk_push_pointer(ctx, param->buf); duk_push_int(ctx, param->buflen); if (duk_pcall(ctx, 2) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); aos_sem_signal(&param->sem); } /* avoid stdout in irq function */ static void native_atCallback(void *arg, char *buf, int buflen) { at_notify_param_t *at_notify_param = NULL; at_notify_param = (at_notify_param_t *) aos_malloc(sizeof(at_notify_param_t)); at_notify_param->js_cb_ref = (int)(arg); at_notify_param->buf = (char *)malloc(buflen); memcpy(at_notify_param->buf, buf, buflen); at_notify_param->buflen = buflen; aos_sem_new(&at_notify_param->sem, 0); amp_debug(MOD_STR, "native_atCallback buflen %d\n", at_notify_param->buflen); amp_task_schedule_call(at_notify, at_notify_param); aos_sem_wait(&at_notify_param->sem, AOS_WAIT_FOREVER); aos_sem_free(&at_notify_param->sem); aos_free(at_notify_param->buf); aos_free(at_notify_param); amp_debug(MOD_STR, "native_atCallback end\n"); } static duk_ret_t native_atRegisterCmdCallback(duk_context *ctx) { char *prefix = NULL; void *js_cb_ref = NULL; int prompt = 0; int ret = 0; if (!(duk_is_string(ctx, 0) && duk_is_function(ctx, 1) )) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "atRegisterCmdCallback parameters must be string and function"); return duk_throw(ctx); } prefix = (char *)duk_get_string(ctx, 0); duk_dup(ctx, 1); js_cb_ref = (void *)be_ref(ctx); ret = amp_at_register_callback(prefix, native_atCallback, js_cb_ref); duk_push_int(ctx, ret); amp_debug(MOD_STR, "native_atRegisterCmdCallback"); return 1; } static duk_ret_t native_atInit(duk_context *ctx) { int at_uart_port = 0; uint32_t baud_rate = 0; char *send_delimiter = NULL; int ret = 0; if (!(duk_is_number(ctx, 0) && duk_is_number(ctx, 1) && duk_is_string(ctx, 2))) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "atInit parameters must be number"); return duk_throw(ctx); } at_uart_port = duk_get_number(ctx, 0); baud_rate = duk_get_number(ctx, 1); send_delimiter = duk_get_string(ctx, 2); ret = amp_at_init(at_uart_port, baud_rate, send_delimiter); duk_push_int(ctx, ret); amp_debug(MOD_STR, "native_atInit"); return 1; } static duk_ret_t native_atDeInit(duk_context *ctx) { amp_at_deinit(); duk_push_int(ctx, 0); return 1; } static duk_ret_t native_atSetEcho(duk_context *ctx) { int flag = 0; if (!(duk_is_number(ctx, 0))) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "atInit parameters must be number"); return duk_throw(ctx); } flag = duk_get_number(ctx, 0); amp_at_set_echo(flag); duk_push_int(ctx, 0); return 1; } static void module_atClean(void) { amp_at_deinit(); } void module_at_register(void) { amp_debug(MOD_STR, "module_at_register"); duk_context *ctx = be_get_context(); amp_module_free_register(module_atClean); duk_push_object(ctx); AMP_ADD_FUNCTION("atInit", native_atInit, 3); AMP_ADD_FUNCTION("atDeInit", native_atDeInit, 0); AMP_ADD_FUNCTION("atSetEcho", native_atSetEcho, 1); AMP_ADD_FUNCTION("atRegisterCmdCallback", native_atRegisterCmdCallback, 2); AMP_ADD_FUNCTION("atSendNoReply", native_atSendNoReply, 2); AMP_ADD_FUNCTION("atRead", native_atRead, 2); AMP_ADD_FUNCTION("atReadLine", native_atReadLine, 1); duk_put_prop_string(ctx, -2, "AT"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/at/module_at.c
C
apache-2.0
7,457
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_system.h" #include "be_inl.h" #include "aos_fs.h" #include "board_mgr.h" #define MOD_STR "BUILTIN" #define GLOBAL_APPCONFIG_STRING_1 "Object.defineProperty(this, 'appConfig', { value: " #define GLOBAL_APPCONFIG_STRING_2 ", writable: false });" extern int g_repl_config; static duk_ret_t native_console_log(duk_context *ctx) { duk_idx_t n = duk_get_top(ctx); duk_idx_t i; duk_get_global_string(ctx, "console"); duk_get_prop_string(ctx, -1, "format"); for (i = 0; i < n; i++) { if (duk_check_type_mask(ctx, i, DUK_TYPE_MASK_OBJECT)) { /* Slow path formatting. */ duk_dup(ctx, -1); /* console.format */ duk_dup(ctx, i); duk_call(ctx, 1); duk_replace(ctx, i); /* arg[i] = console.format(arg[i]); */ } } duk_pop_2(ctx); duk_push_string(ctx, ""); duk_insert(ctx, 0); duk_join(ctx, duk_get_top(ctx) - 1); const char *msg = duk_safe_to_string(ctx, -1); if (bone_console_get_log_flag()) { amp_console("%s", msg); if (g_repl_config) { #ifdef AMP_REPL_STDIO_EXTERNAL repl_printf("%s", msg); repl_printf("\r\n"); #endif } } return 0; } /* export appConfig */ static void native_add_global_appconfig(duk_context *ctx) { char json_dir[32] = {0}; char *json = NULL; void *json_data = NULL; uint32_t len = 0; uint32_t global_config_len = 0; int json_fd = -1; snprintf(json_dir, 32, AMP_APP_MAIN_JSON); // amp_debug(MOD_STR, "path:%s", json_dir); if ((json_fd = aos_open(json_dir, O_RDONLY)) < 0) { amp_error(MOD_STR, "open:%s fail", json_dir); return; } // amp_debug(MOD_STR, "jse_lseek:%d", *(int *)json_fd); len = aos_lseek(json_fd, 0, SEEK_END); printf("%s %d\r\n", __func__, len); global_config_len = len + strlen(GLOBAL_APPCONFIG_STRING_1) + strlen(GLOBAL_APPCONFIG_STRING_2) + 1; // amp_debug(MOD_STR, "jse_lseek, len: %d, globallen:%d", len, global_config_len); if ((json_data = aos_calloc(1, global_config_len)) == NULL) { aos_close(json_fd); amp_error(MOD_STR, "memory overflow"); return; } aos_lseek(json_fd, 0, SEEK_SET); strncpy(json_data, GLOBAL_APPCONFIG_STRING_1, global_config_len); aos_read(json_fd, json_data + strlen(GLOBAL_APPCONFIG_STRING_1), len); strcpy(json_data + strlen(GLOBAL_APPCONFIG_STRING_1) + len, GLOBAL_APPCONFIG_STRING_2); if (duk_peval_string(ctx, json_data) != DUK_EXEC_SUCCESS) { amp_console("export appConfig failed: %s\n", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); amp_debug(MOD_STR, "export appConfig"); aos_close(json_fd); aos_free(json_data); } void module_builtin_register(void) { amp_debug(MOD_STR, "module_builtin_register"); duk_context *ctx = be_get_context(); duk_push_object(ctx); /* Custom function to format objects; user can replace. * For now, try JX-formatting and if that fails, fall back * to ToString(v). */ duk_eval_string(ctx, "(function (E) {" "return function format(v){" "try{" "return E('jx',v);" "}catch(e){" "return String(v);" /* String() allows symbols, ToString() internal algorithm doesn't. */ "}" "};" "})(Duktape.enc)"); duk_put_prop_string(ctx, -2, "format"); duk_push_c_function(ctx, native_console_log, DUK_VARARGS); duk_put_prop_string(ctx, -2, "log"); duk_put_global_string(ctx, "console"); /* print module */ duk_push_c_function(ctx, native_console_log, DUK_VARARGS); duk_put_global_string(ctx, "print"); /* export appConfig */ native_add_global_appconfig(ctx); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/builtin/module_builtin.c
C
apache-2.0
4,112
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "amp_utils.h" #include "be_inl.h" #include "mbedtls/md5.h" #define MOD_STR "CRYPTO" #define DEBUG_HEX_DUMP(str, buff, len) hexdump(str, buff, len) // #define DEBUG_HEX_DUMP(str, buff, len) #if 0 static duk_ret_t native_crypto_encrypt(duk_context *ctx) { char *crypte_mode = NULL, *aes_type = NULL, *aes_padding = NULL; int i = 0; char *key = NULL; char *iv = NULL; unsigned char *input = NULL; unsigned char *dest = NULL; if (!duk_is_string(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_string(ctx, 2) || !duk_is_object(ctx, 3)){ amp_error(MOD_STR, "invalid parameter");; goto done; } crypte_mode = (const char *)duk_get_string(ctx, 0); aes_type = (const char *)duk_get_string(ctx, 1); aes_padding = (const char *)duk_get_string(ctx, 2); if (strcasecmp(crypte_mode, "aes") != 0) { amp_error(MOD_STR, "not supprted crypte_mode"); goto done; /* now just support aes encryption */ } if (strcasecmp(aes_type, "cbc") != 0) { amp_warn(MOD_STR, "aes type only cbc supported"); goto done; } /* input.key */ memset(&options, 0, sizeof(udp_options_t)); duk_get_prop_string(ctx, 1, "key"); if (!duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "key not specify"); duk_pop(ctx); goto out; } key = (const char *)duk_get_string(ctx, -1); duk_pop(ctx); /* input.iv */ duk_get_prop_string(ctx, 1, "iv"); if (!duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "iv not specify"); duk_pop(ctx); goto out; } strncpy(options.ip, duk_get_string(ctx, -1), sizeof(options.ip) - 1); duk_pop(ctx); crypte_mode = (const char *)duk_get_string(ctx, 3); amp_debug(MOD_STR, "native_crypto_encrypt"); if (!arg0 || !symbol_is_string(arg0) || !arg1 || !symbol_is_string(arg1) || !arg2 || !symbol_is_string(arg2) || !arg3 || !symbol_is_object(arg3)) { goto done; } return 1; done: duk_push_string(ctx, ""); return 1; } #endif static duk_ret_t native_crypto_decrypt(duk_context *ctx) { amp_debug(MOD_STR, "native_crypto_decrypt"); return 1; } static duk_ret_t native_crypto_md5(duk_context *ctx) { char *src = NULL, *data = NULL; int src_len = 0; char *dest; amp_md5_context s_ctx; uint8_t result[16] = {0}; char md5[33] = {0}; int i = 0; // amp_debug(MOD_STR, "native_crypto_md5, type:%d %d", duk_get_type(ctx, 0), duk_get_length(ctx, 0)); if (!duk_is_object(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter"); goto done; } src_len = duk_get_length(ctx, 0); src = (char *)aos_malloc(src_len); if (!src) { amp_error(MOD_STR, "allocate memory failed"); goto done; } for (i = 0; i < src_len; i++) { duk_get_prop_index(ctx, 0, i); src[i] = (char)duk_get_int(ctx, -1); duk_pop(ctx); } // DEBUG_HEX_DUMP("content data:", src, src_len); amp_md5(src, src_len, result); // DEBUG_HEX_DUMP("result data:", result, 16); for(i = 0; i < 16; ++i){ num2hex(result[i], &md5[2 * i]); } // amp_debug(MOD_STR, "md5: %s", md5); duk_push_string(ctx, md5); return 1; done: duk_push_string(ctx, ""); return 1; } void module_crypto_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("md5", native_crypto_md5, 1); // AMP_ADD_FUNCTION("encrypt", native_crypto_encrypt, 1); // AMP_ADD_FUNCTION("decrypt", native_crypto_decrypt, 1); duk_put_prop_string(ctx, -2, "crypto"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/crypto/module_crypto.c
C
apache-2.0
3,803
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_config.h" #include "aos_fs.h" #include "amp_defines.h" #include "aos_system.h" #include "be_inl.h" #define MOD_STR "FS" static int check_fs_is_support() { int ret; int fp; const char *string = "test if fs mount ok"; char testfile[64] = {0}; snprintf(testfile, sizeof(testfile), AMP_FS_ROOT_DIR"/%s", "testfile.txt"); fp = aos_open(testfile, O_RDWR | O_CREAT | O_TRUNC); if (fp < 0) { amp_warn(MOD_STR, "check_fs_is_support open fail\n"); return 0; } ret = aos_write(fp, (char *)string, strlen(string)); if (ret <= 0) { amp_warn(MOD_STR, "check_fs_is_support write fail\n"); aos_close(fp); return 0; } aos_close(fp); ret = aos_remove(testfile); if (ret) { amp_warn(MOD_STR, "check_fs_is_support sync fail\n"); return 0; } return 1; } /***************************************************************************** * Function: native_fs_issupport * Description: js native addon for FILE.issupport() * check if the js FILE object is support * Called by: js api * Input: none * Output: 1 :support ,0 :not support *****************************************************************************/ static duk_ret_t native_fs_is_support(duk_context *ctx) { int ret; ret = check_fs_is_support(); duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_read * Description: js native addon for FILE.read(filepath) * read the file content * Called by: js api * Input: filepath : string * Output: a String object which the file content is *****************************************************************************/ static duk_ret_t native_fs_read(duk_context *ctx) { int fp = -1; int len = 0; int size = 0; const char *path; char *buf = NULL; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } path = duk_get_string(ctx, 0); fp = aos_open(path, O_RDONLY); if (fp < 0) { amp_warn(MOD_STR, "jse_open failed\n"); goto out; } size = aos_lseek(fp, 0, HAL_SEEK_END); aos_lseek(fp, 0, HAL_SEEK_SET); buf = (char *)aos_malloc(size + 1); if (!buf) { amp_warn(MOD_STR, "malloc failed\n"); aos_close(fp); goto out; } len = aos_read(fp, buf, size); if (len > 0) { buf[len] = 0; amp_debug(MOD_STR, "read data: %s\n", buf); } aos_close(fp); out: if (len > 0) duk_push_string(ctx, buf); else duk_push_undefined(ctx); aos_free(buf); return 1; } /***************************************************************************** * Function: native_fs_write * Description: js native addon for FILE.write(filepath,buffer,mode) * write the content to the file * Called by: js api * Input: filepath : string ; * buffer: the content buffer which is a String object * mode: could be "w","r","w+","r+","a","a+" * Output: 0 write ok ;other write fail *****************************************************************************/ static duk_ret_t native_fs_write(duk_context *ctx) { int ret = -1; int fp = -1; size_t str_len = 0; size_t nwrite = 0; const char *path; const char *content; const char *flag; int aos_flag = 0, m = 0; if (!duk_is_string(ctx, 0) || !duk_is_string(ctx, 1) || !duk_is_object(ctx, 2)) { amp_warn(MOD_STR, "parameter must be [string, string, object]\n"); goto out; } path = duk_get_string(ctx, 0); content = duk_get_lstring(ctx, 1, &str_len); /* get device certificate */ duk_get_prop_string(ctx, 2, "flag"); if (!duk_is_string(ctx, -1)) { amp_warn(MOD_STR, "Parameter must be an object like {flag: string}"); ret = -1; goto out; } flag = duk_get_string(ctx, -1); switch (flag[0]) { case 'r': m = O_RDONLY; aos_flag = 0; break; case 'w': m = O_WRONLY; aos_flag = O_CREAT | O_TRUNC; break; case 'a': m = O_WRONLY; aos_flag = O_CREAT | O_APPEND; break; default: return -1; goto out; } while (*++flag) { switch (*flag) { case '+': m = (m & ~O_ACCMODE) | O_RDWR; break; default: break; } } aos_flag = m | aos_flag; fp = aos_open(path, aos_flag); if (fp < 0) { amp_error(MOD_STR, "be_osal_open fail\n"); goto out; } nwrite = aos_write(fp, (char *)content, str_len); if (nwrite <= 0) { amp_error(MOD_STR, "be_osal_write fail\n"); aos_close(fp); goto out; } amp_debug(MOD_STR, "FS.write(%s,%s,%s);\n", path, content, flag); aos_sync(fp); aos_close(fp); out: duk_push_int(ctx, nwrite == str_len ? 0 : -1); return 1; } /***************************************************************************** * Function: native_fs_delete * Description: js native addon for FILE.delete(filepath) * delete the file * Called by: js api * Input: filepath : string * Output: 0 delete ok ;other delete fail *****************************************************************************/ static duk_ret_t native_fs_delete(duk_context *ctx) { int ret = -1; const char *path; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } path = duk_get_string(ctx, 0); ret = aos_remove(path); out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_totalsize * Description: js native addon for FILE.totalsize() * get file system total size in bytes * Called by: js api * Output: file system total size in bytes; negative if failed. *****************************************************************************/ static duk_ret_t native_fs_totalsize(duk_context *ctx) { int ret = -1; int size; struct aos_statfs buf; aos_statfs(AMP_FS_ROOT_DIR, &buf); size = buf.f_bsize * buf.f_blocks; if (size < 0) { amp_error(MOD_STR, "get fs totalsize fail"); goto out; } ret = size; out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_usedsize * Description: js native addon for FILE.usedsize() * get file system used size in bytes * Called by: js api * Output: file system used size in bytes; negative if failed. *****************************************************************************/ static duk_ret_t native_fs_usedsize(duk_context *ctx) { int ret = -1; int size; struct aos_statfs buf; aos_statfs(AMP_FS_ROOT_DIR, &buf); size = buf.f_bsize * buf.f_blocks - buf.f_bsize * buf.f_bavail; if (size < 0) { amp_error(MOD_STR, "get fs usedsize fail"); goto out; } ret = size; out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_freesize * Description: js native addon for FILE.freesize() * get file system free size in bytes * Called by: js api * Output: file system free size in bytes; negative if failed. *****************************************************************************/ static duk_ret_t native_fs_freesize(duk_context *ctx) { int ret = -1; int size; struct aos_statfs buf; aos_statfs(AMP_FS_ROOT_DIR, &buf); size = buf.f_bsize * buf.f_bavail; if (size < 0) { amp_error(MOD_STR, "get fs freesize fail"); goto out; } ret = size; out: duk_push_int(ctx, ret); return 1; } void module_fs_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("issupport", native_fs_is_support, 0); AMP_ADD_FUNCTION("read", native_fs_read, 1); AMP_ADD_FUNCTION("write", native_fs_write, 3); AMP_ADD_FUNCTION("delete", native_fs_delete, 1); AMP_ADD_FUNCTION("totalsize", native_fs_totalsize, 0); AMP_ADD_FUNCTION("usedsize", native_fs_usedsize, 0); AMP_ADD_FUNCTION("freesize", native_fs_freesize, 0); duk_put_prop_string(ctx, -2, "FS"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/fs/module_fs.c
C
apache-2.0
8,748
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_config.h" #include "aos/kv.h" #include "amp_defines.h" #include "be_inl.h" #define MOD_STR "KV" #define KV_BUFFER_MAX_LEN 256 /***************************************************************************** * Function: native_fs_issupport * Description: js native addon for FILE.issupport() * check if the js FILE object is support * Called by: js api * Input: none * Output: 1 :support ,0 :not support *****************************************************************************/ static duk_ret_t native_kv_setStorage(duk_context *ctx) { int32_t ret = -1; int32_t value_len = 0; const char *key; const char *value; if (!duk_is_string(ctx, 0) || !duk_is_string(ctx, 1)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } key = duk_get_string(ctx, 0); value = duk_get_string(ctx, 1); value_len = strlen(value); ret = aos_kv_set(key, value, value_len, 1); if (ret != 0) { amp_warn(MOD_STR, "kv set storage failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } /***************************************************************************** * Function: native_fs_read * Description: js native addon for FILE.read(filepath) * read the file content * Called by: js api * Input: filepath : string * Output: a String object which the file content is *****************************************************************************/ static duk_ret_t native_kv_getStorage(duk_context *ctx) { int32_t ret = -1; int32_t value_len = KV_BUFFER_MAX_LEN; const char *key; char *value; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } key = duk_get_string(ctx, 0); value = (char *)aos_malloc(KV_BUFFER_MAX_LEN); if (value == NULL) { amp_warn(MOD_STR, "allocate memory failed\n"); goto out; } ret = aos_kv_get(key, value, &value_len); if (ret != 0) { amp_warn(MOD_STR, "kv get storage failed"); aos_free(value); goto out; } duk_push_lstring(ctx, value, value_len); aos_free(value); return 1; out: duk_push_undefined(ctx); return 1; } /***************************************************************************** * Function: native_fs_delete * Description: js native addon for FILE.delete(filepath) * delete the file * Called by: js api * Input: filepath : string * Output: 0 delete ok ;other delete fail *****************************************************************************/ static duk_ret_t native_kv_removeStorage(duk_context *ctx) { int32_t ret = -1; int32_t value_len = 0; const char *key; char *value; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } key = duk_get_string(ctx, 0); ret = aos_kv_del(key); if (ret != 0) { amp_warn(MOD_STR, "kv delete item failed"); goto out; } out: duk_push_int(ctx, ret); return 1; } void module_kv_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("setStorageSync", native_kv_setStorage, 2); AMP_ADD_FUNCTION("getStorageSync", native_kv_getStorage, 1); AMP_ADD_FUNCTION("removeStorageSync", native_kv_removeStorage, 1); duk_put_prop_string(ctx, -2, "KV"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/kv/module_kv.c
C
apache-2.0
3,553
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include "amp_config.h" #include "amp_defines.h" #include "aos_system.h" #include "be_inl.h" #define MOD_STR "LOG" #define SCRIPT "JSLOG" #define LOG_LEVEL_DEBUG "debug" #define LOG_LEVEL_INFO "info" #define LOG_LEVEL_WARN "warn" #define LOG_LEVEL_ERROR "error" #define LOG_LEVEL_FATAL "fatal" #define LOG_LEVEL_NONE "none" static int native_get_log_level(const char *pclevel, aos_log_level_t *paos_log_level) { if (NULL == pclevel || NULL == paos_log_level) { amp_error(MOD_STR, "invalid input\n"); return -1; } if (strncmp(pclevel, LOG_LEVEL_DEBUG, strlen(LOG_LEVEL_DEBUG)) == 0) { *paos_log_level = AOS_LL_DEBUG; } else if (strncmp(pclevel, LOG_LEVEL_INFO, strlen(LOG_LEVEL_INFO)) == 0) { *paos_log_level = AOS_LL_INFO; } else if (strncmp(pclevel, LOG_LEVEL_WARN, strlen(LOG_LEVEL_WARN)) == 0) { *paos_log_level = AOS_LL_WARN; } else if (strncmp(pclevel, LOG_LEVEL_ERROR, strlen(LOG_LEVEL_ERROR)) == 0) { *paos_log_level = AOS_LL_ERROR; } else if (strncmp(pclevel, LOG_LEVEL_FATAL, strlen(LOG_LEVEL_FATAL)) == 0) { *paos_log_level = AOS_LL_FATAL; } else if (strncmp(pclevel, LOG_LEVEL_NONE, strlen(LOG_LEVEL_NONE)) == 0) { *paos_log_level = AOS_LL_NONE; } else { amp_error(MOD_STR, "invalid log level %s", pclevel); return -1; } return 0; } static duk_ret_t native_set_stdlog_level(duk_context *ctx) { int ret = 0; aos_log_level_t log_level; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } const char *pclevel = duk_get_string(ctx, 0); if (NULL == pclevel) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } ret = native_get_log_level(pclevel, &log_level); if (ret) { amp_warn(MOD_STR, "invalid loglevel %s\n", pclevel); return -1; } ret = aos_set_log_level(log_level); return ret; } static duk_ret_t native_set_popcloud_log_level(duk_context *ctx) { int ret = 0; aos_log_level_t log_level; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } const char *pclevel = duk_get_string(ctx, 0); if (NULL == pclevel) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } ret = native_get_log_level(pclevel, &log_level); if (ret) { amp_warn(MOD_STR, "invalid log level %s\n", pclevel); return -1; } ret = aos_set_popcloud_log_level(log_level); return ret; } static duk_ret_t native_set_popfs_log_level(duk_context *ctx) { int ret = 0; aos_log_level_t log_level; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } const char *pclevel = duk_get_string(ctx, 0); if (NULL == pclevel) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } ret = native_get_log_level(pclevel, &log_level); if (ret) { amp_warn(MOD_STR, "invalid loglevel %s\n", pclevel); return -1; } ret = aos_set_popfs_log_level(log_level); return ret; } static duk_ret_t native_set_log_file_path(duk_context *ctx) { int ret = 0; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } const char *path = duk_get_string(ctx, 0); if (NULL == path) { amp_warn(MOD_STR, "invalid parameter\n"); return -1; } ret = ulog_fs_log_file_path(path); if (ret) { amp_warn(MOD_STR, "fail to set log file path %s\n", path); return -1; } return 0; } static duk_ret_t native_set_log_file_size(duk_context *ctx) { int ret = -1; unsigned int filesize = 0; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "parameter must be [number]\n"); return -1; } filesize = duk_get_number(ctx, 0); /*TODO : limit the biggist file size*/ ret = ulog_fs_log_file_size(filesize); if (ret) { amp_warn(MOD_STR, "fail to set log file size %d\n", filesize); return -1; } return 0; } static const char *ulog_get_output_format_msg(duk_context *ctx) { duk_idx_t n = duk_get_top(ctx); duk_idx_t i; duk_get_global_string(ctx, "ulog"); duk_get_prop_string(ctx, -1, "format"); for (i = 0; i < n; i++) { if (duk_check_type_mask(ctx, i, DUK_TYPE_MASK_OBJECT)) { /* Slow path formatting. */ duk_dup(ctx, -1); /* console.format */ duk_dup(ctx, i); duk_call(ctx, 1); duk_replace(ctx, i); /* arg[i] = console.format(arg[i]); */ } } duk_pop_2(ctx); duk_push_string(ctx, ""); duk_insert(ctx, 0); duk_join(ctx, duk_get_top(ctx) - 1); return duk_safe_to_string(ctx, -1); } static duk_ret_t native_debug_log_out(duk_context *ctx) { const char *msg = ulog_get_output_format_msg(ctx); if (NULL == msg) { amp_error(MOD_STR, "ulog fail to get output format msg"); return -1; } ulog(AOS_LL_DEBUG, SCRIPT, NULL, 0, msg); return 0; } static duk_ret_t native_info_log_out(duk_context *ctx) { const char *msg = ulog_get_output_format_msg(ctx); if (NULL == msg) { amp_error(MOD_STR, "ulog fail to get output format msg"); return -1; } ulog(AOS_LL_INFO, SCRIPT, NULL, 0, msg); return 0; } static duk_ret_t native_warn_log_out(duk_context *ctx) { const char *msg = ulog_get_output_format_msg(ctx); if (NULL == msg) { amp_error(MOD_STR, "ulog fail to get output format msg"); return -1; } ulog(AOS_LL_WARN, SCRIPT, NULL, 0, msg); return 0; } static duk_ret_t native_error_log_out(duk_context *ctx) { const char *msg = ulog_get_output_format_msg(ctx); if (NULL == msg) { amp_error(MOD_STR, "ulog fail to get output format msg"); return -1; } ulog(AOS_LL_ERROR, SCRIPT, NULL, 0, msg); return 0; } static duk_ret_t native_fatal_log_out(duk_context *ctx) { const char *msg = ulog_get_output_format_msg(ctx); if (NULL == msg) { amp_error(MOD_STR, "ulog fail to get output format msg"); return -1; } ulog(AOS_LL_FATAL, SCRIPT, NULL, 0, msg); return 0; } void module_log_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); /*copy from console.log don't why*/ duk_eval_string(ctx, "(function (E) {" "return function format(v){" "try{" "return E('jx',v);" "}catch(e){" "return String(v);" /* String() allows symbols, ToString() internal algorithm doesn't. */ "}" "};" "})(Duktape.enc)"); duk_put_prop_string(ctx, -2, "format"); AMP_ADD_FUNCTION("debug", native_debug_log_out, DUK_VARARGS); AMP_ADD_FUNCTION("info", native_info_log_out, DUK_VARARGS); AMP_ADD_FUNCTION("warn", native_warn_log_out, DUK_VARARGS); AMP_ADD_FUNCTION("error", native_error_log_out, DUK_VARARGS); AMP_ADD_FUNCTION("fatal", native_fatal_log_out, DUK_VARARGS); AMP_ADD_FUNCTION("stdloglevel", native_set_stdlog_level, 1); AMP_ADD_FUNCTION("cloudloglevel", native_set_popcloud_log_level, 1); AMP_ADD_FUNCTION("fsloglevel", native_set_popfs_log_level, 1); AMP_ADD_FUNCTION("setlogfilepath", native_set_log_file_path, 1); AMP_ADD_FUNCTION("setlogfilesize", native_set_log_file_size, 1); duk_put_global_string(ctx, "ulog"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/log/module_log.c
C
apache-2.0
7,728
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_system.h" #include "be_inl.h" #define MOD_STR "Battery" static duk_ret_t native_battery_conn_state_get(duk_context *ctx) { int ret = -1; int state; if (aos_battery_connect_state_get(&state)) { amp_error(MOD_STR, "get battery connect state fail"); goto out; } ret = state; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_battery_voltage_get(duk_context *ctx) { int ret = -1; int voltage; if (aos_battery_voltage_get(&voltage)) { amp_error(MOD_STR, "get battery voltage fail"); goto out; } ret = voltage; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_battery_level_get(duk_context *ctx) { int ret = -1; int level; if (aos_battery_level_get(&level)) { amp_error(MOD_STR, "get battery level fail"); goto out; } ret = level; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_battery_temperature_get(duk_context *ctx) { int ret = -1; int temperature; if (aos_battery_temperature_get(&temperature)) { amp_error(MOD_STR, "get battery temperature fail"); goto out; } ret = temperature; out: duk_push_int(ctx, ret); return 1; } void module_battery_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("getConnectState", native_battery_conn_state_get, 0); AMP_ADD_FUNCTION("getVoltage", native_battery_voltage_get, 0); AMP_ADD_FUNCTION("getLevel", native_battery_level_get, 0); AMP_ADD_FUNCTION("getTemperature", native_battery_temperature_get, 0); duk_put_prop_string(ctx, -2, "Battery"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/pm/module_battery.c
C
apache-2.0
1,863
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_system.h" #include "aos_pm.h" #include "be_inl.h" #define MOD_STR "Charger" static duk_ret_t native_charger_conn_state_get(duk_context *ctx) { int ret = -1; int state; if (aos_charger_connect_state_get(&state)) { amp_error(MOD_STR, "get charger connection state fail"); goto out; } ret = state; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_charger_state_get(duk_context *ctx) { int ret = -1; aos_charger_state_t state = AOS_CHARGER_STAT_SHUTDOWN; if (aos_charger_state_get(&state)) { amp_error(MOD_STR, "get charger connection state fail"); goto out; } ret = state; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_charger_current_get(duk_context *ctx) { int ret = -1; int current; if (aos_charger_current_get(&current)) { amp_error(MOD_STR, "get charger current fail"); goto out; } ret = current; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_charger_switch_set(duk_context *ctx) { int ret = -1; int val; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } val = duk_get_int(ctx, 0); if (val < 0) { amp_error(MOD_STR, "parameter %d invalid", val); goto out; } if (aos_charger_switch_set(val)) { amp_error(MOD_STR, "set charger switch fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_charger_connect_on(duk_context *ctx) { int ret = -1; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } void module_charger_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("getConnectState", native_charger_conn_state_get, 0); AMP_ADD_FUNCTION("getState", native_charger_state_get, 0); AMP_ADD_FUNCTION("getCurrent", native_charger_current_get, 0); AMP_ADD_FUNCTION("switch", native_charger_switch_set, 1); AMP_ADD_FUNCTION("onConnect", native_charger_connect_on, 1); duk_put_prop_string(ctx, -2, "Charger"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/pm/module_charger.c
C
apache-2.0
2,487
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_system.h" #include "be_inl.h" #define MOD_STR "PM" enum { PM_AUTOSLEEP_MODE_NEVER = 0, PM_AUTOSLEEP_MODE_SLEEP, PM_AUTOSLEEP_MODE_DEEP_SLEEP, }; static void *pm_wakelock; static int pm_autosleep_mode; static int pm_sleep_mode; static int pm_pwrkey_cb_ref; static void __pm_pwrkey_state_notify(void *args) { duk_context *ctx; int state = (int)args; ctx = be_get_context(); be_push_ref(ctx, pm_pwrkey_cb_ref); duk_push_int(ctx, state); if (duk_pcall(ctx, 1) != DUK_EXEC_SUCCESS) { amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); duk_gc(ctx, 0); } static void __pm_pwrkey_state_cb(int state) { duk_context *ctx; amp_task_schedule_call(__pm_pwrkey_state_notify, state); } static duk_ret_t native_pm_autosleep_mode_get(duk_context *ctx) { duk_push_int(ctx, pm_autosleep_mode); return 1; } static duk_ret_t native_pm_autosleep_mode_set(duk_context *ctx) { int ret = -1; int mode; if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter not number"); goto out; } mode = duk_get_int(ctx, 0); if (aos_system_autosleep(mode) < 0) { amp_error(MOD_STR, "set autosleep mode %d fail", mode); goto out; } pm_autosleep_mode = mode; ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pm_sleep(duk_context *ctx) { int ret = -1; if (aos_system_sleep()) { amp_error(MOD_STR, "pm suspend fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pm_wakelock_lock(duk_context *ctx) { int ret = -1; void *w = pm_wakelock; if (!w) { goto out; } if (aos_wakelock_lock(w) < 0) { amp_error(MOD_STR, "wakelock lock fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pm_wakelock_timedlock(duk_context *ctx) { int ret = -1; void *w = pm_wakelock; int msec; if (!w) { goto out; } if (!duk_is_number(ctx, 0)) { amp_error(MOD_STR, "parameter must be (number)"); goto out; } msec = duk_get_uint(ctx, 0); if (aos_wakelock_timedlock(w, msec) < 0) { amp_error(MOD_STR, "wakelock timedlock fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pm_wakelock_unlock(duk_context *ctx) { int ret = -1; void *w = pm_wakelock; if (!w) { goto out; } if (aos_wakelock_unlock(w) < 0) { amp_error(MOD_STR, "wakelock unlock fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pm_pwrkey_on(duk_context *ctx) { int ret = -1; if (!duk_is_function(ctx, 0)) { amp_warn(MOD_STR, "parameter must be (function)"); goto out; } duk_dup(ctx, 0); pm_pwrkey_cb_ref = be_ref(ctx); if (aos_pwrkey_notify_register(__pm_pwrkey_state_cb)) { amp_error(MOD_STR, "register event fail"); goto out; } ret = 0; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_pm_power_down(duk_context *ctx) { duk_push_int(ctx, 0); aos_power_down(); return 1; } static duk_ret_t native_pm_power_reset(duk_context *ctx) { aos_power_reset(); duk_push_int(ctx, 0); return 1; } void module_pm_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); pm_wakelock = aos_wakelock_create("PM.wakelock"); if (!pm_wakelock) { amp_debug(MOD_STR, "wakelock unsupport"); } pm_autosleep_mode = PM_AUTOSLEEP_MODE_NEVER; AMP_ADD_FUNCTION("setAutosleepMode", native_pm_autosleep_mode_set, 1); AMP_ADD_FUNCTION("getAutosleepMode", native_pm_autosleep_mode_get, 0); AMP_ADD_FUNCTION("sleep", native_pm_sleep, 0); AMP_ADD_FUNCTION("powerDown", native_pm_power_down, 0); AMP_ADD_FUNCTION("powerReset", native_pm_power_reset, 0); AMP_ADD_FUNCTION("wakelockLock", native_pm_wakelock_lock, 0); AMP_ADD_FUNCTION("wakelockUnlock", native_pm_wakelock_unlock, 0); AMP_ADD_FUNCTION("wakelockTimedlock", native_pm_wakelock_timedlock, 1); AMP_ADD_FUNCTION("onPwrkey", native_pm_pwrkey_on, 1); duk_put_prop_string(ctx, -2, "PM"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/pm/module_pm.c
C
apache-2.0
4,570
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "be_inl.h" #include "amp_utils.h" #define MOD_STR "SYSTEM" extern const char *amp_jsapp_version_get(void); static duk_ret_t native_module_versions(duk_context *ctx) { duk_push_object(ctx); duk_push_string(ctx, aos_get_system_version()); duk_put_prop_string(ctx, -2, "module"); return 1; } static duk_ret_t native_system_version(duk_context *ctx) { char version[AMP_VERSION_LENGTH] = {0}; amp_version_get(version); duk_push_string(ctx, version); return 1; } static duk_ret_t native_system_app_version(duk_context *ctx) { const char *version = amp_jsapp_version_get(); if (strlen(version) == 0) version = "null"; duk_push_string(ctx, version); return 1; } static duk_ret_t native_system_platform(duk_context *ctx) { duk_push_string(ctx, aos_get_platform_type()); return 1; } static duk_ret_t native_system_uptime(duk_context *ctx) { duk_push_number(ctx, aos_now_ms()); return 1; } static duk_ret_t native_system_memory(duk_context *ctx) { int32_t ret = -1; amp_heap_info_t heap_info; ret = amp_heap_memory_info(&heap_info); if (ret != 0) { amp_warn(MOD_STR, "get heap memory failed"); goto out; } duk_push_object(ctx); duk_push_number(ctx, heap_info.heap_total); duk_put_prop_string(ctx, -2, "heapTotal"); duk_push_number(ctx, heap_info.heap_used); duk_put_prop_string(ctx, -2, "heapUsed"); duk_push_number(ctx, heap_info.heap_free); duk_put_prop_string(ctx, -2, "heapFree"); return 1; out: duk_push_int(ctx, ret); return 1; } static duk_ret_t native_system_gc(duk_context *ctx) { int32_t ret = -1; duk_gc(ctx, 0); duk_gc(ctx, 0); duk_push_true(ctx); return 1; } void module_system_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); AMP_ADD_FUNCTION("versions", native_module_versions, 0); AMP_ADD_FUNCTION("version", native_system_version, 0); AMP_ADD_FUNCTION("appversion", native_system_app_version, 0); AMP_ADD_FUNCTION("platform", native_system_platform, 0); AMP_ADD_FUNCTION("uptime", native_system_uptime, 0); AMP_ADD_FUNCTION("memory", native_system_memory, 0); AMP_ADD_FUNCTION("gc", native_system_gc, 0); duk_put_global_string(ctx, "system"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/system/module_system.c
C
apache-2.0
2,532
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <string.h> #include "amp_config.h" #include "amp_defines.h" #include "aos_system.h" #include "amp_task.h" #include "board_mgr.h" #include "be_inl.h" #include "amp_task.h" #include "amp_list.h" #define MOD_STR "TIMER" #define MAGIC 0x55ff0055 typedef struct timer_wrap { int magic; int js_cb_ref; int repeat; aos_timer_t *timer_id; } timer_wrap_t; typedef struct { aos_timer_t *timer_id; dlist_t node; } timer_link_t; static dlist_t g_systimer_list = AMP_DLIST_HEAD_INIT(g_systimer_list); static void clear_timer(timer_wrap_t *t); static void timer_action(void *arg) { timer_wrap_t *t = (timer_wrap_t *)arg; /* Is the timer has been cleared? */ if (t->magic != MAGIC) { // amp_error(MOD_STR, "Timer has been cleared"); return; } duk_context *ctx = be_get_context(); be_push_ref(ctx, t->js_cb_ref); if (duk_pcall(ctx, 0) != DUK_EXEC_SUCCESS) { // amp_console("%s", duk_safe_to_string(ctx, -1)); amp_console("%s", duk_safe_to_stacktrace(ctx, -1)); } duk_pop(ctx); if (!t->repeat) { be_unref(ctx, t->js_cb_ref); clear_timer(t); } duk_gc(ctx, 0); } static timer_wrap_t *setup_timer(int js_cb_ref, long ms, int repeat) { timer_link_t *timer_link; timer_wrap_t *t = (timer_wrap_t *)aos_malloc(sizeof(*t)); t->magic = MAGIC; t->js_cb_ref = js_cb_ref; t->repeat = repeat; t->timer_id = amp_task_timer_action(ms, timer_action, t, repeat); if (t->timer_id) { timer_link = aos_malloc(sizeof(timer_link_t)); if (timer_link) { timer_link->timer_id = t->timer_id; dlist_add_tail(&timer_link->node, &g_systimer_list); } } return t; } static void cancel_timer(void *timerid) { timer_link_t *timer_node; if (!timerid) { return; } dlist_for_each_entry(&g_systimer_list, timer_node, timer_link_t, node) { if (timer_node->timer_id == timerid) { aos_timer_stop((aos_timer_t *)timerid); aos_timer_free((aos_timer_t *)timerid); aos_free((void *)timerid); dlist_del(&timer_node->node); aos_free(timer_node); break; } } } static void clear_timer(timer_wrap_t *t) { if (!t) { amp_warn(MOD_STR, "timer wrap handle is null"); return; } if (t->magic != MAGIC) { amp_warn(MOD_STR, "timer wrap handle has be cleared"); return; } cancel_timer(t->timer_id); duk_context *ctx = be_get_context(); be_unref(ctx, t->js_cb_ref); t->magic = 0; aos_free(t); } static duk_ret_t native_setTimeout(duk_context *ctx) { if (!(duk_is_function(ctx, 0) && duk_is_number(ctx, 1))) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "setTimeout parameters must be function and number"); return duk_throw(ctx); } duk_dup(ctx, 0); int js_cb_ref = be_ref(ctx); long ms = (long)duk_get_number(ctx, 1); timer_wrap_t *t = setup_timer(js_cb_ref, ms, 0); duk_push_pointer(ctx, t); return 1; } static duk_ret_t native_clearTimeout(duk_context *ctx) { timer_wrap_t *t = (timer_wrap_t *)duk_get_pointer(ctx, 0); clear_timer(t); return 0; } static duk_ret_t native_setInterval(duk_context *ctx) { if (!(duk_is_function(ctx, 0) && duk_is_number(ctx, 1))) { amp_warn(MOD_STR, "invalid parameters"); duk_push_string(ctx, "setInterval parameters must be function and number"); return duk_throw(ctx); } amp_debug(MOD_STR, "native_setInterval"); duk_dup(ctx, 0); int js_cb_ref = be_ref(ctx); long ms = (long)duk_get_number(ctx, 1); timer_wrap_t *t = setup_timer(js_cb_ref, ms, 1); duk_push_pointer(ctx, t); return 1; } static duk_ret_t native_clearInterval(duk_context *ctx) { timer_wrap_t *t = (timer_wrap_t *)duk_get_pointer(ctx, 0); clear_timer(t); return 0; } static duk_ret_t native_sleepMs(duk_context *ctx) { int32_t ret = -1; uint32_t ms = 0; if (!duk_is_number(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto out; } ms = duk_get_int(ctx, 0); amp_debug(MOD_STR, "system delay %d ms", ms); aos_msleep(ms); duk_push_int(ctx, 0); return 1; out: duk_push_int(ctx, -1); return 1; } static void module_systimer_source_clean(void) { dlist_t *temp; timer_link_t *timer_node; dlist_for_each_entry_safe(&g_systimer_list, temp, timer_node, timer_link_t, node) { aos_timer_stop((aos_timer_t *)timer_node->timer_id); aos_timer_free((aos_timer_t *)timer_node->timer_id); aos_free((void *)timer_node->timer_id); dlist_del(&timer_node->node); aos_free(timer_node); } } void module_systimer_register(void) { amp_debug(MOD_STR, "module_timer_register"); duk_context *ctx = be_get_context(); amp_module_free_register(module_systimer_source_clean); AMP_ADD_GLOBAL_FUNCTION("setTimeout", native_setTimeout, 2); AMP_ADD_GLOBAL_FUNCTION("clearTimeout", native_clearTimeout, 1); AMP_ADD_GLOBAL_FUNCTION("setInterval", native_setInterval, 2); AMP_ADD_GLOBAL_FUNCTION("clearInterval", native_clearInterval, 1); AMP_ADD_GLOBAL_FUNCTION("sleepMs", native_sleepMs, 1); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/systimer/module_systimer.c
C
apache-2.0
5,506
#include "model_bind.h" #define MODEL_BUFF_LEN 256 #define MODEL_STR_HEAD "var model = require('model'); model.setData({" #define MODEL_STR_DELIMITER ":" #define MODEL_STR_TAIL "});" static model_bind_proc_t g_model_bind_proc = {0}; vm_msg_type_e g_msg_type = msg_invalid; int model_data_bind_init(MODEL_DATA_SEND_TO_VM_F send) { if (send == NULL) { amp_error(UI_MOD_STR, "data bind cb is null"); return -1; } g_model_bind_proc.send = send; g_model_bind_proc.flag = true; return 0; } int model_data_bind_deinit(void) { memset(&g_model_bind_proc, 0, sizeof(g_model_bind_proc)); return 0; } int model_data_send_to_vm(vm_msg_t *msg, int len) { if (msg == NULL) { amp_error(UI_MOD_STR, "msg is null"); return -1; } if (len == 0) { amp_error(UI_MOD_STR, "len is %d", len); return -1; } if (g_model_bind_proc.flag != true) { amp_error(UI_MOD_STR, "model bind proc is uninited"); return -1; } if (g_model_bind_proc.send == NULL) { amp_error(UI_MOD_STR, "model bind send cb is null"); return -1; } return g_model_bind_proc.send(msg, len); } duk_ret_t native_model_setdata(duk_context *ctx) { vm_data_type_t data; vm_msg_t msg; int arr_idx = 0; int len = 0; int i, j; model_array_t *array; widget_desc_t* widget = NULL; page_desc_t *page; if (!duk_is_object(ctx, 0)) { amp_error(UI_MOD_STR, "ctx is invalid, %d", ctx); goto done; } duk_enum(ctx, 0 ,0); page = &g_app.page[g_app.cur_page]; if (page == NULL) { goto done; } while (duk_next(ctx, -1, 1)) { if (!duk_is_string(ctx, -2)) { amp_error(UI_MOD_STR, "para name is not string"); duk_pop_2(ctx); continue; } msg.type = msg_model_to_vm; memset(&data, 0, sizeof(data)); if (duk_is_string(ctx, -1)) { data.val_str = duk_safe_to_string(ctx, -1); data.type = vm_data_str; amp_debug(UI_MOD_STR, "para name: %s, str para: %s", duk_safe_to_string(ctx, -2), duk_safe_to_string(ctx, -1)); } else if (duk_is_boolean(ctx, -1)) { data.val_bool = duk_to_boolean(ctx, -1); data.type = vm_data_bool; amp_debug(UI_MOD_STR, "para name: %s, bool para: %d", duk_safe_to_string(ctx, -2), duk_to_boolean(ctx, -1)); } else if (duk_is_number(ctx, -1)) { data.val_double = duk_to_number(ctx, -1); data.type = vm_data_double; amp_debug(UI_MOD_STR, "para name: %s, float para: %f", duk_safe_to_string(ctx, -2), duk_to_boolean(ctx, -1)); } else if (duk_is_array(ctx, -1)) { arr_idx = duk_normalize_index(ctx, -1); len = duk_get_length(ctx, arr_idx); for (i = 0; i < page->total_num; i++) { if(page->widgets[i] == NULL) { continue; } if (page->widgets[i]->array_parent != list_parent) { continue; } if (page->widgets[i]->array == NULL) { continue; } if (widget_str_equal(page->widgets[i]->array->name, duk_safe_to_string(ctx, -2))) { array = page->widgets[i]->array; widget = page->widgets[i]; break; } } if (i == page->total_num) { continue; } for(j = 0; j < array->ele_num; j++) { array->array_len = duk_get_length(ctx, arr_idx); array->element[j].data = aos_malloc(sizeof(vm_data_type_t) * array->array_len); if (array->element[j].data == NULL) { amp_error(UI_MOD_STR, "array->element->data aos_malloc fail,array->array_len = %d", array->array_len); amp_error(UI_MOD_STR, "array->element->data aos_malloc fail,size = %d", sizeof(vm_data_type_t) * array->array_len); goto done; } } for (i = 0; i < len; i++) { duk_get_prop_index(ctx, arr_idx, i); if (!duk_is_object(ctx, -1)) { amp_warn(UI_MOD_STR, "data is not number, index: %d", i); duk_pop(ctx); } else { amp_warn(UI_MOD_STR, "object, index: %d", i); } for (j = 0; j < array->ele_num; j++) { duk_get_prop_string(ctx, -1, array->element[j].name); amp_warn(UI_MOD_STR, "array->element[%d].data[%d].val_str: %s",j, i, duk_safe_to_string(ctx, -1)); if (duk_is_string(ctx, -1)) { array->element[j].data[i].val_str = duk_safe_to_string(ctx, -1); array->element[j].data[i].type = vm_data_str; amp_warn(UI_MOD_STR, "data is not number, array->element[%d].data[%d].val_str: %s",j, i, array->element[j].data[i].val_str); } else if (duk_is_number(ctx, -1)) { array->element[j].data[i].val_double = duk_to_number(ctx, -1); array->element[j].data[i].type = vm_data_double; } duk_pop(ctx); } } msg.type = msg_list_to_vm; //data.type = vm_data_pointer; msg.payload.widget = widget; } else { continue; } msg.payload.name = duk_safe_to_string(ctx, -2); memcpy(&msg.payload.data, &data, sizeof(data)); model_data_send_to_vm(&msg, sizeof(msg)); if (msg_invalid == g_msg_type) { msg.type = msg_on_load_ret; model_data_send_to_vm(&msg, sizeof(msg)); g_msg_type = msg_on_load_ret; } duk_pop_2(ctx); } amp_debug(UI_MOD_STR, "native_model_setdata success"); done: return 1; } int model_eval_str(char *name, vm_data_type_t* data) { duk_context *ctx = NULL; char buffer[MODEL_BUFF_LEN]; if (name == NULL) { amp_error(UI_MOD_STR, "name is null"); return -1; } if (data == NULL) { amp_error(UI_MOD_STR, "name is null"); return -1; } ctx = be_get_context(); switch(data->type) { case vm_data_uint: memset(buffer, 0, sizeof(buffer)); snprintf(buffer, MODEL_BUFF_LEN - 1, "%s%s%s%u%s", MODEL_STR_HEAD, name, MODEL_STR_DELIMITER, data->val_uint, MODEL_STR_TAIL); duk_eval_string(ctx, buffer); amp_debug(UI_MOD_STR, "name: %s, code: %f", name, buffer); break; case vm_data_int: memset(buffer, 0, sizeof(buffer)); snprintf(buffer, MODEL_BUFF_LEN - 1, "%s%s%s%d%s", MODEL_STR_HEAD, name, MODEL_STR_DELIMITER, data->val_int, MODEL_STR_TAIL); duk_eval_string(ctx, buffer); amp_debug(UI_MOD_STR, "name: %s, code: %f", name, buffer); break; case vm_data_double: memset(buffer, 0, sizeof(buffer)); snprintf(buffer, MODEL_BUFF_LEN - 1, "%s%s%s%f%s", MODEL_STR_HEAD, name, MODEL_STR_DELIMITER, data->val_double, MODEL_STR_TAIL); duk_eval_string(ctx, buffer); amp_debug(UI_MOD_STR, "name: %s, code: %f", name, buffer); break; case vm_data_str: memset(buffer, 0, sizeof(buffer)); snprintf(buffer, MODEL_BUFF_LEN - 1, "%s%s%s%s%s", MODEL_STR_HEAD, name, MODEL_STR_DELIMITER, data->val_str, MODEL_STR_TAIL); duk_eval_string(ctx, buffer); amp_debug(UI_MOD_STR, "name: %s, code: %f", name, buffer); break; case vm_data_bool: memset(buffer, 0, sizeof(buffer)); snprintf(buffer, MODEL_BUFF_LEN - 1, "%s%s%s%s%s", MODEL_STR_HEAD, name, MODEL_STR_DELIMITER, data->val_bool == 0 ? "false" : "true", MODEL_STR_TAIL); duk_eval_string(ctx, buffer); amp_debug(UI_MOD_STR, "name: %s, code: %f", name, buffer); break; default : break; } return 0; }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/ui/model_bind.c
C
apache-2.0
8,403
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "aos_network.h" #include "amp_defines.h" #include "aos_network.h" #include "amp_task.h" #include "be_inl.h" #define MOD_STR "UI" char g_app_path[128]; extern void amp_page_changed_set(void); duk_ret_t native_ui_redirect(duk_context *ctx) { char *path; if (!duk_is_string(ctx, 0)) { amp_warn(MOD_STR, "invalid parameter\n"); goto done; } path = duk_get_string(ctx, 0); if (path != NULL) { memset(&g_app_path[0], 0, sizeof(g_app_path)); snprintf(&g_app_path[0],128,"%s",path); amp_debug(MOD_STR, "native_ui_redirect path is %s\n", path); amp_page_changed_set(); } amp_debug(MOD_STR, "native_ui_redirect success"); done: return 1; } void module_ui_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); duk_push_c_function(ctx, native_ui_redirect, 1); duk_put_prop_string(ctx, -2, "redirectTo"); duk_put_prop_string(ctx, -2, "UI"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/ui/module_ui.c
C
apache-2.0
1,164
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include "amp_config.h" #include "aos_system.h" #include "aos_network.h" #include "amp_defines.h" #include "aos_network.h" #include "amp_task.h" #include "be_inl.h" #define MOD_STR "MODEL" duk_ret_t native_model_setdata(duk_context *ctx); void module_vm_register(void) { duk_context *ctx = be_get_context(); duk_push_object(ctx); duk_push_c_function(ctx, native_model_setdata, 1); duk_put_prop_string(ctx, -2, "setData"); duk_put_prop_string(ctx, -2, "VM"); }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/utils/ui/module_vm.c
C
apache-2.0
630
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <aos/errno.h> #include <aos/kernel.h> #include "aos/init.h" #include "board.h" #include <k_api.h> #include <aos/ble.h> #include <bluetooth/bluetooth.h> #include <bluetooth/conn.h> #include <atomic.h> #include <work.h> #include <aos/gatt.h> #include <bluetooth/gatt.h> #include <bluetooth/uuid.h> #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "be_inl.h" #include "aiot_state_api.h" #include "bt_host_adapter.h" #define MOD_STR "BT_GATTS_ADAPTER" size_t g_attr_num = 0; gatt_attr_t *g_attrs_list = NULL; int bt_gatts_adapter_update_user_data(size_t index, uint16_t uuid, uint8_t *data, size_t len); uint16_t get_16bits_hex_from_string(const char *str) { uint16_t ret = 0, tmp = 0, ii = 0, jj = 0; uint32_t sample_len = strlen("0xAABB"); uint8_t seed[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; if (strlen(str) == sample_len) { if (strncmp(str, "0x", 2) && strncmp(str, "0X", 2)) { } else { for (ii = sample_len-1; ii >= sample_len-4; ii--) { // to uppercase if (str[ii] >= 'a') { tmp = str[ii] - ('a'-'A'); } else { tmp = str[ii]; } // char to number for (jj=0; jj<sizeof(seed); jj++) { if (seed[jj] == tmp) { break; } } ret += jj<<((sample_len-1-ii)*4); } } } // amp_debug(MOD_STR, "[%s] %s -> 0x%X", __func__, str, ret); return ret; } gatt_perm_en get_attr_perm_from_string(char *str) { gatt_perm_en ret = GATT_PERM_NONE; if (strstr(str, "R")) { ret |= GATT_PERM_READ; } if (strstr(str, "W")) { ret |= GATT_PERM_WRITE; } return ret; } gatt_prop_en get_char_perm_from_string(char *str) { gatt_prop_en ret = 0; if (strstr(str, "R")) { ret |= GATT_CHRC_PROP_READ; } if (strstr(str, "W")) { ret |= GATT_CHRC_PROP_WRITE; } return ret; } static gatt_service srvc_instance = {0}; uuid_t *bt_gatts_declare_16bits_uuid(uint16_t val) { struct ut_uuid_16 *uuid = (struct ut_uuid_16 *)malloc(sizeof(struct ut_uuid_16)); uuid->uuid.type = UUID_TYPE_16; uuid->val = val; return (uuid_t *)uuid; } void bt_gatts_define_gatt_srvc(gatt_attr_t *out, uint16_t uuid) { amp_debug(MOD_STR, "[%s] declare service uuid 0x%04x", __func__, uuid); out->uuid = bt_gatts_declare_16bits_uuid(0x2800); // UUID_GATT_PRIMARY; out->perm = GATT_PERM_READ; out->read = out->write = NULL; out->user_data = (void *)uuid; } void bt_gatts_define_gatt_char(gatt_attr_t *out, uint16_t uuid, uint8_t perimt) { amp_debug(MOD_STR, "[%s] declare char uuid 0x%04x", __func__, uuid); struct gatt_char_t *data = (struct gatt_char_t *)malloc(sizeof(struct gatt_char_t)); memset(data, 0, sizeof(struct gatt_char_t)); data->uuid= bt_gatts_declare_16bits_uuid(uuid); data->value_handle = 0; data->properties = perimt, out->uuid = bt_gatts_declare_16bits_uuid(0x2803); //UUID_GATT_CHRC; out->perm = GATT_PERM_READ; out->read = out->write = NULL; out->user_data = (void *)data; } void bt_gatts_define_gatt_char_val(gatt_attr_t *out, uint16_t uuid, uint8_t perimt) { amp_debug(MOD_STR, "[%s] declare char val uuid 0x%04x", __func__, uuid); out->uuid = bt_gatts_declare_16bits_uuid(uuid); out->perm = perimt; out->read = out->write = NULL; out->user_data = NULL; } void bt_gatts_define_ccc(gatt_attr_t *out) { amp_debug(MOD_STR, "[%s] declare ccc ...", __func__); struct bt_gatt_ccc_t *ccc = (struct bt_gatt_ccc_t *)malloc(sizeof(struct bt_gatt_ccc_t)); memset(ccc, 0, sizeof(struct bt_gatt_ccc_t)); out->uuid = bt_gatts_declare_16bits_uuid(0x2902); //UUID_GATT_CCC; out->perm = GATT_PERM_READ|GATT_PERM_WRITE; out->read = out->write = NULL; out->user_data = (void *)ccc; } int bt_gatts_adapter_add_service(amp_bt_host_adapter_gatts_srvc_t *srvc) { int ret = 0; amp_bt_host_adapter_gatt_chars_t *char_list = NULL; if (srvc) { g_attrs_list = (gatt_attr_t *)aos_malloc(srvc->attr_cnt * sizeof(gatt_attr_t)); if (!g_attrs_list) { amp_error(MOD_STR, "[%s] memory not enough for g_attrs_list", __func__); return ret; } memset(g_attrs_list, 0, srvc->attr_cnt * sizeof(gatt_attr_t)); char_list = srvc->chars; // declare the service bt_gatts_define_gatt_srvc(&g_attrs_list[g_attr_num++], get_16bits_hex_from_string(srvc->s_uuid)); while(g_attr_num<srvc->attr_cnt) { if (char_list->descr_type) { if (0 == strcmp(char_list->descr_type, "CCC")) { bt_gatts_define_gatt_char(&g_attrs_list[g_attr_num++], get_16bits_hex_from_string(char_list->char_uuid), GATT_CHRC_PROP_NOTIFY | get_char_perm_from_string(char_list->permission)); bt_gatts_define_gatt_char_val(&g_attrs_list[g_attr_num++], get_16bits_hex_from_string(char_list->char_uuid), get_attr_perm_from_string(char_list->permission)); bt_gatts_define_ccc(&g_attrs_list[g_attr_num++]); char_list++; continue; } else { /* CUD, SCC, CPF, CAF*/ amp_warn(MOD_STR, "[%s] unsupported descr type: %s ", __func__, char_list->descr_type); } } bt_gatts_define_gatt_char(&g_attrs_list[g_attr_num++], get_16bits_hex_from_string(char_list->char_uuid), GATT_CHRC_PROP_NOTIFY | get_char_perm_from_string(char_list->permission)); bt_gatts_define_gatt_char_val(&g_attrs_list[g_attr_num++], get_16bits_hex_from_string(char_list->char_uuid), get_attr_perm_from_string(char_list->permission)); char_list++; } amp_debug(MOD_STR, "[%s] declare service done, total attr: %d(%d)", __func__, g_attr_num, srvc->attr_cnt); // >=0: handle, <0: error ret = ble_stack_gatt_registe_service(&srvc_instance, g_attrs_list, srvc->attr_cnt); amp_debug(MOD_STR, "[%s] add service done with ret %d", __func__, ret); } else { amp_error(MOD_STR, "[%s] srvc is null", __func__); } return ret; } int bt_gatts_adapter_update_user_data(size_t index, uint16_t uuid_val, uint8_t *data, size_t len) { int ret = -1; gatt_attr_t *ptr = NULL; if (index >=0 && index<g_attr_num) { ptr = &(g_attrs_list[index]); } else { for (int ii=0; ii<g_attr_num; ii++) { if (((struct ut_uuid_16 *)(g_attrs_list[ii].uuid))->val == uuid_val) { ptr = &(g_attrs_list[ii]); break; } } } if (ptr == NULL) { amp_error(MOD_STR, "[%s] give up updating as uuid not matched!!", __func__); return 0; } amp_bt_gatts_adapter_usr_data_t *old = ptr->user_data; amp_bt_gatts_adapter_usr_data_t **new = &(ptr->user_data); if (old) { if (old->data) { free(old->data); } else { amp_error(MOD_STR, "[%s] old is avaliable, but data is null. should NOT be here!!", __func__); } free(old); } *new = (amp_bt_gatts_adapter_usr_data_t *)malloc(sizeof(amp_bt_gatts_adapter_usr_data_t)); if (*new) { (*new)->len = len; (*new)->data = (uint8_t *)malloc(sizeof(uint8_t) * len); if ((*new)->data) { ret = 0; memcpy((*new)->data, data, len); amp_debug(MOD_STR, "[%s]update user data:%p -> %p", __func__, old, *new); } else { free(*new); amp_error(MOD_STR, "[%s][%d] memory not enough for new data!", __func__, __LINE__); } } else { amp_error(MOD_STR, "[%s][%d] memory not enough for new data!", __func__, __LINE__); } return ret; } int bt_gatts_adapter_update_chars(char *uuid, uint8_t *data, size_t len) { amp_bt_gatts_adapter_usr_data_t *old_data = NULL; uint32_t ii = bt_gatts_adapter_update_user_data(0, get_16bits_hex_from_string(uuid), data, len); if (ii==0) {return -1;} if(ii!=0 && (ii+1)<g_attr_num && g_attrs_list[ii+1].uuid == UUID_GATT_CCC) { uint16_t *conn_handle = NULL; struct bt_gatt_ccc_t *ccc = (struct bt_gatt_ccc_t *)g_attrs_list[ii+1].user_data; for (int jj=0; jj< ARRAY_SIZES(ccc->cfg); jj++) { conn_handle = (uint16_t *)bt_conn_lookup_addr_le(ccc->cfg->id, &ccc->cfg->peer); if (conn_handle) { if (ccc->cfg[0].value) { ble_stack_gatt_notificate(*conn_handle, g_attrs_list[ii].handle, data, len); } } } } return 0; } void bt_gatts_dump_hex(uint8_t data[], size_t len) { printf("\t\tDUMP START: "); for (int ii=0; ii<len; ii++) { printf("%02x ", data[ii]); } printf("\n"); } int bt_gatts_adapter_event_callback(ble_event_en event, void *event_data) { switch (event) { case EVENT_GATT_CHAR_READ: { evt_data_gatt_char_read_t *read_data = (evt_data_gatt_char_read_t *)event_data; for (int ii=0; ii<g_attr_num; ii++) { if (g_attrs_list[ii].handle == read_data->char_handle) { printf("[%s]read request at handle.%d, uuid:0x%04x, offset:%d\n", __func__, read_data->char_handle , ((struct ut_uuid_16 *)(g_attrs_list[ii].uuid))->val , read_data->offset); amp_bt_gatts_adapter_usr_data_t *data = g_attrs_list[ii].user_data; if (data) { if (data->data && data->len) { bt_gatts_dump_hex(data->data, data->len); read_data->data = data->data; //memcpy(read_data->data, data->data, data->len); read_data->len = data->len; break; } } amp_error(MOD_STR, "[%s][%d] no data to be read!", __func__, __LINE__); } } } break; case EVENT_GATT_CHAR_WRITE: { evt_data_gatt_char_write_t *write_data = (evt_data_gatt_char_write_t *)event_data; for (int ii=0; ii<g_attr_num; ii++) { if (g_attrs_list[ii].handle == write_data->char_handle) { printf("[%s]read request at handle.%d, uuid:0x%04x, offset:%d\n" , __func__, write_data->char_handle , ((struct ut_uuid_16 *)(g_attrs_list[ii].uuid))->val , write_data->offset); bt_gatts_adapter_update_user_data(ii, 0, write_data->data, write_data->len); amp_bt_gatts_adapter_usr_data_t *data = g_attrs_list[ii].user_data; //bt_gatts_dump_hex(data->data, data->len); native_bt_host_gatts_handle_write(write_data->data, write_data->len); break; } } } break; case EVENT_GATT_CHAR_CCC_CHANGE: { evt_data_gatt_char_ccc_change_t *data = (evt_data_gatt_char_ccc_change_t *)event_data; for (int ii=0; ii<g_attr_num; ii++) { if (g_attrs_list[ii].handle == data->char_handle) { struct bt_gatt_ccc_t *ccc = (struct bt_gatt_ccc_t *)g_attrs_list[ii+1].user_data; printf("[%s]ccc-write at handle.%d 0x%04x, 0x%04x,\n", __func__, data->char_handle , data->ccc_value, ccc->value); } } } break; break; default: break; } }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/wireless/bt_host/bt_gatts_adapter.c
C
apache-2.0
12,496
/* * Copyright (C) 2015-2019 Alibaba Group Holding Limited */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <aos/errno.h> #include <aos/kernel.h> #include "aos/init.h" #include "board.h" #include <k_api.h> #include <aos/ble.h> #include <bluetooth/bluetooth.h> #include <bluetooth/conn.h> #include <atomic.h> #include <work.h> #include <bluetooth/gatt.h> #include <bluetooth/uuid.h> #include "amp_platform.h" #include "aos_system.h" #include "amp_defines.h" #include "amp_task.h" #include "be_inl.h" #include "aiot_state_api.h" #include "bt_host_adapter.h" #define MOD_STR "BT_HOST_ADAPTER" static void bt_host_adapter_adv_data_destroy(ad_data_t *ad_data, int ad_num); static int bt_host_adapter_event_callback(ble_event_en event, void *event_data); extern int bt_gatts_adapter_event_callback(ble_event_en event, void *event_data); static ble_event_cb_t bt_host_adapter_ble_cb = { .callback = bt_host_adapter_event_callback, }; static int bt_host_adapter_char2hex(char c, char *x) { if (c >= '0' && c <= '9') { *x = c - '0'; } else if (c >= 'a' && c <= 'f') { *x = c - 'a' + 10; } else if (c >= 'A' && c <= 'F') { *x = c - 'A' + 10; } else { return -1; } return 0; } static int bt_host_adapter_hex2bin(char *hex, uint8_t *buf) { char dec; int hexlen, i; hexlen = strlen(hex); if (hexlen == 0) { return NULL; } /* if hexlen is uneven, return failed */ if (hexlen % 2) { return NULL; } /* regular hex conversion */ for (i = 0; i < hexlen/2; i++) { if (bt_host_adapter_char2hex(hex[2 * i], &dec) < 0) { return 0; } buf[i] = dec << 4; if (bt_host_adapter_char2hex(hex[2 * i + 1], &dec) < 0) { return 0; } buf[i] += dec; } return hexlen/2; } static int bt_host_adapter_bin2hex(char *hex, uint8_t *buf, uint8_t buf_len) { int i; if (hex == NULL) return 0; hex[0] = 0; for (i = 0; i < buf_len; i++) { sprintf(hex+strlen(hex), "%02x", buf[i]); } return buf_len*2; } static int bt_host_adapter_event_callback(ble_event_en event, void *event_data) { amp_debug(MOD_STR, "%s, event = %x", __func__, event); switch (event) { case EVENT_GAP_CONN_CHANGE: { evt_data_gap_conn_change_t *e = (evt_data_gap_conn_change_t *)event_data; int32_t connect; if (e->connected == CONNECTED) { connect = 1; amp_debug(MOD_STR, "Connected"); } else { connect = 0; amp_debug(MOD_STR, "Disconnected"); } native_bt_host_conn_handle(e->conn_handle, connect); } break; case EVENT_GAP_DEV_FIND: { evt_data_gap_dev_find_t *e = (evt_data_gap_dev_find_t *)event_data; char adv_data[63]; char addr[18]; adv_data[0] = 0; bt_host_adapter_bin2hex(adv_data, e->adv_data, e->adv_len); addr[0] = 0; bt_host_adapter_bin2hex(addr, e->dev_addr.val, 6); native_bt_host_scan_handle(addr, e->dev_addr.type, e->adv_type, adv_data, e->rssi); } break; default: bt_gatts_adapter_event_callback(event, event_data); break; } return 0; } static ad_data_t *bt_host_adapter_adv_data_parse(char *adv_data, int8_t *num) { int ad_num; int i, type, len, adv_len; ad_data_t *ad_data; uint8_t adv_bin[31]; if (adv_data == NULL) { return NULL; } adv_len = strlen(adv_data); if (adv_len == 0 || adv_len > 62) { return NULL; } adv_len = bt_host_adapter_hex2bin(adv_data, adv_bin); ad_num = 0; for (i = 0; i < adv_len; ) { len = adv_bin[i]; if (i+len >= adv_len) { amp_debug(MOD_STR, "%s, wrong data %s", __func__, adv_data); return NULL; } i += len+1; ad_num++; } if (ad_num == 0) { return NULL; } ad_data = aos_malloc(ad_num*sizeof(ad_data_t)); if (ad_data == NULL) { return NULL; } memset(ad_data, 0, sizeof(ad_num*sizeof(ad_data_t))); ad_num = 0; for (i = 0; i < adv_len; ) { len = adv_bin[i]; ad_data[ad_num].len = len-1; ad_data[ad_num].type = adv_bin[i+1]; ad_data[ad_num].data = aos_malloc(len-1); if (ad_data[ad_num].data == NULL) { bt_host_adapter_adv_data_destroy(ad_data, ad_num); return NULL; } memcpy(ad_data[ad_num].data, adv_bin+i+2, len-2); i += len+1; ad_num++; } if (num) { *num = ad_num; } return ad_data; } static void bt_host_adapter_adv_data_destroy(ad_data_t *ad_data, int ad_num) { int i; for (i = 0; i < ad_num; i++) { if (ad_data[i].data) { aos_free(ad_data[i].data); } } aos_free(ad_data); } int bt_host_adapter_init(amp_bt_host_adapter_init_t *init) { init_param_t param; int ret; param.dev_name = init->dev_name; param.conn_num_max = init->conn_num_max; param.dev_addr = NULL; ret = ble_stack_init(&param); if (ret != BLE_STACK_OK) { return -1; } ret = ble_stack_event_register(&bt_host_adapter_ble_cb); if(ret) { return -1; } return ret; } int bt_host_adapter_start_adv(amp_bt_host_adapter_adv_start_t *adv_param) { adv_param_t param; int ret; param.type = adv_param->type; param.interval_min = adv_param->interval_min; param.interval_max = adv_param->interval_max; param.channel_map = adv_param->channel_map; param.ad_num = 0; param.sd_num = 0; param.ad = bt_host_adapter_adv_data_parse(adv_param->adv_data, &(param.ad_num)); param.sd = bt_host_adapter_adv_data_parse(adv_param->scan_rsp_data, &(param.sd_num)); param.filter_policy = ADV_FILTER_POLICY_ANY_REQ; memset(&(param.direct_peer_addr), 0, sizeof(dev_addr_t)); amp_debug(MOD_STR, "%s, ble_stack_adv_start, type = %d, min = %d, max = %d, ch = %d, ad_num = %d, sd_num = %d, ad[0].type = %d, ad[0].len = %d", __func__, param.type, param.interval_min, param.interval_max, param.channel_map, param.ad_num, param.sd_num, param.ad[0].type, param.ad[0].len); ret = ble_stack_adv_start(&param); amp_debug(MOD_STR, "ble_stack_adv_start ret = %d", ret); if (param.ad) { bt_host_adapter_adv_data_destroy(param.ad, param.ad_num); } if (param.sd) { bt_host_adapter_adv_data_destroy(param.sd, param.sd_num); } if(ret) { return -1; } return ret; } int bt_host_adapter_stop_adv(void) { int ret; ret = ble_stack_adv_stop(); if(ret) { return -1; } return ret; } int bt_host_adapter_start_scan(amp_bt_host_adapter_scan_start_t *scan_param) { scan_param_t param; int ret; param.type = scan_param->type; param.interval = scan_param->interval; param.window = scan_param->window; param.filter_dup = SCAN_FILTER_DUP_DISABLE; param.scan_filter = SCAN_FILTER_POLICY_ANY_ADV; amp_debug(MOD_STR, "%s, ble_stack_scan_start, type = %d, int = %d, win = %d", __func__, param.type, param.interval, param.window); ret = ble_stack_scan_start(&param); amp_debug(MOD_STR, "ble_stack_scan_start ret = %d", ret); if(ret) { return -1; } return ret; } int bt_host_adapter_stop_scan(void) { int ret; ret = ble_stack_scan_stop(); if(ret) { return -1; } return ret; }
YifuLiu/AliOS-Things
components/amp/engine/duktape_engine/addons/wireless/bt_host/bt_host_adapter.c
C
apache-2.0
7,664