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 
xnn_delete_operator(xnn_operator_t op)18 enum xnn_status xnn_delete_operator(xnn_operator_t op)
19 {
20   if ((xnn_params.init_flags & XNN_INIT_FLAG_XNNPACK) == 0) {
21     xnn_log_error("failed to delete operator: XNNPACK is not initialized");
22     return xnn_status_uninitialized;
23   }
24 
25   if (op == NULL) {
26     return xnn_status_invalid_parameter;
27   }
28 
29   xnn_release_memory(op->indirection_buffer);
30   xnn_release_simd_memory(op->packed_weights);
31   xnn_release_simd_memory(op->zero_buffer);
32   xnn_release_memory(op->pixelwise_buffer);
33   xnn_release_memory(op->subconvolution_buffer);
34   xnn_release_simd_memory(op->lookup_table);
35   xnn_release_simd_memory(op);
36   return xnn_status_success;
37 }
38