expression processing: added support for inverse/reciprocal
Some checks are pending
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Waiting to run
Some checks are pending
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Waiting to run
This commit is contained in:
parent
7121329a17
commit
6d3c3164cf
|
@ -6,7 +6,7 @@ export Operator, ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER, ABS, LOG, EXP, SQRT
|
||||||
export ElementType, EMPTY, FLOAT32, OPERATOR, VARIABLE, PARAMETER
|
export ElementType, EMPTY, FLOAT32, OPERATOR, VARIABLE, PARAMETER
|
||||||
export ExpressionElement
|
export ExpressionElement
|
||||||
|
|
||||||
@enum Operator ADD=1 SUBTRACT=2 MULTIPLY=3 DIVIDE=4 POWER=5 ABS=6 LOG=7 EXP=8 SQRT=9
|
@enum Operator ADD=1 SUBTRACT=2 MULTIPLY=3 DIVIDE=4 POWER=5 ABS=6 LOG=7 EXP=8 SQRT=9 INV=10
|
||||||
@enum ElementType EMPTY=0 FLOAT32=1 OPERATOR=2 VARIABLE=3 PARAMETER=4
|
@enum ElementType EMPTY=0 FLOAT32=1 OPERATOR=2 VARIABLE=3 PARAMETER=4
|
||||||
|
|
||||||
const binary_operators = [ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER]
|
const binary_operators = [ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER]
|
||||||
|
@ -99,6 +99,8 @@ function get_operator(op::Symbol)::Operator
|
||||||
return EXP
|
return EXP
|
||||||
elseif op == :sqrt
|
elseif op == :sqrt
|
||||||
return SQRT
|
return SQRT
|
||||||
|
elseif op == :inv
|
||||||
|
return INV
|
||||||
else
|
else
|
||||||
throw("Operator unknown. Operator was $op")
|
throw("Operator unknown. Operator was $op")
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,6 +98,8 @@ function interpret_expression(expressions::CuDeviceArray{ExpressionElement}, var
|
||||||
operationStack[operationStackTop] = exp(operationStack[operationStackTop])
|
operationStack[operationStackTop] = exp(operationStack[operationStackTop])
|
||||||
elseif opcode == SQRT
|
elseif opcode == SQRT
|
||||||
operationStack[operationStackTop] = sqrt(operationStack[operationStackTop])
|
operationStack[operationStackTop] = sqrt(operationStack[operationStackTop])
|
||||||
|
elseif opcode == INV
|
||||||
|
operationStack[operationStackTop] = inv(operationStack[operationStackTop])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
operationStack[operationStackTop] = NaN32
|
operationStack[operationStackTop] = NaN32
|
||||||
|
|
|
@ -316,6 +316,8 @@ function get_operation(operator::Operator, regManager::Utils.RegisterManager, le
|
||||||
ex2.approx.f32 $resultRegister, $resultRegister;"
|
ex2.approx.f32 $resultRegister, $resultRegister;"
|
||||||
elseif operator == SQRT
|
elseif operator == SQRT
|
||||||
resultCode = "sqrt.approx.f32 $resultRegister, $left;"
|
resultCode = "sqrt.approx.f32 $resultRegister, $left;"
|
||||||
|
elseif operator == INV
|
||||||
|
resultCode = "rcp.approx.f32 $resultRegister, $left;"
|
||||||
else
|
else
|
||||||
throw(ArgumentError("Operator conversion to ptx not implemented for '$operator'"))
|
throw(ArgumentError("Operator conversion to ptx not implemented for '$operator'"))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user