diff --git a/llvm/include/llvm/IR/IntrinsicsVISC.td b/llvm/include/llvm/IR/IntrinsicsVISC.td index e0d4971f3eda620d35a764d648f94f9c84290ef4..d228a9d01fb84c1fce8536862d50a313a2725079 100644 --- a/llvm/include/llvm/IR/IntrinsicsVISC.td +++ b/llvm/include/llvm/IR/IntrinsicsVISC.td @@ -324,26 +324,34 @@ let TargetPrefix = "visc" in { llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + + // Image processing functions + // See projects/hpvm-tensor-rt/tensor_runtime/include/img_tensor_runtime.h def int_visc_tensor_fft: Intrinsic<[llvm_ptr_ty], [ llvm_ptr_ty ], []>; - def int_visc_tensor_cosineT: Intrinsic<[llvm_ptr_ty], [ - llvm_ptr_ty - ], []>; def int_visc_tensor_reduce: Intrinsic<[llvm_ptr_ty], [ - llvm_ptr_ty, llvm_i32_ty, llvm_ptrptr_ty, llvm_i32_ty + llvm_ptr_ty, llvm_i32_ty, llvm_ptr_ty ], []>; def int_visc_tensor_projectiveT: Intrinsic<[llvm_ptr_ty], [ llvm_ptr_ty, llvm_ptr_ty ], []>; def int_visc_tensor_map1: Intrinsic<[llvm_ptr_ty], [ - llvm_ptr_ty, llvm_ptrptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty + llvm_ptr_ty, llvm_ptr_ty ], []>; def int_visc_tensor_map2: Intrinsic<[llvm_ptr_ty], [ - llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty + llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty ], []>; def int_visc_tensor_map3: Intrinsic<[llvm_ptr_ty], [ - llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty + llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty + ], []>; + + // Tentative functions without an impl yet + def int_visc_tensor_cosineT: Intrinsic<[llvm_ptr_ty], [ + llvm_ptr_ty + ], []>; + def int_visc_tensor_stencil: Intrinsic<[llvm_ptr_ty], [ + llvm_ptr_ty ], []>; } diff --git a/llvm/lib/Transforms/DFG2LLVM_WrapperAPI/DFG2LLVM_WrapperAPI.cpp b/llvm/lib/Transforms/DFG2LLVM_WrapperAPI/DFG2LLVM_WrapperAPI.cpp index 8ccd087d49fc2171ebb95dbd723ed8e4723736db..a6f957bb75685797e224390c9cad099461ff7786 100644 --- a/llvm/lib/Transforms/DFG2LLVM_WrapperAPI/DFG2LLVM_WrapperAPI.cpp +++ b/llvm/lib/Transforms/DFG2LLVM_WrapperAPI/DFG2LLVM_WrapperAPI.cpp @@ -1185,37 +1185,42 @@ errs() << "TensorII: " << *TensorII << "\n"; break; case Intrinsic::visc_tensor_fft: { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorFFT", strRef, 1); - } - break; - case Intrinsic::visc_tensor_cosineT: - { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensor_cosineT", strRef, 1); + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorFft", strRef, 1); } break; case Intrinsic::visc_tensor_reduce: { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensor_reduce", strRef, 4); + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorReduce", strRef, 3); } break; case Intrinsic::visc_tensor_projectiveT: { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensor_projectiveT", strRef, 2); + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorProjectiveT", strRef, 2); } break; case Intrinsic::visc_tensor_map1: { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensor_map1", strRef, 5); + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorMap1", strRef, 2); } break; case Intrinsic::visc_tensor_map2: { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensor_map2", strRef, 6); + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorMap2", strRef, 3); } break; case Intrinsic::visc_tensor_map3: { - codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensor_map3", strRef, 7); + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorMap3", strRef, 4); + } + break; + case Intrinsic::visc_tensor_cosineT: + { + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorCosineT", strRef, 1); + } + break; + case Intrinsic::visc_tensor_stencil: + { + codeGenCommonRoutine(M, RtM, F, TensorII, Args, "wrapper_tensorStencil", strRef, 1); } break; /* diff --git a/llvm/lib/Transforms/GenVISC/GenVISC.cpp b/llvm/lib/Transforms/GenVISC/GenVISC.cpp index 9e41ca494a4eb6495e0fc79a815abebfc2d3bbba..213f5a4d6b0207fa5b45280134d0d225f6b1423a 100644 --- a/llvm/lib/Transforms/GenVISC/GenVISC.cpp +++ b/llvm/lib/Transforms/GenVISC/GenVISC.cpp @@ -179,12 +179,14 @@ IS_VISC_CALL(tensor_sigmoid) IS_VISC_CALL(tensor_softmax) // Image processing tensor operators IS_VISC_CALL(tensor_fft) -IS_VISC_CALL(tensor_cosineT) IS_VISC_CALL(tensor_reduce) IS_VISC_CALL(tensor_projectiveT) IS_VISC_CALL(tensor_map1) IS_VISC_CALL(tensor_map2) IS_VISC_CALL(tensor_map3) +// Image processing tensor operators (tentative) +IS_VISC_CALL(tensor_cosineT) +IS_VISC_CALL(tensor_stencil) // Return the constant integer represented by value V static unsigned getNumericValue(Value* V) { @@ -1319,9 +1321,6 @@ bool GenVISC::runOnModule(Module &M) { if (isVISCCall_tensor_fft(I)) { ReplaceCallWithIntrinsic(I, Intrinsic::visc_tensor_fft, &toBeErased); } - if (isVISCCall_tensor_cosineT(I)) { - ReplaceCallWithIntrinsic(I, Intrinsic::visc_tensor_cosineT, &toBeErased); - } if (isVISCCall_tensor_reduce(I)) { ReplaceCallWithIntrinsic(I, Intrinsic::visc_tensor_reduce, &toBeErased); } @@ -1337,6 +1336,12 @@ bool GenVISC::runOnModule(Module &M) { if (isVISCCall_tensor_map3(I)) { ReplaceCallWithIntrinsic(I, Intrinsic::visc_tensor_map3, &toBeErased); } + if (isVISCCall_tensor_cosineT(I)) { + ReplaceCallWithIntrinsic(I, Intrinsic::visc_tensor_cosineT, &toBeErased); + } + if (isVISCCall_tensor_stencil(I)) { + ReplaceCallWithIntrinsic(I, Intrinsic::visc_tensor_stencil, &toBeErased); + } } // Erase the __visc__node calls diff --git a/llvm/test/VISC/DNN_Benchmarks/common/include/visc.h b/llvm/test/VISC/DNN_Benchmarks/common/include/visc.h index 55f16e4d8d176e1709e2c6525c3cd47b2bb8da1c..978f29e85a9aae8e310f528bc8fa7630c85d8542 100644 --- a/llvm/test/VISC/DNN_Benchmarks/common/include/visc.h +++ b/llvm/test/VISC/DNN_Benchmarks/common/include/visc.h @@ -104,12 +104,13 @@ void* __visc__tensor_tanh(void*); void* __visc__tensor_softmax(void*); // Tensor ops for image processing void* __visc__tensor_fft(void*); -void* __visc__tensor_cosineT(void*); -void* __visc__tensor_reduce(void*, int, void**, int); +void* __visc__tensor_reduce(void*, int, void*); void* __visc__tensor_projectiveT(void*, void*); -void* __visc__tensor_map1(void*, void**, int, int, int); -void* __visc__tensor_map2(void*, void*, void**, int, int, int); -void* __visc__tensor_map3(void*, void*, void*, void**, int, int, int); +void* __visc__tensor_map1(void*, void*); +void* __visc__tensor_map2(void*, void*, void*); +void* __visc__tensor_map3(void*, void*, void*, void*); +void* __visc__tensor_cosineT(void*); +void* __visc__tensor_stencil(void*); #include <unistd.h>