diff --git a/lib/nncase/v1/include/nncase/kernels/convolution.h b/lib/nncase/v1/include/nncase/kernels/convolution.h index 7dd9474..7c16558 100644 --- a/lib/nncase/v1/include/nncase/kernels/convolution.h +++ b/lib/nncase/v1/include/nncase/kernels/convolution.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/optimized/convolution.h b/lib/nncase/v1/include/nncase/kernels/cpu/optimized/convolution.h index 85b887d..673c07d 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/optimized/convolution.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/optimized/convolution.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/optimized/runtime_types.h b/lib/nncase/v1/include/nncase/kernels/cpu/optimized/runtime_types.h index 3ae0982..8aff824 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/optimized/runtime_types.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/optimized/runtime_types.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,17 +35,6 @@ } \ } -#define TYPE_IMPL_SELECT(type, IMPL) \ - switch (runtime::get_bytes(type)) \ - { \ - IMPL(1, uint8_t); \ - IMPL(2, uint16_t); \ - IMPL(4, uint32_t); \ - IMPL(8, uint64_t); \ - default: \ - return err(std::errc::not_supported); \ - } - enum copy_impl_select { all_contiguous, diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/optimized/tensor_compute.h b/lib/nncase/v1/include/nncase/kernels/cpu/optimized/tensor_compute.h index e0b2723..51e1a0b 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/optimized/tensor_compute.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/optimized/tensor_compute.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,33 @@ BEGIN_NS_NNCASE_KERNELS_CPU_OPT NNCASE_API result concat(datatype_t type, gsl::span inputs, gsl::byte *output, const runtime_shape_t &out_shape, gsl::span in_strides, const runtime_shape_t &out_strides, size_t axis, const runtime_shape_t &concat_dims, - kernel_context &context) noexcept; + kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result resize_bilinear(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, int32_t out_h, int32_t out_w, bool align_corners, bool half_pixel_centers, + kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result resize_nearest_neighbor(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, int32_t out_h, int32_t out_w, bool align_corners, bool half_pixel_centers, + kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result copy(datatype_t type, const gsl::byte *src, gsl::byte *dest, + const runtime_shape_t &shape, const runtime_shape_t &src_strides, const runtime_shape_t &dest_strides, + int dims_offset, copy_impl_select impl_select, kernel_context &context) noexcept; + +NNCASE_API result gather(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const int32_t *indices, const runtime_shape_t &indices_shape, size_t axis, + kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result gather_nd(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const int32_t *indices, const runtime_shape_t &indices_shape, size_t batch_dims, + kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result onehot(datatype_t type, const int32_t *indices, gsl::byte *output, const runtime_shape_t &indices_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &out_strides, gsl::byte *depth, gsl::byte *off_value, gsl::byte *on_value, size_t axis, onehot_mode_t mode, kernel_context &context) noexcept; NNCASE_API result slice(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const runtime_shape_t &begins, const runtime_shape_t &ends, const runtime_axis_t &strides, - kernel_context &context) noexcept; - -NNCASE_API result copy(datatype_t type, const gsl::byte *src, gsl::byte *dest, - const runtime_shape_t &shape, const runtime_shape_t &src_strides, const runtime_shape_t &dest_strides, - int dims_offset, copy_impl_select impl_select, kernel_context &context) noexcept; + kernel_context &context = default_kernel_context()) noexcept; END_NS_NNCASE_KERNELS_CPU_OPT diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/reference/convolution.h b/lib/nncase/v1/include/nncase/kernels/cpu/reference/convolution.h index 6f38b4f..080d441 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/reference/convolution.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/reference/convolution.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/reference/nnil.h b/lib/nncase/v1/include/nncase/kernels/cpu/reference/nnil.h index 6157865..8302be4 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/reference/nnil.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/reference/nnil.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/reference/reduce_window.h b/lib/nncase/v1/include/nncase/kernels/cpu/reference/reduce_window.h index ac59809..9258f09 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/reference/reduce_window.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/reference/reduce_window.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/reference/runtime_types.h b/lib/nncase/v1/include/nncase/kernels/cpu/reference/runtime_types.h index b90e146..0a068c3 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/reference/runtime_types.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/reference/runtime_types.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/cpu/reference/tensor_compute.h b/lib/nncase/v1/include/nncase/kernels/cpu/reference/tensor_compute.h index 4025d42..22a8b46 100644 --- a/lib/nncase/v1/include/nncase/kernels/cpu/reference/tensor_compute.h +++ b/lib/nncase/v1/include/nncase/kernels/cpu/reference/tensor_compute.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,9 @@ NNCASE_API result dequantize(datatype_t in_type, datatype_t out_type, cons NNCASE_API result lut1d(datatype_t type, const gsl::byte *input, const gsl::byte *table, gsl::byte *output, const runtime_shape_t &shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const scalar &min, const scalar &max) noexcept; +NNCASE_API result onehot(datatype_t type, const int32_t *indices, gsl::byte *output, const runtime_shape_t &indices_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &out_strides, gsl::byte *depth, gsl::byte *off_value, gsl::byte *on_value, size_t axis, onehot_mode_t mode, kernel_context &context) noexcept; + NNCASE_API result pad(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const runtime_paddings_t &paddings, pad_mode_t mode, const scalar &pad_value, kernel_context &context) noexcept; @@ -63,8 +66,22 @@ NNCASE_API result unary(unary_op_t op, const float *input, float *output, NNCASE_API result reduce(reduce_op_t op, float init_value, const float *input, float *output, const runtime_shape_t &in_shape, const runtime_shape_t &axis, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, bool keep_dims, kernel_context &context) noexcept; +NNCASE_API result resize_bilinear(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, int32_t out_h, int32_t out_w, bool align_corners, bool half_pixel_centers, + kernel_context &context) noexcept; + +NNCASE_API result resize_nearest_neighbor(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, int32_t out_h, int32_t out_w, bool align_corners, bool half_pixel_centers, + kernel_context &context) noexcept; + NNCASE_API result slice(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const runtime_shape_t &begins, const runtime_shape_t &ends, const runtime_axis_t &strides, kernel_context &context) noexcept; +NNCASE_API result gather(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const int32_t *indices, const runtime_shape_t &indices_shape, size_t axis, kernel_context &context) noexcept; + +NNCASE_API result gather_nd(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const int32_t *indices, const runtime_shape_t &indices_shape, size_t batch_dims, kernel_context &context) noexcept; + END_NS_NNCASE_KERNELS_CPU_REF diff --git a/lib/nncase/v1/include/nncase/kernels/k210/k210_kernels.h b/lib/nncase/v1/include/nncase/kernels/k210/k210_kernels.h index 145a99b..5e448da 100644 --- a/lib/nncase/v1/include/nncase/kernels/k210/k210_kernels.h +++ b/lib/nncase/v1/include/nncase/kernels/k210/k210_kernels.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/kernel_context.h b/lib/nncase/v1/include/nncase/kernels/kernel_context.h index 2d61391..bd71438 100644 --- a/lib/nncase/v1/include/nncase/kernels/kernel_context.h +++ b/lib/nncase/v1/include/nncase/kernels/kernel_context.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/kernel_utils.h b/lib/nncase/v1/include/nncase/kernels/kernel_utils.h index 181ed20..77e81b4 100644 --- a/lib/nncase/v1/include/nncase/kernels/kernel_utils.h +++ b/lib/nncase/v1/include/nncase/kernels/kernel_utils.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ #pragma once #include #include +#include #include #include #include @@ -27,6 +28,17 @@ #define CXX_RESTRICT #endif +#define TYPE_IMPL_SELECT(type, IMPL) \ + switch (runtime::get_bytes(type)) \ + { \ + IMPL(1, uint8_t); \ + IMPL(2, uint16_t); \ + IMPL(4, uint32_t); \ + IMPL(8, uint64_t); \ + default: \ + return err(std::errc::not_supported); \ + } + BEGIN_NS_NNCASE_KERNELS template @@ -236,5 +248,46 @@ constexpr T quantize(float value, const quant_param_t ¶m) noexcept { return (T)clamp((int32_t)lrintf(value / param.scale + param.zero_point), (int32_t)std::numeric_limits::lowest(), (int32_t)std::numeric_limits::max()); } + +inline std::pair get_resize_scales(const runtime_shape_t &in_shape, int32_t out_h, int32_t out_w, bool align_corners) +{ + auto height_scale = (float)in_shape[2] / out_h; + auto width_scale = (float)in_shape[3] / out_w; + if (align_corners && out_h > 1) + height_scale = (float)(in_shape[2] - 1) / (out_h - 1); + if (align_corners && out_w > 1) + width_scale = (float)(in_shape[3] - 1) / (out_w - 1); + return { height_scale, width_scale }; +} + +inline void set_resize_bilinear(size_t value, float scale, bool half_pixel_centers, size_t shape_size, float &scaled_value, int32_t &v0, int32_t &v1) +{ + if (half_pixel_centers) + { + scaled_value = (value + 0.5f) * scale - 0.5f; + } + else + { + scaled_value = value * scale; + } + float scaled_value_floor = std::floor(scaled_value); + v0 = std::max(static_cast(scaled_value_floor), 0); + v1 = std::min(static_cast(std::ceil(scaled_value)), static_cast(shape_size - 1)); +} + +template +inline size_t get_nearest_neighbor(T input_value, size_t shape_size, float scale, bool align_corners, bool half_pixel_centers) +{ + const auto offset = half_pixel_centers ? 0.5f : 0.0f; + const auto after_scale = (static_cast(input_value) + offset) * scale; + const auto align_corners_val = align_corners ? roundf(after_scale) : std::floor(after_scale); + int32_t output_value = std::min(static_cast(align_corners_val), static_cast(shape_size - 1)); + if (half_pixel_centers) + { + output_value = std::max(0, output_value); + } + return output_value; +} + } END_NS_NNCASE_KERNELS diff --git a/lib/nncase/v1/include/nncase/kernels/neutral/neutral_kernels.h b/lib/nncase/v1/include/nncase/kernels/neutral/neutral_kernels.h index e8b9c81..7c369e4 100644 --- a/lib/nncase/v1/include/nncase/kernels/neutral/neutral_kernels.h +++ b/lib/nncase/v1/include/nncase/kernels/neutral/neutral_kernels.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/nnil.h b/lib/nncase/v1/include/nncase/kernels/nnil.h index 3c53881..08851fa 100644 --- a/lib/nncase/v1/include/nncase/kernels/nnil.h +++ b/lib/nncase/v1/include/nncase/kernels/nnil.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,10 +13,10 @@ * limitations under the License. */ #pragma once +#include #include #include #include -#include BEGIN_NS_NNCASE_KERNELS diff --git a/lib/nncase/v1/include/nncase/kernels/reduce_window.h b/lib/nncase/v1/include/nncase/kernels/reduce_window.h index 35c4aae..4b56d86 100644 --- a/lib/nncase/v1/include/nncase/kernels/reduce_window.h +++ b/lib/nncase/v1/include/nncase/kernels/reduce_window.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/riscv/neutral_kernels.h b/lib/nncase/v1/include/nncase/kernels/riscv/neutral_kernels.h index cdf224d..127ad0a 100644 --- a/lib/nncase/v1/include/nncase/kernels/riscv/neutral_kernels.h +++ b/lib/nncase/v1/include/nncase/kernels/riscv/neutral_kernels.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/kernels/tensor_compute.h b/lib/nncase/v1/include/nncase/kernels/tensor_compute.h index 9d27616..f2ecc9f 100644 --- a/lib/nncase/v1/include/nncase/kernels/tensor_compute.h +++ b/lib/nncase/v1/include/nncase/kernels/tensor_compute.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,15 @@ * limitations under the License. */ #pragma once +#include #include #include #include -#include BEGIN_NS_NNCASE_KERNELS NNCASE_API result batch_to_space(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, - const runtime_shape_t &block_shape, const runtime_paddings_t &crops, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, + const runtime_shape_t &block_shape, const runtime_paddings_t &crops, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, kernel_context &context = default_kernel_context()) noexcept; NNCASE_API result broadcast(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, @@ -51,6 +51,10 @@ NNCASE_API result dequantize(datatype_t in_type, datatype_t out_type, cons NNCASE_API result lut1d(datatype_t type, const gsl::byte *input, const gsl::byte *table, gsl::byte *output, const runtime_shape_t &shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const scalar &min, const scalar &max) noexcept; +NNCASE_API result onehot(datatype_t type, const int32_t *indices, gsl::byte *output, const runtime_shape_t &indices_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &out_strides, gsl::byte *depth, gsl::byte *off_value, gsl::byte *on_value, size_t axis, onehot_mode_t mode, + kernel_context &context = default_kernel_context()) noexcept; + NNCASE_API result pad(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const runtime_paddings_t &paddings, pad_mode_t mode, const scalar &pad_value, kernel_context &context = default_kernel_context()) noexcept; @@ -65,8 +69,21 @@ NNCASE_API result unary(unary_op_t op, const float *input, float *output, NNCASE_API result reduce(reduce_op_t op, float init_value, const float *input, float *output, const runtime_shape_t &in_shape, const runtime_shape_t &axis, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, bool keep_dims, kernel_context &context = default_kernel_context()) noexcept; +NNCASE_API result resize_bilinear(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, int32_t out_h, int32_t out_w, bool align_corners, bool half_pixel_centers, + kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result resize_nearest_neighbor(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, int32_t out_h, int32_t out_w, bool align_corners, bool half_pixel_centers, + kernel_context &context = default_kernel_context()) noexcept; + NNCASE_API result slice(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const runtime_shape_t &begins, const runtime_shape_t &ends, const runtime_axis_t &strides, kernel_context &context = default_kernel_context()) noexcept; +NNCASE_API result gather(datatype_t in_type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const int32_t *indices, const runtime_shape_t &indices_shape, int32_t axis, kernel_context &context = default_kernel_context()) noexcept; + +NNCASE_API result gather_nd(datatype_t type, const gsl::byte *input, gsl::byte *output, const runtime_shape_t &in_shape, const runtime_shape_t &out_shape, + const runtime_shape_t &in_strides, const runtime_shape_t &out_strides, const int32_t *indices, const runtime_shape_t &indices_shape, int32_t batch_dims, kernel_context &context = default_kernel_context()) noexcept; END_NS_NNCASE_KERNELS diff --git a/lib/nncase/v1/include/nncase/runtime/allocator.h b/lib/nncase/v1/include/nncase/runtime/allocator.h index 23fe469..fa995ad 100644 --- a/lib/nncase/v1/include/nncase/runtime/allocator.h +++ b/lib/nncase/v1/include/nncase/runtime/allocator.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/bfloat16.h b/lib/nncase/v1/include/nncase/runtime/bfloat16.h index b4373fe..a121cad 100644 --- a/lib/nncase/v1/include/nncase/runtime/bfloat16.h +++ b/lib/nncase/v1/include/nncase/runtime/bfloat16.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/bitio.h b/lib/nncase/v1/include/nncase/runtime/bitio.h index 2642406..1303860 100644 --- a/lib/nncase/v1/include/nncase/runtime/bitio.h +++ b/lib/nncase/v1/include/nncase/runtime/bitio.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/compiler_defs.h b/lib/nncase/v1/include/nncase/runtime/compiler_defs.h index a1efbe3..4f412fc 100644 --- a/lib/nncase/v1/include/nncase/runtime/compiler_defs.h +++ b/lib/nncase/v1/include/nncase/runtime/compiler_defs.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/datatypes.h b/lib/nncase/v1/include/nncase/runtime/datatypes.h index 9146728..af1d543 100644 --- a/lib/nncase/v1/include/nncase/runtime/datatypes.h +++ b/lib/nncase/v1/include/nncase/runtime/datatypes.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,6 +136,22 @@ typedef enum _reduce_op reduce_sum } reduce_op_t; +inline std::string reduce_op_to_string(reduce_op_t op) +{ + switch (op) + { + case reduce_mean: + return "reduce_mean"; + case reduce_min: + return "reduce_min"; + case reduce_max: + return "reduce_max"; + case reduce_sum: + return "reduce_sum"; + } + return "unknown"; +} + typedef enum _binary_op { binary_add, @@ -256,6 +272,12 @@ typedef enum _image_resize_mode image_resize_nearest_neighbor } image_resize_mode_t; +typedef enum _onehot_mode +{ + onehot_normal, + onehot_process_neg +} onehot_mode_t; + typedef enum _pad_mode { pad_constant, diff --git a/lib/nncase/v1/include/nncase/runtime/error.h b/lib/nncase/v1/include/nncase/runtime/error.h index a4f7daf..c56d6f5 100644 --- a/lib/nncase/v1/include/nncase/runtime/error.h +++ b/lib/nncase/v1/include/nncase/runtime/error.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/host_runtime_tensor.h b/lib/nncase/v1/include/nncase/runtime/host_runtime_tensor.h index 5d889d2..cdf90a3 100644 --- a/lib/nncase/v1/include/nncase/runtime/host_runtime_tensor.h +++ b/lib/nncase/v1/include/nncase/runtime/host_runtime_tensor.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,9 @@ struct host_memory_block host_memory_block() = default; host_memory_block(const host_memory_block &) = delete; - host_memory_block(host_memory_block && other) noexcept; + host_memory_block(host_memory_block &&other) noexcept; host_memory_block &operator=(const host_memory_block &) = delete; - host_memory_block &operator=(host_memory_block && other) noexcept; + host_memory_block &operator=(host_memory_block &&other) noexcept; ~host_memory_block() { @@ -52,6 +52,7 @@ struct host_memory_block if (auto d = std::move(deleter)) d(reinterpret_cast(virtual_address)); deleter = {}; + physical_block.free(*this); } gsl::span virtual_buffer() const noexcept diff --git a/lib/nncase/v1/include/nncase/runtime/interpreter.h b/lib/nncase/v1/include/nncase/runtime/interpreter.h index a068ba1..470cfb5 100644 --- a/lib/nncase/v1/include/nncase/runtime/interpreter.h +++ b/lib/nncase/v1/include/nncase/runtime/interpreter.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/k210/compiler_defs.h b/lib/nncase/v1/include/nncase/runtime/k210/compiler_defs.h index a79bff0..a57de2c 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/compiler_defs.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/compiler_defs.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/k210/error.h b/lib/nncase/v1/include/nncase/runtime/k210/error.h index 218c9d0..43776fe 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/error.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/error.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/k210/kernel_context.h b/lib/nncase/v1/include/nncase/runtime/k210/kernel_context.h index 160a450..11dd3eb 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/kernel_context.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/kernel_context.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/k210/op_reader.h b/lib/nncase/v1/include/nncase/runtime/k210/op_reader.h index d5a526a..b2c8ec9 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/op_reader.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/op_reader.h @@ -1,6 +1,4 @@ -/* This file is generated by tools/stackvm_gen/IsaGen at 2021/2/23 16:24:09 +08:00. - * - * Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +34,7 @@ public: virtual result visit(NNCASE_UNUSED const kpu_download_options &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const kpu_conv2d_options &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const kpu_upload_options &op) noexcept { return ok(); } + virtual result visit(NNCASE_UNUSED const copy_options &op) noexcept { return ok(); } protected: bool interrupted_; diff --git a/lib/nncase/v1/include/nncase/runtime/k210/runtime_module.h b/lib/nncase/v1/include/nncase/runtime/k210/runtime_module.h index 310a7f4..9298d0e 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/runtime_module.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/runtime_module.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/k210/runtime_op_utility.h b/lib/nncase/v1/include/nncase/runtime/k210/runtime_op_utility.h index 2ffdee0..083d680 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/runtime_op_utility.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/runtime_op_utility.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/k210/runtime_types.h b/lib/nncase/v1/include/nncase/runtime/k210/runtime_types.h index ac4015f..2d024f1 100644 --- a/lib/nncase/v1/include/nncase/runtime/k210/runtime_types.h +++ b/lib/nncase/v1/include/nncase/runtime/k210/runtime_types.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -292,7 +292,8 @@ enum class opcode_t : uint8_t { kpu_upload, kpu_download, - kpu_conv2d + kpu_conv2d, + copy }; struct kpu_upload_options @@ -328,4 +329,16 @@ struct kpu_conv2d_options kpu_layer_argument_t layer; }; +struct copy_options +{ + opcode_t opcode = opcode_t::copy; + uint8_t reserved0[3]; + + memory_range input; + memory_range output; + kpu_shape_t in_shape; + kpu_shape_t in_strides; + kpu_shape_t out_strides; +}; + END_NS_NNCASE_RT_K210 diff --git a/lib/nncase/v1/include/nncase/runtime/model.h b/lib/nncase/v1/include/nncase/runtime/model.h index 1c9286e..72b6630 100644 --- a/lib/nncase/v1/include/nncase/runtime/model.h +++ b/lib/nncase/v1/include/nncase/runtime/model.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/nnil.h b/lib/nncase/v1/include/nncase/runtime/nnil.h index cb1c092..bae8ab7 100644 --- a/lib/nncase/v1/include/nncase/runtime/nnil.h +++ b/lib/nncase/v1/include/nncase/runtime/nnil.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/result.h b/lib/nncase/v1/include/nncase/runtime/result.h index 43eb099..a1fa153 100644 --- a/lib/nncase/v1/include/nncase/runtime/result.h +++ b/lib/nncase/v1/include/nncase/runtime/result.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ struct Ok : value(value) { } template - constexpr explicit Ok(mpark::in_place_t, Args &&...args) + constexpr explicit Ok(mpark::in_place_t, Args &&... args) : value(std::forward(args)...) { } T value; @@ -101,7 +101,7 @@ inline constexpr Ok ok() } template -constexpr Ok ok(Args &&...args) +constexpr Ok ok(Args &&... args) { return Ok(mpark::in_place, std::forward(args)...); } diff --git a/lib/nncase/v1/include/nncase/runtime/runtime_loader.h b/lib/nncase/v1/include/nncase/runtime/runtime_loader.h index 44a61d8..dd873d1 100644 --- a/lib/nncase/v1/include/nncase/runtime/runtime_loader.h +++ b/lib/nncase/v1/include/nncase/runtime/runtime_loader.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/runtime_module.h b/lib/nncase/v1/include/nncase/runtime/runtime_module.h index ee06e2c..009affb 100644 --- a/lib/nncase/v1/include/nncase/runtime/runtime_module.h +++ b/lib/nncase/v1/include/nncase/runtime/runtime_module.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/runtime_op_utility.h b/lib/nncase/v1/include/nncase/runtime/runtime_op_utility.h index d754cc6..1ebb1a4 100644 --- a/lib/nncase/v1/include/nncase/runtime/runtime_op_utility.h +++ b/lib/nncase/v1/include/nncase/runtime/runtime_op_utility.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -252,8 +252,10 @@ inline int get_last_not_contiguous_index(const runtime_shape_t &strides, const r return -1; } -template +template constexpr auto is_not_equal = std::integral_constant {}(A, B)> {}; -struct DefaultCallable {}; +struct DefaultCallable +{ +}; END_NS_NNCASE_RUNTIME diff --git a/lib/nncase/v1/include/nncase/runtime/runtime_tensor.h b/lib/nncase/v1/include/nncase/runtime/runtime_tensor.h index eac5e59..396e73d 100644 --- a/lib/nncase/v1/include/nncase/runtime/runtime_tensor.h +++ b/lib/nncase/v1/include/nncase/runtime/runtime_tensor.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/runtime_tensor_impl.h b/lib/nncase/v1/include/nncase/runtime/runtime_tensor_impl.h index d53a070..4b01477 100644 --- a/lib/nncase/v1/include/nncase/runtime/runtime_tensor_impl.h +++ b/lib/nncase/v1/include/nncase/runtime/runtime_tensor_impl.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.h b/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.h index 01a6f74..73fda54 100644 --- a/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.h +++ b/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.platform.h b/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.platform.h index 266d82f..4a2788b 100644 --- a/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.platform.h +++ b/lib/nncase/v1/include/nncase/runtime/shared_runtime_tensor.platform.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ struct NNCASE_API physical_memory_block physical_memory_block &operator=(const physical_memory_block &) = delete; physical_memory_block &operator=(physical_memory_block &&other) noexcept; - result free() noexcept; + void free(NNCASE_UNUSED host_memory_block &block) noexcept; static result acknowledge(host_memory_block &block) noexcept; static result allocate(host_memory_block &block) noexcept; diff --git a/lib/nncase/v1/include/nncase/runtime/small_vector.hpp b/lib/nncase/v1/include/nncase/runtime/small_vector.hpp index ae82cc1..ebc39a9 100644 --- a/lib/nncase/v1/include/nncase/runtime/small_vector.hpp +++ b/lib/nncase/v1/include/nncase/runtime/small_vector.hpp @@ -130,61 +130,69 @@ // #pragma once -#include #include #include +#include -#define ITLIB_SMALL_VECTOR_ERROR_HANDLING_NONE 0 +#define ITLIB_SMALL_VECTOR_ERROR_HANDLING_NONE 0 #define ITLIB_SMALL_VECTOR_ERROR_HANDLING_THROW 1 #define ITLIB_SMALL_VECTOR_ERROR_HANDLING_ASSERT 2 #define ITLIB_SMALL_VECTOR_ERROR_HANDLING_ASSERT_AND_THROW 3 #if !defined(ITLIB_SMALL_VECTOR_ERROR_HANDLING) -# define ITLIB_SMALL_VECTOR_ERROR_HANDLING ITLIB_SMALL_VECTOR_ERROR_HANDLING_THROW +#define ITLIB_SMALL_VECTOR_ERROR_HANDLING ITLIB_SMALL_VECTOR_ERROR_HANDLING_THROW #endif - #if ITLIB_SMALL_VECTOR_ERROR_HANDLING == ITLIB_SMALL_VECTOR_ERROR_HANDLING_NONE -# define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond) +#define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond) #elif ITLIB_SMALL_VECTOR_ERROR_HANDLING == ITLIB_SMALL_VECTOR_ERROR_HANDLING_THROW -# include -# define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond) if (cond) throw std::out_of_range("itlib::small_vector out of range") +#include +#define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond) \ + if (cond) \ + throw std::out_of_range("itlib::small_vector out of range") #elif ITLIB_SMALL_VECTOR_ERROR_HANDLING == ITLIB_SMALL_VECTOR_ERROR_HANDLING_ASSERT -# include -# define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond, rescue_return) assert(!(cond) && "itlib::small_vector out of range") +#include +#define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond, rescue_return) assert(!(cond) && "itlib::small_vector out of range") #elif ITLIB_SMALL_VECTOR_ERROR_HANDLING == ITLIB_SMALL_VECTOR_ERROR_HANDLING_ASSERT_AND_THROW -# include -# include -# define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond, rescue_return) \ - do { if (cond) { assert(false && "itlib::small_vector out of range"); throw std::out_of_range("itlib::small_vector out of range"); } } while(false) +#include +#include +#define I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(cond, rescue_return) \ + do \ + { \ + if (cond) \ + { \ + assert(false && "itlib::small_vector out of range"); \ + throw std::out_of_range("itlib::small_vector out of range"); \ + } \ + } while (false) #else #error "Unknown ITLIB_SMALL_VECTOR_ERRROR_HANDLING" #endif - #if defined(ITLIB_SMALL_VECTOR_NO_DEBUG_BOUNDS_CHECK) -# define I_ITLIB_SMALL_VECTOR_BOUNDS_CHECK(i) +#define I_ITLIB_SMALL_VECTOR_BOUNDS_CHECK(i) #else -# include -# define I_ITLIB_SMALL_VECTOR_BOUNDS_CHECK(i) assert((i) < this->size()) +#include +#define I_ITLIB_SMALL_VECTOR_BOUNDS_CHECK(i) assert((i) < this->size()) #endif namespace itlib { -template> -struct small_vector: Alloc +template > +struct small_vector : Alloc { static_assert(RevertToStaticSize <= StaticCapacity + 1, "itlib::small_vector: the revert-to-static size shouldn't exceed the static capacity by more than one"); using atraits = std::allocator_traits; + public: using allocator_type = Alloc; using value_type = typename atraits::value_type; using size_type = typename atraits::size_type; using difference_type = typename atraits::difference_type; - using reference = T&; - using const_reference = const T&; + using reference = T &; + using const_reference = const T &; using pointer = typename atraits::pointer; using const_pointer = typename atraits::const_pointer; using iterator = pointer; @@ -197,9 +205,10 @@ public: small_vector() : small_vector(Alloc()) - {} + { + } - small_vector(const Alloc& alloc) + small_vector(const Alloc &alloc) : Alloc(alloc) , m_capacity(StaticCapacity) , m_dynamic_capacity(0) @@ -208,36 +217,37 @@ public: m_begin = m_end = static_begin_ptr(); } - explicit small_vector(size_t count, const Alloc& alloc = Alloc()) + explicit small_vector(size_t count, const Alloc &alloc = Alloc()) : small_vector(alloc) { resize(count); } - explicit small_vector(size_t count, const T& value, const Alloc& alloc = Alloc()) + explicit small_vector(size_t count, const T &value, const Alloc &alloc = Alloc()) : small_vector(alloc) { assign_impl(count, value); } template ())> - small_vector(InputIterator first, InputIterator last, const Alloc& alloc = Alloc()) + small_vector(InputIterator first, InputIterator last, const Alloc &alloc = Alloc()) : small_vector(alloc) { assign_impl(first, last); } - small_vector(std::initializer_list l, const Alloc& alloc = Alloc()) + small_vector(std::initializer_list l, const Alloc &alloc = Alloc()) : small_vector(alloc) { assign_impl(l); } - small_vector(const small_vector& v) + small_vector(const small_vector &v) : small_vector(v, atraits::select_on_container_copy_construction(v.get_allocator())) - {} + { + } - small_vector(const small_vector& v, const Alloc& alloc) + small_vector(const small_vector &v, const Alloc &alloc) : Alloc(alloc) , m_dynamic_capacity(0) , m_dynamic_data(nullptr) @@ -261,7 +271,7 @@ public: } } - small_vector(small_vector&& v) + small_vector(small_vector &&v) : Alloc(std::move(v.get_alloc())) , m_capacity(v.m_capacity) , m_dynamic_capacity(v.m_dynamic_capacity) @@ -300,7 +310,7 @@ public: } } - small_vector& operator=(const small_vector& v) + small_vector &operator=(const small_vector &v) { if (this == &v) { @@ -323,7 +333,7 @@ public: return *this; } - small_vector& operator=(small_vector&& v) + small_vector &operator=(small_vector &&v) { clear(); @@ -357,7 +367,7 @@ public: return *this; } - void assign(size_type count, const T& value) + void assign(size_type count, const T &value) { clear(); assign_impl(count, value); @@ -512,7 +522,8 @@ public: void reserve(size_type new_cap) { - if (new_cap <= m_capacity) return; + if (new_cap <= m_capacity) + return; auto new_buf = choose_data(new_cap); @@ -520,7 +531,7 @@ public: assert(new_buf != static_begin_ptr()); // we should never reserve into static memory const auto s = size(); - if(s < RevertToStaticSize) + if (s < RevertToStaticSize) { // we've allocated enough memory for the dynamic buffer but don't move there until we have to return; @@ -558,8 +569,10 @@ public: { const auto s = size(); - if (s == m_capacity) return; - if (m_begin == static_begin_ptr()) return; + if (s == m_capacity) + return; + if (m_begin == static_begin_ptr()) + return; auto old_end = m_end; @@ -591,8 +604,10 @@ public: void revert_to_static() { const auto s = size(); - if (m_begin == static_begin_ptr()) return; //we're already there - if (s > StaticCapacity) return; // nothing we can do + if (m_begin == static_begin_ptr()) + return; //we're already there + if (s > StaticCapacity) + return; // nothing we can do // revert to static capacity auto old_end = m_end; @@ -625,21 +640,21 @@ public: } } - iterator insert(const_iterator position, const value_type& val) + iterator insert(const_iterator position, const value_type &val) { auto pos = grow_at(position, 1); atraits::construct(get_alloc(), pos, val); return pos; } - iterator insert(const_iterator position, value_type&& val) + iterator insert(const_iterator position, value_type &&val) { auto pos = grow_at(position, 1); atraits::construct(get_alloc(), pos, std::move(val)); return pos; } - iterator insert(const_iterator position, size_type count, const value_type& val) + iterator insert(const_iterator position, size_type count, const value_type &val) { auto pos = grow_at(position, count); for (size_type i = 0; i < count; ++i) @@ -666,7 +681,7 @@ public: { auto pos = grow_at(position, ilist.size()); size_type i = 0; - for (auto& elem : ilist) + for (auto &elem : ilist) { atraits::construct(get_alloc(), pos + i, elem); ++i; @@ -674,8 +689,8 @@ public: return pos; } - template - iterator emplace(const_iterator position, Args&&... args) + template + iterator emplace(const_iterator position, Args &&... args) { auto pos = grow_at(position, 1); atraits::construct(get_alloc(), pos, std::forward(args)...); @@ -699,14 +714,14 @@ public: atraits::construct(get_alloc(), pos, val); } - void push_back(T&& val) + void push_back(T &&val) { auto pos = grow_at(m_end, 1); atraits::construct(get_alloc(), pos, std::move(val)); } - template - reference emplace_back(Args&&... args) + template + reference emplace_back(Args &&... args) { auto pos = grow_at(m_end, 1); atraits::construct(get_alloc(), pos, std::forward(args)...); @@ -718,7 +733,7 @@ public: shrink_at(m_end - 1, 1); } - void resize(size_type n, const value_type& v) + void resize(size_type n, const value_type &v) { auto new_buf = choose_data(n); @@ -847,7 +862,7 @@ public: } private: - T* static_begin_ptr() + T *static_begin_ptr() { return reinterpret_cast(m_static_data + 0); } @@ -855,9 +870,9 @@ private: // increase the size by splicing the elements in such a way that // a hole of uninitialized elements is left at position, with size num // returns the (potentially new) address of the hole - T* grow_at(const T* cp, size_t num) + T *grow_at(const T *cp, size_t num) { - auto position = const_cast(cp); + auto position = const_cast(cp); I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(position < m_begin || position > m_end); @@ -919,9 +934,9 @@ private: } } - T* shrink_at(const T* cp, size_t num) + T *shrink_at(const T *cp, size_t num) { - auto position = const_cast(cp); + auto position = const_cast(cp); I_ITLIB_SMALL_VECTOR_OUT_OF_RANGE_IF(position < m_begin || position > m_end || position + num > m_end); @@ -985,7 +1000,7 @@ private: return ++position; } - void assign_impl(size_type count, const T& value) + void assign_impl(size_type count, const T &value) { assert(m_begin); assert(m_begin == m_end); @@ -1022,7 +1037,7 @@ private: assert(m_begin == m_end); m_begin = m_end = choose_data(ilist.size()); - for (auto& elem : ilist) + for (auto &elem : ilist) { atraits::construct(get_alloc(), m_end, elem); ++m_end; @@ -1043,7 +1058,7 @@ private: } } - T* choose_data(size_t desired_capacity) + T *choose_data(size_t desired_capacity) { if (m_begin == m_dynamic_data) { @@ -1105,8 +1120,8 @@ private: } } - allocator_type& get_alloc() { return static_cast(*this); } - const allocator_type& get_alloc() const { return static_cast(*this); } + allocator_type &get_alloc() { return static_cast(*this); } + const allocator_type &get_alloc() const { return static_cast(*this); } pointer m_begin; pointer m_end; @@ -1118,9 +1133,9 @@ private: pointer m_dynamic_data; }; -template -bool operator==(const small_vector& a, - const small_vector& b) +template +bool operator==(const small_vector &a, + const small_vector &b) { if (a.size() != b.size()) { @@ -1136,9 +1151,9 @@ bool operator==(const small_vector return true; } -template -bool operator!=(const small_vector& a, - const small_vector& b) +template +bool operator!=(const small_vector &a, + const small_vector &b) { if (a.size() != b.size()) { diff --git a/lib/nncase/v1/include/nncase/runtime/span_reader.h b/lib/nncase/v1/include/nncase/runtime/span_reader.h index e3bb0f8..5f28097 100644 --- a/lib/nncase/v1/include/nncase/runtime/span_reader.h +++ b/lib/nncase/v1/include/nncase/runtime/span_reader.h @@ -1,4 +1,4 @@ -/* Copyright 2019-2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/runtime/stackvm/op_reader.h b/lib/nncase/v1/include/nncase/runtime/stackvm/op_reader.h index 08277d1..252528c 100644 --- a/lib/nncase/v1/include/nncase/runtime/stackvm/op_reader.h +++ b/lib/nncase/v1/include/nncase/runtime/stackvm/op_reader.h @@ -1,6 +1,6 @@ -/* This file is generated by tools/stackvm_gen/IsaGen at 2021/5/28 11:52:08 +08:00. +/* This file is generated by tools/stackvm_gen/IsaGen at 2021/7/14 19:17:48 +08:00. * - * Copyright 2020 Canaan Inc. + * Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1148,24 +1148,6 @@ struct op_reader } }; -template <> -struct op_reader -{ - tensor_concat_op_t operator()(span_reader &reader) const - { - tensor_concat_op_t op(default_init); - op.opcode = static_cast(reader.read_unaligned()); - op.funct = static_cast(reader.read_unaligned()); - op.datatype = static_cast(reader.read_unaligned()); - op.num_src = reader.read_unaligned(); - op.axis = reader.read_unaligned(); - op.rshape_dims = reader.read_unaligned(); - op.rshape_dest = reader.read_unaligned(); - op.rstride_dest = reader.read_unaligned(); - return op; - } -}; - template <> struct op_reader { @@ -1192,6 +1174,22 @@ struct op_reader } }; +template <> +struct op_reader +{ + tensor_copy_op_t operator()(span_reader &reader) const + { + tensor_copy_op_t op(default_init); + op.opcode = static_cast(reader.read_unaligned()); + op.funct = static_cast(reader.read_unaligned()); + op.datatype = static_cast(reader.read_unaligned()); + op.rshape = reader.read_unaligned(); + op.rstride_src = reader.read_unaligned(); + op.rstride_dest = reader.read_unaligned(); + return op; + } +}; + template <> struct op_reader { @@ -1226,6 +1224,44 @@ struct op_reader } }; +template <> +struct op_reader +{ + tensor_gather_op_t operator()(span_reader &reader) const + { + tensor_gather_op_t op(default_init); + op.opcode = static_cast(reader.read_unaligned()); + op.funct = static_cast(reader.read_unaligned()); + op.datatype = static_cast(reader.read_unaligned()); + op.rshape_src = reader.read_unaligned(); + op.rshape_dest = reader.read_unaligned(); + op.rstride_src = reader.read_unaligned(); + op.rstride_dest = reader.read_unaligned(); + op.rshape_indices = reader.read_unaligned(); + op.axis = reader.read_unaligned(); + return op; + } +}; + +template <> +struct op_reader +{ + tensor_gather_nd_op_t operator()(span_reader &reader) const + { + tensor_gather_nd_op_t op(default_init); + op.opcode = static_cast(reader.read_unaligned()); + op.funct = static_cast(reader.read_unaligned()); + op.datatype = static_cast(reader.read_unaligned()); + op.rshape_src = reader.read_unaligned(); + op.rshape_dest = reader.read_unaligned(); + op.rstride_src = reader.read_unaligned(); + op.rstride_dest = reader.read_unaligned(); + op.rshape_indices = reader.read_unaligned(); + op.batch_dims = reader.read_unaligned(); + return op; + } +}; + template <> struct op_reader { @@ -1243,6 +1279,24 @@ struct op_reader } }; +template <> +struct op_reader +{ + tensor_onehot_op_t operator()(span_reader &reader) const + { + tensor_onehot_op_t op(default_init); + op.opcode = static_cast(reader.read_unaligned()); + op.funct = static_cast(reader.read_unaligned()); + op.datatype = static_cast(reader.read_unaligned()); + op.rshape_indices = reader.read_unaligned(); + op.rshape_dest = reader.read_unaligned(); + op.rstride_dest = reader.read_unaligned(); + op.axis = reader.read_unaligned(); + op.onehot_mode = static_cast(reader.read_unaligned()); + return op; + } +}; + template <> struct op_reader { @@ -1322,6 +1376,25 @@ struct op_reader } }; +template <> +struct op_reader +{ + tensor_resize_image_op_t operator()(span_reader &reader) const + { + tensor_resize_image_op_t op(default_init); + op.opcode = static_cast(reader.read_unaligned()); + op.funct = static_cast(reader.read_unaligned()); + op.datatype = static_cast(reader.read_unaligned()); + op.rshape_src = reader.read_unaligned(); + op.rstride_src = reader.read_unaligned(); + op.rstride_dest = reader.read_unaligned(); + op.align_corners = reader.read_unaligned(); + op.half_pixel_centers = reader.read_unaligned(); + op.image_resize_mode = static_cast(reader.read_unaligned()); + return op; + } +}; + template <> struct op_reader { @@ -1485,15 +1558,19 @@ public: virtual result visit(NNCASE_UNUSED const tensor_broadcast_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_binary_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_call_op_t &op) noexcept { return ok(); } - virtual result visit(NNCASE_UNUSED const tensor_concat_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_conv2d_op_t &op) noexcept { return ok(); } + virtual result visit(NNCASE_UNUSED const tensor_copy_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_convert_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_dequantize_op_t &op) noexcept { return ok(); } + virtual result visit(NNCASE_UNUSED const tensor_gather_op_t &op) noexcept { return ok(); } + virtual result visit(NNCASE_UNUSED const tensor_gather_nd_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_lut1d_op_t &op) noexcept { return ok(); } + virtual result visit(NNCASE_UNUSED const tensor_onehot_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_pad_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_quantize_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_reduce_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_reduce_window2d_op_t &op) noexcept { return ok(); } + virtual result visit(NNCASE_UNUSED const tensor_resize_image_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_slice_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_unary_op_t &op) noexcept { return ok(); } virtual result visit(NNCASE_UNUSED const tensor_transpose_op_t &op) noexcept { return ok(); } diff --git a/lib/nncase/v1/include/nncase/runtime/stackvm/opcode.h b/lib/nncase/v1/include/nncase/runtime/stackvm/opcode.h index 13f5ad3..122a4d2 100644 --- a/lib/nncase/v1/include/nncase/runtime/stackvm/opcode.h +++ b/lib/nncase/v1/include/nncase/runtime/stackvm/opcode.h @@ -1,6 +1,6 @@ -/* This file is generated by tools/stackvm_gen/IsaGen at 2021/5/28 11:52:08 +08:00. +/* This file is generated by tools/stackvm_gen/IsaGen at 2021/7/14 19:17:48 +08:00. * - * Copyright 2020 Canaan Inc. + * Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,25 +127,28 @@ enum class tensor_function_t BROADCAST = 0x0002, CALL = 0x0003, CLAMP = 0x0004, - CONCAT = 0x0005, - CONV2D = 0x0006, - CONV2D_TRANSPOSE = 0x0007, - CONVERT = 0x0008, + CONV2D = 0x0005, + CONV2D_TRANSPOSE = 0x0006, + CONVERT = 0x0007, + COPY = 0x0008, DEQUANTIZE = 0x0009, - LOGISTIC = 0x000A, - LUT1D = 0x000B, - MATMUL = 0x000C, - PAD = 0x000D, - QUANTIZE = 0x000E, - REDUCE = 0x000F, - REDUCE_WINDOW2D = 0x0010, - RESIZE_IMAGE = 0x0011, - SLICE = 0x0012, - SOFTMAX = 0x0013, - SPACE_TO_BATCH = 0x0014, - TAKE = 0x0015, - TRANSPOSE = 0x0016, - UNARY = 0x0017, + GATHER = 0x000A, + GATHER_ND = 0x000B, + LOGISTIC = 0x000C, + LUT1D = 0x000D, + MATMUL = 0x000E, + ONEHOT = 0x000F, + PAD = 0x0010, + QUANTIZE = 0x0011, + REDUCE = 0x0012, + REDUCE_WINDOW2D = 0x0013, + RESIZE_IMAGE = 0x0014, + SLICE = 0x0015, + SOFTMAX = 0x0016, + SPACE_TO_BATCH = 0x0017, + TAKE = 0x0018, + TRANSPOSE = 0x0019, + UNARY = 0x001A, }; // Instructions @@ -1273,24 +1276,6 @@ struct tensor_call_op_t } }; -struct tensor_concat_op_t -{ - opcode_t opcode; - tensor_function_t funct; - datatype_t datatype; - uint8_t num_src; - uint8_t axis; - uint8_t rshape_dims; - uint8_t rshape_dest; - uint8_t rstride_dest; - - tensor_concat_op_t(default_init_t) noexcept { } - explicit tensor_concat_op_t(datatype_t datatype, uint8_t num_src, uint8_t axis, uint8_t rshape_dims, uint8_t rshape_dest, uint8_t rstride_dest) noexcept - : opcode(opcode_t::TENSOR), funct(tensor_function_t::CONCAT), datatype(datatype), num_src(num_src), axis(axis), rshape_dims(rshape_dims), rshape_dest(rshape_dest), rstride_dest(rstride_dest) - { - } -}; - struct tensor_conv2d_op_t { opcode_t opcode; @@ -1317,6 +1302,22 @@ struct tensor_conv2d_op_t } }; +struct tensor_copy_op_t +{ + opcode_t opcode; + tensor_function_t funct; + datatype_t datatype; + uint8_t rshape; + uint8_t rstride_src; + uint8_t rstride_dest; + + tensor_copy_op_t(default_init_t) noexcept { } + explicit tensor_copy_op_t(datatype_t datatype, uint8_t rshape, uint8_t rstride_src, uint8_t rstride_dest) noexcept + : opcode(opcode_t::TENSOR), funct(tensor_function_t::COPY), datatype(datatype), rshape(rshape), rstride_src(rstride_src), rstride_dest(rstride_dest) + { + } +}; + struct tensor_convert_op_t { opcode_t opcode; @@ -1351,6 +1352,44 @@ struct tensor_dequantize_op_t } }; +struct tensor_gather_op_t +{ + opcode_t opcode; + tensor_function_t funct; + datatype_t datatype; + uint8_t rshape_src; + uint8_t rshape_dest; + uint8_t rstride_src; + uint8_t rstride_dest; + uint8_t rshape_indices; + uint8_t axis; + + tensor_gather_op_t(default_init_t) noexcept { } + explicit tensor_gather_op_t(datatype_t datatype, uint8_t rshape_src, uint8_t rshape_dest, uint8_t rstride_src, uint8_t rstride_dest, uint8_t rshape_indices, uint8_t axis) noexcept + : opcode(opcode_t::TENSOR), funct(tensor_function_t::GATHER), datatype(datatype), rshape_src(rshape_src), rshape_dest(rshape_dest), rstride_src(rstride_src), rstride_dest(rstride_dest), rshape_indices(rshape_indices), axis(axis) + { + } +}; + +struct tensor_gather_nd_op_t +{ + opcode_t opcode; + tensor_function_t funct; + datatype_t datatype; + uint8_t rshape_src; + uint8_t rshape_dest; + uint8_t rstride_src; + uint8_t rstride_dest; + uint8_t rshape_indices; + uint8_t batch_dims; + + tensor_gather_nd_op_t(default_init_t) noexcept { } + explicit tensor_gather_nd_op_t(datatype_t datatype, uint8_t rshape_src, uint8_t rshape_dest, uint8_t rstride_src, uint8_t rstride_dest, uint8_t rshape_indices, uint8_t batch_dims) noexcept + : opcode(opcode_t::TENSOR), funct(tensor_function_t::GATHER_ND), datatype(datatype), rshape_src(rshape_src), rshape_dest(rshape_dest), rstride_src(rstride_src), rstride_dest(rstride_dest), rshape_indices(rshape_indices), batch_dims(batch_dims) + { + } +}; + struct tensor_lut1d_op_t { opcode_t opcode; @@ -1368,6 +1407,24 @@ struct tensor_lut1d_op_t } }; +struct tensor_onehot_op_t +{ + opcode_t opcode; + tensor_function_t funct; + datatype_t datatype; + uint8_t rshape_indices; + uint8_t rshape_dest; + uint8_t rstride_dest; + uint8_t axis; + onehot_mode_t onehot_mode; + + tensor_onehot_op_t(default_init_t) noexcept { } + explicit tensor_onehot_op_t(datatype_t datatype, uint8_t rshape_indices, uint8_t rshape_dest, uint8_t rstride_dest, uint8_t axis, onehot_mode_t onehot_mode) noexcept + : opcode(opcode_t::TENSOR), funct(tensor_function_t::ONEHOT), datatype(datatype), rshape_indices(rshape_indices), rshape_dest(rshape_dest), rstride_dest(rstride_dest), axis(axis), onehot_mode(onehot_mode) + { + } +}; + struct tensor_pad_op_t { opcode_t opcode; @@ -1447,6 +1504,25 @@ struct tensor_reduce_window2d_op_t } }; +struct tensor_resize_image_op_t +{ + opcode_t opcode; + tensor_function_t funct; + datatype_t datatype; + uint8_t rshape_src; + uint8_t rstride_src; + uint8_t rstride_dest; + bool align_corners; + bool half_pixel_centers; + image_resize_mode_t image_resize_mode; + + tensor_resize_image_op_t(default_init_t) noexcept { } + explicit tensor_resize_image_op_t(datatype_t datatype, uint8_t rshape_src, uint8_t rstride_src, uint8_t rstride_dest, bool align_corners, bool half_pixel_centers, image_resize_mode_t image_resize_mode) noexcept + : opcode(opcode_t::TENSOR), funct(tensor_function_t::RESIZE_IMAGE), datatype(datatype), rshape_src(rshape_src), rstride_src(rstride_src), rstride_dest(rstride_dest), align_corners(align_corners), half_pixel_centers(half_pixel_centers), image_resize_mode(image_resize_mode) + { + } +}; + struct tensor_slice_op_t { opcode_t opcode; diff --git a/lib/nncase/v1/include/nncase/runtime/stackvm/runtime_module.h b/lib/nncase/v1/include/nncase/runtime/stackvm/runtime_module.h index f7d1cda..3e0a361 100644 --- a/lib/nncase/v1/include/nncase/runtime/stackvm/runtime_module.h +++ b/lib/nncase/v1/include/nncase/runtime/stackvm/runtime_module.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/nncase/v1/include/nncase/version.h b/lib/nncase/v1/include/nncase/version.h index 1b67733..6aff662 100644 --- a/lib/nncase/v1/include/nncase/version.h +++ b/lib/nncase/v1/include/nncase/version.h @@ -1,4 +1,4 @@ -/* Copyright 2020 Canaan Inc. +/* Copyright 2019-2021 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,4 +14,4 @@ */ #pragma once #define NNCASE_VERSION "1.0.0" -#define NNCASE_GIT_DESC "0dc08ae" +#define NNCASE_VERSION_SUFFIX "-8c384a4" diff --git a/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeConfig.cmake b/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeConfig.cmake index b4500a2..f5effc2 100644 --- a/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeConfig.cmake +++ b/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeConfig.cmake @@ -1 +1,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/nncaseruntimeTargets.cmake) +if(NOT TARGET mpark_variant) + find_package(mpark_variant REQUIRED) +endif() + +if(NOT TARGET gsl-lite) + find_package(gsl-lite REQUIRED) +endif() + + diff --git a/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeTargets.cmake b/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeTargets.cmake index 5d4c6e8..92dcf51 100644 --- a/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeTargets.cmake +++ b/lib/nncase/v1/lib/cmake/nncaseruntime/nncaseruntimeTargets.cmake @@ -54,14 +54,14 @@ endif() add_library(kernels INTERFACE IMPORTED) set_target_properties(kernels PROPERTIES - INTERFACE_LINK_LIBRARIES "CONAN_PKG::gsl-lite;CONAN_PKG::mpark-variant" + INTERFACE_LINK_LIBRARIES "gsl::gsl-lite;mpark_variant::mpark_variant" ) # Create imported target runtime add_library(runtime INTERFACE IMPORTED) set_target_properties(runtime PROPERTIES - INTERFACE_LINK_LIBRARIES "CONAN_PKG::gsl-lite;CONAN_PKG::mpark-variant;\$" + INTERFACE_LINK_LIBRARIES "gsl::gsl-lite;mpark_variant::mpark_variant;\$" ) # Create imported target nncaseruntime @@ -69,7 +69,7 @@ add_library(nncaseruntime STATIC IMPORTED) set_target_properties(nncaseruntime PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" - INTERFACE_LINK_LIBRARIES "\$;\$;\$;CONAN_PKG::gsl-lite;CONAN_PKG::mpark-variant" + INTERFACE_LINK_LIBRARIES "\$;\$;\$;gsl::gsl-lite;mpark_variant::mpark_variant" ) # Create imported target runtime_stackvm diff --git a/lib/nncase/v1/lib/libnncase.rt_modules.k210.a b/lib/nncase/v1/lib/libnncase.rt_modules.k210.a index 9a9293e..e81135e 100644 Binary files a/lib/nncase/v1/lib/libnncase.rt_modules.k210.a and b/lib/nncase/v1/lib/libnncase.rt_modules.k210.a differ diff --git a/lib/nncase/v1/lib/libnncase.runtime.a b/lib/nncase/v1/lib/libnncase.runtime.a index c6dd40c..2fdadb6 100644 Binary files a/lib/nncase/v1/lib/libnncase.runtime.a and b/lib/nncase/v1/lib/libnncase.runtime.a differ diff --git a/lib/nncase/v1/nncase_v1.cpp b/lib/nncase/v1/nncase_v1.cpp index 8ac32a2..4c54325 100644 --- a/lib/nncase/v1/nncase_v1.cpp +++ b/lib/nncase/v1/nncase_v1.cpp @@ -49,7 +49,7 @@ public: result run_kmodel(const uint8_t *src, dmac_channel_number_t dma_ch) { -#ifdef NNCASE_DEBUG +#if NNCASE_DEBUG auto micro = sysctl_get_time_us(); #endif try_(interp_.options().set("dma_ch", (uint32_t)dma_ch)); @@ -59,7 +59,7 @@ public: try_(hrt::sync(input_tensor, hrt::sync_write_back)); try_(interp_.input_tensor(0, input_tensor)); try_(interp_.run()); -#ifdef NNCASE_DEBUG +#if NNCASE_DEBUG auto duration = sysctl_get_time_us() - micro; printf("run kmodel takes %f ms.\n", duration / 1e3f); #endif diff --git a/third_party/gsl-lite/CMakeLists.txt b/third_party/gsl-lite/CMakeLists.txt index 7c69a80..0a024e0 100644 --- a/third_party/gsl-lite/CMakeLists.txt +++ b/third_party/gsl-lite/CMakeLists.txt @@ -3,3 +3,4 @@ add_library(gsl-lite INTERFACE) target_include_directories(gsl-lite INTERFACE include) add_library(CONAN_PKG::gsl-lite ALIAS gsl-lite) +add_library(gsl::gsl-lite ALIAS gsl-lite) diff --git a/third_party/mpark-variant/CMakeLists.txt b/third_party/mpark-variant/CMakeLists.txt index bb278e5..ce134ce 100644 --- a/third_party/mpark-variant/CMakeLists.txt +++ b/third_party/mpark-variant/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 3.8) -add_library(mpark-variant INTERFACE) -target_include_directories(mpark-variant INTERFACE include) -add_library(CONAN_PKG::mpark-variant ALIAS mpark-variant) +add_library(mpark_variant INTERFACE) +target_include_directories(mpark_variant INTERFACE include) +add_library(mpark_variant::mpark_variant ALIAS mpark_variant) +add_library(CONAN_PKG::mpark-variant ALIAS mpark_variant)