-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add timvx op test && Fix timvx_gather op (#756)
* Update CMakeLists.txt * Add files via upload * Update deconvolution.c
- Loading branch information
Showing
22 changed files
with
3,438 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2021, OPEN AI LAB | ||
* Author: [email protected] | ||
* Revised: [email protected] | ||
*/ | ||
|
||
#include "mathp.h" | ||
|
||
#include <stdlib.h> | ||
|
||
|
||
int imin(int a, int b) | ||
{ | ||
return a <= b ? a : b; | ||
} | ||
|
||
|
||
int imax(int a, int b) | ||
{ | ||
return a >= b ? a : b; | ||
} | ||
|
||
|
||
int min_abs(int a, int b) | ||
{ | ||
return imin(abs(a), abs(b)); | ||
} | ||
|
||
|
||
int max_abs(int a, int b) | ||
{ | ||
return imax(abs(a), abs(b)); | ||
} | ||
|
||
|
||
static int solve_gcd(int large, int small) | ||
{ | ||
int val = large % small; | ||
return 0 == val ? small : gcd(small, val); | ||
} | ||
|
||
|
||
int gcd(int a, int b) | ||
{ | ||
if (0 == a || 0 == b) | ||
return 0; | ||
|
||
return solve_gcd(max_abs(a, b), min_abs(a, b)); | ||
} | ||
|
||
|
||
int lcm(int a, int b) | ||
{ | ||
if (0 == a || 0 == b) | ||
return 0; | ||
|
||
return abs(a * b) / solve_gcd(max_abs(a, b), min_abs(a, b)); | ||
} | ||
|
||
|
||
int align(int value, int step) | ||
{ | ||
const int mask = ~(abs(step) - 1); | ||
return (value + step) & mask; | ||
} | ||
|
||
|
||
void* align_address(void* address, int step) | ||
{ | ||
const size_t mask = ~(abs(step) - 1); | ||
return (void*)((size_t)address & mask); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2021, OPEN AI LAB | ||
* Author: [email protected] | ||
* Revised: [email protected] | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
/*! | ||
* @brief Solve min value | ||
* | ||
* @param [in] a: number a | ||
* @param [in] b: number b | ||
* | ||
* @return The solved min value | ||
*/ | ||
int imin(int a, int b); | ||
|
||
|
||
/*! | ||
* @brief Solve max value | ||
* | ||
* @param [in] a: number a | ||
* @param [in] b: number b | ||
* | ||
* @return The solved max value | ||
*/ | ||
int imax(int a, int b); | ||
|
||
|
||
/*! | ||
* @brief Solve min absolute value | ||
* | ||
* @param [in] a: number a | ||
* @param [in] b: number b | ||
* | ||
* @return The solved min absolute value | ||
*/ | ||
int min_abs(int a, int b); | ||
|
||
|
||
/*! | ||
* @brief Solve max absolute value | ||
* | ||
* @param [in] a: number a | ||
* @param [in] b: number b | ||
* | ||
* @return The solved max absolute value | ||
*/ | ||
int max_abs(int a, int b); | ||
|
||
|
||
/*! | ||
* @brief Solve greatest common divisor | ||
* | ||
* @param [in] a: number a | ||
* @param [in] b: number b | ||
* | ||
* @return The solved GCD | ||
*/ | ||
int gcd(int a, int b); | ||
|
||
|
||
/*! | ||
* @brief Solve lowest common multiple | ||
* | ||
* @param [in] a: number a | ||
* @param [in] b: number b | ||
* | ||
* @return The solved LCM | ||
*/ | ||
int lcm(int a, int b); | ||
|
||
|
||
/*! | ||
* @brief Solve min aligned value with the step length | ||
* | ||
* @param [in] value: number which may not be aligned | ||
* @param [in] step: align step | ||
* | ||
* @return The solved aligned value | ||
*/ | ||
int align(int value, int step); | ||
|
||
|
||
/*! | ||
* @brief Get aligned pointer | ||
* | ||
* @param [in] value: pointer which may not be aligned | ||
* @param [in] step: align step | ||
* | ||
* @return The solved aligned pointer | ||
*/ | ||
void* align_address(void* address, int step); |
Oops, something went wrong.