Skip to content

Commit

Permalink
[webgl] Fix nightly browser configurations (tensorflow#5687)
Browse files Browse the repository at this point in the history
Run the correct browsers in nightly and pass the correct parameters to them to match the original test-ci.sh file.

Pin Firefox to 90.

Fix square test comparison precision on Safari webgl1.
  • Loading branch information
mattsoulanille authored Oct 1, 2021
1 parent bef2fee commit 9e54753
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 21 deletions.
82 changes: 64 additions & 18 deletions tfjs-backend-webgl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,9 @@ pkg_npm(
],
)

BROWSERS = [
"bs_chrome_mac",
"bs_firefox_mac",
"bs_safari_mac",
"bs_ios_11",
"bs_android_9",
"win_10_chrome",
]

STATIC_FILES = [
# Listed here so sourcemaps are served
"//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle",
# For the webworker
":tf-backend-webgl.min.js",
":tf-backend-webgl.min.js.map",
"//tfjs-backend-cpu:tf-backend-cpu.min.js",
"//tfjs-backend-cpu:tf-backend-cpu.min.js.map",
"//tfjs-core:tf-core.min.js",
"//tfjs-core:tf-core.min.js.map",
]

tfjs_web_test(
Expand All @@ -121,7 +105,12 @@ tfjs_web_test(
"--testEnv",
"webgl2",
],
browsers = BROWSERS,
browsers = [
"bs_chrome_mac",
"bs_firefox_mac",
"bs_android_9",
"win_10_chrome",
],
static_files = STATIC_FILES,
)

Expand All @@ -134,7 +123,64 @@ tfjs_web_test(
"--testEnv",
"webgl1",
],
browsers = BROWSERS,
browsers = [
"bs_safari_mac",
"bs_ios_11",
],
static_files = STATIC_FILES,
)

tfjs_web_test(
name = "tfjs-backend-webgl_unpacked_test",
srcs = [
"//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle",
],
args = [
"--testEnv",
"webgl2",
"--flags",
'{"WEBGL_PACK": false}',
],
browsers = [
"bs_chrome_mac",
],
presubmit_browsers = [], # Only run in nightly
static_files = STATIC_FILES,
)

tfjs_web_test(
name = "tfjs-backend-webgl_forward_test",
srcs = [
"//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle",
],
args = [
"--testEnv",
"webgl2",
"--flags",
'{"WEBGL_CPU_FORWARD": true}',
],
browsers = [
"bs_chrome_mac",
],
presubmit_browsers = [], # Only run in nightly
static_files = STATIC_FILES,
)

tfjs_web_test(
name = "tfjs-backend-webgl_uniforms_test",
srcs = [
"//tfjs-backend-webgl/src:tfjs-backend-webgl_test_bundle",
],
args = [
"--testEnv",
"webgl2",
"--flags",
'{"WEBGL_USE_SHAPES_UNIFORMS": true}',
],
browsers = [
"bs_chrome_mac",
],
presubmit_browsers = [], # Only run in nightly
static_files = STATIC_FILES,
)

Expand Down
10 changes: 8 additions & 2 deletions tfjs-core/src/ops/square_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import * as tf from '../index';
import {ALL_ENVS, describeWithFlags} from '../jasmine_util';
import {expectArraysClose} from '../test_util';
import {expectArraysClose, expectNumbersClose} from '../test_util';

describeWithFlags('square', ALL_ENVS, () => {
it('1D array', async () => {
Expand Down Expand Up @@ -59,7 +59,13 @@ describeWithFlags('square', ALL_ENVS, () => {
const a = tf.tensor1d([2, 4, 40000], 'int32');
const r = tf.square(a);
expect(r.dtype).toEqual('int32');
expectArraysClose(await r.data(), [4, 16, 1600000000]);
const data = await r.data();
expectNumbersClose(data[0], 4);
expectNumbersClose(data[1], 16);
// Epsilon must be larger here for webgl1
// TODO: Use expectArraysClose when it supports epsilons scaled by the
// numbers being compared.
expectNumbersClose(data[2], 1_600_000_000, 1_000 /* epsilon */);
});

it('gradients: Scalar', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tools/karma_template.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function(config) {
bs_firefox_mac: {
base: 'BrowserStack',
browser: 'firefox',
browser_version: 'latest',
browser_version: '90',
os: 'OS X',
os_version: 'High Sierra'
},
Expand Down

0 comments on commit 9e54753

Please sign in to comment.