| 1 |
// This file contains all the tests for int8_prepare_b_from_quantized_transposed intrinsic. It depends |
| 2 |
// on the CommonTestSetup.js script which contains the common functionality |
| 3 |
// that is required for testing all the intrinsics. |
| 4 |
const COMMON_TEST_SETUP_SCRIPT = "./CommonTestSetup.js" |
| 5 |
|
| 6 |
// All tests for this intrinsic as a string |
| 7 |
const ALL_TESTS_AS_STRING =` |
| 8 |
let {int8_prepare_b_from_quantized_transposed} = instance.exports; |
| 9 |
|
| 10 |
const VALID = {input: 0, rows: ROWS_B_MULTIPLIER, cols: COLUMNS_B_MULTIPLIER, output: ARRAY_ALIGNMENT << 5}; |
| 11 |
|
| 12 |
function testInvalidSize() { |
| 13 |
let invalidSize; |
| 14 |
|
| 15 |
// row: 0 |
| 16 |
invalidSize = 0; |
| 17 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(VALID.input, invalidSize, VALID.cols, VALID.output), WebAssembly.RuntimeError, /unreachable/); |
| 18 |
|
| 19 |
// row: Not an integral multiple of ROWS_B_MULTIPLIER |
| 20 |
invalidSize = ROWS_B_MULTIPLIER + 1; |
| 21 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(VALID.input, invalidSize, VALID.cols, VALID.output), WebAssembly.RuntimeError, /unreachable/); |
| 22 |
|
| 23 |
// col: 0 |
| 24 |
invalidSize = 0; |
| 25 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(VALID.input, VALID.rows, invalidSize, VALID.output), WebAssembly.RuntimeError, /unreachable/); |
| 26 |
|
| 27 |
// col: Not an integral multiple of COLUMNS_B_MULTIPLIER |
| 28 |
invalidSize = COLUMNS_B_MULTIPLIER + 1; |
| 29 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(VALID.input, VALID.rows, invalidSize, VALID.output), WebAssembly.RuntimeError, /unreachable/); |
| 30 |
} |
| 31 |
|
| 32 |
function testInvalidAlignment() { |
| 33 |
let invalidAlignment = ARRAY_ALIGNMENT + 1; |
| 34 |
|
| 35 |
// input: Not an integral multiple of ARRAY_ALIGNMENT |
| 36 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(invalidAlignment, VALID.rows, VALID.cols, VALID.output), WebAssembly.RuntimeError, /index out of bounds/); |
| 37 |
|
| 38 |
// output: Not an integral multiple of ARRAY_ALIGNMENT |
| 39 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(VALID.input, VALID.rows, VALID.cols, invalidAlignment), WebAssembly.RuntimeError, /index out of bounds/); |
| 40 |
} |
| 41 |
|
| 42 |
function testOutOfBounds() { |
| 43 |
let outOfBound = PageSizeInBytes - ARRAY_ALIGNMENT; |
| 44 |
|
| 45 |
// input: Out of Bounds |
| 46 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(outOfBound, VALID.rows, VALID.cols, VALID.output), WebAssembly.RuntimeError, /index out of bounds/); |
| 47 |
|
| 48 |
// output: Out of Bounds |
| 49 |
assertErrorMessage(() => int8_prepare_b_from_quantized_transposed(VALID.input, VALID.rows, VALID.cols, outOfBound), WebAssembly.RuntimeError, /index out of bounds/); |
| 50 |
} |
| 51 |
|
| 52 |
function testSuccessfulCall() { |
| 53 |
// We just test that with valid arguments the intrinsic executes without any error |
| 54 |
int8_prepare_b_from_quantized_transposed(VALID.input, VALID.rows, VALID.cols, VALID.output); |
| 55 |
} |
| 56 |
|
| 57 |
testInvalidSize(); |
| 58 |
testInvalidAlignment(); |
| 59 |
testOutOfBounds(); |
| 60 |
testSuccessfulCall(); |
| 61 |
` |
| 62 |
|
| 63 |
// Run all the tests |
| 64 |
import(COMMON_TEST_SETUP_SCRIPT).then((importedModule) => { |
| 65 |
importedModule.runTest(importedModule.COMMON_TEST_SETUP_AS_STRING + ALL_TESTS_AS_STRING); |
| 66 |
}); |