tvm
platform.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
25 #ifndef TVM_RUNTIME_CRT_PLATFORM_H_
26 #define TVM_RUNTIME_CRT_PLATFORM_H_
27 
28 #include <stdarg.h>
29 #include <stddef.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
43 #if defined(_MSC_VER)
44 __declspec(noreturn) void TVMPlatformAbort(tvm_crt_error_t code);
45 #else
46 void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t code);
47 #endif
48 
61 size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt,
62  va_list args);
63 
75 tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr);
76 
84 tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev);
85 
93 
102 tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds);
103 
113 
122 
140 tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes);
141 
150 
151 #ifdef __cplusplus
152 } // extern "C"
153 #endif
154 
155 #endif // TVM_RUNTIME_CRT_PLATFORM_H_
Defines integral error codes returned by the CRT.
tvm_crt_error_t
Definition: error_codes.h:50
tvm_crt_error_t TVMPlatformTimerStop(double *elapsed_time_seconds)
Stop the running device timer and get the elapsed time (in microseconds).
tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void **out_ptr)
Allocate memory for use by TVM.
tvm_crt_error_t TVMPlatformTimerStart()
Start a device timer.
tvm_crt_error_t TVMPlatformAfterMeasurement()
Platform-specific after measurement call.
void TVMPlatformAbort(tvm_crt_error_t code)
Called when an internal error occurs and execution cannot continue.
size_t TVMPlatformFormatMessage(char *out_buf, size_t out_buf_size_bytes, const char *fmt, va_list args)
Called by the microTVM RPC server to implement TVMLogf.
tvm_crt_error_t TVMPlatformInitialize()
Initialize TVM inference.
tvm_crt_error_t TVMPlatformMemoryFree(void *ptr, DLDevice dev)
Free memory used by TVM.
tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t *buffer, size_t num_bytes)
Fill a buffer with random data.
tvm_crt_error_t TVMPlatformBeforeMeasurement()
Platform-specific before measurement call.