• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 // All rights reserved.
3 //
4 // Copyright 2019 Google LLC
5 //
6 // This source code is licensed under the BSD-style license found in the
7 // LICENSE file in the root directory of this source tree.
8 
9 #include <stdlib.h>
10 
11 #include <xnnpack.h>
12 #include <xnnpack/allocator.h>
13 #include <xnnpack/log.h>
14 #include <xnnpack/operator.h>
15 #include <xnnpack/params.h>
16 
17 
18 #if XNN_PLATFORM_JIT
xnn_release_jit_ukernel(struct xnn_ukernel ukernel)19 static void xnn_release_jit_ukernel(struct xnn_ukernel ukernel)
20 {
21   switch (ukernel.type) {
22     case xnn_ukernel_type_gemm:
23       xnn_release_code_memory(&ukernel.gemm.general_code_buffer);
24       xnn_release_code_memory(&ukernel.gemm.mr1_code_buffer);
25       break;
26     default:
27       break;
28       // Do nothing, only GEMMs have JIT kernels now.
29   }
30 }
31 #endif  // XNN_PLATFORM_JIT
32 
xnn_delete_operator(xnn_operator_t op)33 enum xnn_status xnn_delete_operator(xnn_operator_t op)
34 {
35   if ((xnn_params.init_flags & XNN_INIT_FLAG_XNNPACK) == 0) {
36     xnn_log_error("failed to delete operator: XNNPACK is not initialized");
37     return xnn_status_uninitialized;
38   }
39 
40   if (op == NULL) {
41     return xnn_status_invalid_parameter;
42   }
43 
44   xnn_release_memory(op->indirection_buffer);
45   xnn_release_simd_memory(op->packed_weights);
46   xnn_release_simd_memory(op->zero_buffer);
47   xnn_release_memory(op->pixelwise_buffer);
48   xnn_release_memory(op->subconvolution_buffer);
49   xnn_release_simd_memory(op->lookup_table);
50 #if XNN_PLATFORM_JIT
51   xnn_release_jit_ukernel(op->ukernel);
52 #endif  // XNN_PLATFORM_JIT
53   xnn_release_simd_memory(op);
54   return xnn_status_success;
55 }
56