You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/22 14:17:23 UTC

[GitHub] [tvm] stoa commented on a change in pull request #7742: Contributing the STM32 port

stoa commented on a change in pull request #7742:
URL: https://github.com/apache/tvm/pull/7742#discussion_r713990676



##########
File path: tests/crt/contrib/stm32/src/main.c
##########
@@ -0,0 +1,461 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 <inttypes.h>
+#include <math.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ai_runtime_api.h"
+#include "network.h"
+#include "network_data.h"
+
+//
+// Network that we are testing
+//
+extern ai_model_info network_network;
+
+//
+// Dummy: for the runtime
+//
+uint32_t __models_section_start__ = (uint32_t)&network_network;
+uint32_t __models_section_end__ = (uint32_t)&network_network + sizeof(ai_model_info);
+
+static ai_model_info* _model_p = &network_network;
+
+//
+// Global handle to reference the instantiated NN
+//
+static ai_handle _network = AI_HANDLE_NULL;
+
+static uint8_t LoadInputImg(const char* filename, ai_tensor* input);
+static int32_t quantize_val(float val, ai_quantization_info* quant);
+static float dequantize_val(int32_t val, ai_quantization_info* quant);
+
+// =================================================================
+//   Convert_Fixed_To_Float
+// =================================================================
+static float Convert_Fixed_To_Float(uint8_t data, int8_t fl) {
+  uint8_t val = data;
+  float x;
+  if (fl >= 0) {
+    x = ((float)val) / (float)(1 << fl);  // NOLINT
+  } else {
+    x = ((float)val) / (float)(1 >> fl);  // NOLINT

Review comment:
       Thanks: copy-paste from a wrong place ...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org