summaryrefslogtreecommitdiffstats
path: root/rs
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2015-06-29 17:43:03 -0700
committerMiao Wang <miaowang@google.com>2015-06-30 10:12:54 -0700
commit6099ee6e081904e73e0fad331e326b0607b6b1dc (patch)
tree5441813f3f96434f9dbb0d08054d44f92eea4eec /rs
parente40d7a632668a3813a443195ba8e2146407a0517 (diff)
downloadframeworks_base-6099ee6e081904e73e0fad331e326b0607b6b1dc.zip
frameworks_base-6099ee6e081904e73e0fad331e326b0607b6b1dc.tar.gz
frameworks_base-6099ee6e081904e73e0fad331e326b0607b6b1dc.tar.bz2
[RenderScript] update the type of offsets for BLAS.BNNM
bug: 22184114 Change-Id: I7e7132aa3563f32de32640567b381f8f5bddf491
Diffstat (limited to 'rs')
-rw-r--r--rs/java/android/renderscript/ScriptIntrinsicBLAS.java12
-rw-r--r--rs/jni/android_renderscript_RenderScript.cpp4
2 files changed, 11 insertions, 5 deletions
diff --git a/rs/java/android/renderscript/ScriptIntrinsicBLAS.java b/rs/java/android/renderscript/ScriptIntrinsicBLAS.java
index aa72fba..06134e5 100644
--- a/rs/java/android/renderscript/ScriptIntrinsicBLAS.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicBLAS.java
@@ -3277,11 +3277,11 @@ public final class ScriptIntrinsicBLAS extends ScriptIntrinsic {
* just before there's a shift down to drop the fractional parts. The output
* values are gated to 0 to 255 to fit in a byte, but the 10-bit format
* gives some headroom to avoid wrapping around on small overflows.
- *
+ *
* @param A The input allocation contains matrix A, supported elements type {@link Element#U8}.
- * @param a_offset The offset for all values in matrix A, e.g A[i,j] = A[i,j] - a_offset.
+ * @param a_offset The offset for all values in matrix A, e.g A[i,j] = A[i,j] - a_offset. Value should be from 0 to 255.
* @param B The input allocation contains matrix B, supported elements type {@link Element#U8}.
- * @param b_offset The offset for all values in matrix B, e.g B[i,j] = B[i,j] - b_offset.
+ * @param b_offset The offset for all values in matrix B, e.g B[i,j] = B[i,j] - b_offset. Value should be from 0 to 255.
* @param C The input allocation contains matrix C, supported elements type {@link Element#U8}.
* @param c_offset The offset for all values in matrix C.
* @param c_mult The multiplier for all values in matrix C, e.g C[i,j] = (C[i,j] + c_offset) * c_mult.
@@ -3289,6 +3289,12 @@ public final class ScriptIntrinsicBLAS extends ScriptIntrinsic {
public void BNNM(Allocation A, int a_offset, Allocation B, int b_offset, Allocation C, int c_offset, int c_mult) {
validateL3(Element.U8(mRS), NO_TRANSPOSE, TRANSPOSE, 0, A, B, C);
+ if (a_offset < 0 || a_offset > 255) {
+ throw new RSRuntimeException("Invalid a_offset passed to BNNM");
+ }
+ if (b_offset < 0 || b_offset > 255) {
+ throw new RSRuntimeException("Invalid b_offset passed to BNNM");
+ }
int M = -1, N = -1, K = -1;
M = A.getType().getY();
N = B.getType().getY();
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index 1833a1c..ffc4fd8 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -696,8 +696,8 @@ nScriptIntrinsicBLAS_BNNM(JNIEnv *_env, jobject _this, jlong con, jlong id, jint
call.M = M;
call.N = N;
call.K = K;
- call.a_offset = a_offset;
- call.b_offset = b_offset;
+ call.a_offset = a_offset & 0xFF;
+ call.b_offset = b_offset & 0xFF;
call.c_offset = c_offset;
call.c_mult_int = c_mult_int;