| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- /* Copyright 2019-2020 Canaan Inc.
- *
- * Licensed 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.
- */
- #pragma once
- #include "../node_body.h"
- namespace nncase
- {
- namespace runtime
- {
- namespace cpu
- {
- struct cpu_conv2d_options
- {
- memory_range input;
- memory_range output;
- runtime_shape_t in_shape;
- int32_t out_channels;
- padding padding_h;
- padding padding_w;
- int32_t filter_h;
- int32_t filter_w;
- int32_t stride_h;
- int32_t stride_w;
- int32_t dilation_h;
- int32_t dilation_w;
- value_range<float> fused_activation;
- xtl::span<const float> weights;
- xtl::span<const float> bias;
- void deserialize(span_reader &reader)
- {
- reader.read(input);
- reader.read(output);
- reader.read(in_shape);
- reader.read(out_channels);
- reader.read(padding_h);
- reader.read(padding_w);
- reader.read(filter_h);
- reader.read(filter_w);
- reader.read(stride_h);
- reader.read(stride_w);
- reader.read(dilation_h);
- reader.read(dilation_w);
- reader.read(fused_activation);
- reader.read_span(weights, (size_t)out_channels * in_shape[3] * filter_h * filter_w);
- reader.read_span(bias, out_channels);
- }
- };
- struct cpu_depthwise_conv2d_options
- {
- memory_range input;
- memory_range output;
- runtime_shape_t in_shape;
- padding padding_h;
- padding padding_w;
- int32_t filter_h;
- int32_t filter_w;
- int32_t stride_h;
- int32_t stride_w;
- int32_t dilation_h;
- int32_t dilation_w;
- value_range<float> fused_activation;
- xtl::span<const float> weights;
- xtl::span<const float> bias;
- void deserialize(span_reader &reader)
- {
- reader.read(input);
- reader.read(output);
- reader.read(in_shape);
- reader.read(padding_h);
- reader.read(padding_w);
- reader.read(filter_h);
- reader.read(filter_w);
- reader.read(stride_h);
- reader.read(stride_w);
- reader.read(dilation_h);
- reader.read(dilation_w);
- reader.read(fused_activation);
- reader.read_span(weights, (size_t)in_shape[3] * filter_h * filter_w);
- reader.read_span(bias, in_shape[3]);
- }
- };
- struct cpu_reduce_window2d_options : simple_node_body<cpu_reduce_window2d_options>
- {
- memory_range input;
- memory_range output;
- reduce_op_t reduce_op;
- runtime_shape_t in_shape;
- padding padding_h;
- padding padding_w;
- int32_t filter_h;
- int32_t filter_w;
- int32_t stride_h;
- int32_t stride_w;
- int32_t dilation_h;
- int32_t dilation_w;
- float init_value;
- value_range<float> fused_activation;
- };
- struct cpu_quantized_conv2d_options
- {
- memory_range input;
- memory_range output;
- runtime_shape_t in_shape;
- int32_t out_channels;
- padding padding_h;
- padding padding_w;
- int32_t filter_h;
- int32_t filter_w;
- int32_t stride_h;
- int32_t stride_w;
- int32_t dilation_h;
- int32_t dilation_w;
- int32_t input_offset;
- int32_t filter_offset;
- int32_t output_mul;
- int32_t output_shift;
- int32_t output_offset;
- xtl::span<const uint8_t> weights;
- xtl::span<const int32_t> bias;
- void deserialize(span_reader &reader)
- {
- reader.read(input);
- reader.read(output);
- reader.read(in_shape);
- reader.read(out_channels);
- reader.read(padding_h);
- reader.read(padding_w);
- reader.read(filter_h);
- reader.read(filter_w);
- reader.read(stride_h);
- reader.read(stride_w);
- reader.read(dilation_h);
- reader.read(dilation_w);
- reader.read(input_offset);
- reader.read(filter_offset);
- reader.read(output_mul);
- reader.read(output_shift);
- reader.read(output_offset);
- reader.read_span(weights, (size_t)out_channels * in_shape[3] * filter_h * filter_w);
- reader.read_span(bias, out_channels);
- }
- };
- struct cpu_quantized_depthwise_conv2d_options
- {
- memory_range input;
- memory_range output;
- runtime_shape_t in_shape;
- padding padding_h;
- padding padding_w;
- int32_t filter_h;
- int32_t filter_w;
- int32_t stride_h;
- int32_t stride_w;
- int32_t dilation_h;
- int32_t dilation_w;
- int32_t input_offset;
- int32_t filter_offset;
- int32_t output_mul;
- int32_t output_shift;
- int32_t output_offset;
- xtl::span<const uint8_t> weights;
- xtl::span<const int32_t> bias;
- void deserialize(span_reader &reader)
- {
- reader.read(input);
- reader.read(output);
- reader.read(in_shape);
- reader.read(padding_h);
- reader.read(padding_w);
- reader.read(filter_h);
- reader.read(filter_w);
- reader.read(stride_h);
- reader.read(stride_w);
- reader.read(dilation_h);
- reader.read(dilation_w);
- reader.read(input_offset);
- reader.read(filter_offset);
- reader.read(output_mul);
- reader.read(output_shift);
- reader.read(output_offset);
- reader.read_span(weights, (size_t)in_shape[3] * filter_h * filter_w);
- reader.read_span(bias, in_shape[3]);
- }
- };
- }
- }
- }
|