Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
892 changes: 892 additions & 0 deletions src/layer/riscv/dequantize_riscv.cpp

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/layer/riscv/dequantize_riscv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Tencent is pleased to support the open source community by making ncnn available.
//
// Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// 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.

#ifndef LAYER_DEQUANTIZE_RISCV_H
#define LAYER_DEQUANTIZE_RISCV_H

#include "dequantize.h"

namespace ncnn {

class Dequantize_riscv : public Dequantize
{
public:
Dequantize_riscv();

virtual int forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const;
};

} // namespace ncnn

#endif // LAYER_DEQUANTIZE_RISCV_H
10 changes: 5 additions & 5 deletions src/layer/riscv/flatten_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ int Flatten_riscv::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Opt
}

#if __riscv_vector
const int packn = csrr_vlenb() / 1;
const int packn = csrr_vlenb() / 2; // packn should be 8
#endif

int w = bottom_blob.w;
Expand Down Expand Up @@ -394,7 +394,7 @@ int Flatten_riscv::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Opt
if (dims == 2)
{
#if __riscv_vector
if (elempack == packn) // out_elempack == packn
if (elempack == packn) // must add, because in innerproduct, elempack is 8
{
#pragma omp parallel for num_threads(opt.num_threads)
for (int i = 0; i < h; i++)
Expand All @@ -405,7 +405,7 @@ int Flatten_riscv::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Opt
int n = w * elempack;
while (n > 0)
{
size_t vl = vsetvl_e8m1(n);
size_t vl = elempack;

vint8m1_t _p = vle8_v_i8m1(ptr, vl);
vsse8_v_i8m1(outptr, w * sizeof(unsigned char), _p, vl);
Expand All @@ -422,7 +422,7 @@ int Flatten_riscv::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Opt
if (dims == 3 || dims == 4)
{
#if __riscv_vector
if (elempack == packn) // out_elempack == packn
if (elempack == packn) // must add, because in innerproduct, elempack is 8
{
#pragma omp parallel for num_threads(opt.num_threads)
for (int q = 0; q < channels; q++)
Expand All @@ -433,7 +433,7 @@ int Flatten_riscv::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Opt
int n = size * elempack;
while (n > 0)
{
size_t vl = vsetvl_e8m1(n);
size_t vl = elempack;

vint8m1_t _p = vle8_v_i8m1(ptr, vl);
vsse8_v_i8m1(outptr, size * sizeof(signed char), _p, vl);
Expand Down
Loading